I'm using a nRF51 beacon as a receiver that produces a pulse when it receives a byte from the transmitter. The code is based on the ble_app_uart example. And I set the connection interval to minimum to minimise the latency.
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS) /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS) /**< Maximum
The beacon is only used every few days and for 1 hour each time. I want to switch off the beacon without pulling the coin battery out or modifying the circuit.
Is it feasible to connect one of the GPIOs to a SPDT switch as a "power switch"? For example, when the pin transitions from high to low, the beacon is powered down (system off) and when the pin transitions from low to high, the beacon is powered up and reset.
Is there any example code to do this with S110 soft device? I have only used an example without the soft device in github.com/.../.
Thank you for you questions.
As explained in the nRF51 current consumption guide, System On and System Off low power modes are enabled with the the sd_app_event_wait() and sd_power_system_off() commands respectively when using softdevice.
To get action on a button, but stay in System On low power mode, you can just insert the following code in the bsp_event_handler in the ble_app_uart example:
When you press Button 1 on the nRF51-DK, then your "Do whatever" code will execute. When the key is not pressed, the nRF51 will stay in System On low power mode (CPU disabled) as code execution falls back to the main loop where power_manage() function (sd_app_event_wait) is executed.
To see how to enter System Off with softdevice, an example is shown in e.g. in the sleep_mode_enter() function in the ble_app_uart example, which also sets up a GPIO pin for waking up again.