Now that we have a setup for programming and testing the TX and RX boards, we're starting to explore a bit of programming. One of the possibilities is use sleep modes to conserve battery power. Lowpower labs has a library that puts the MCU to sleep and wakes it up and various intervals.
First download the library here, and put it into the Arduino library folder. To get it working for the PB variant, go to the LowPower.h file and add the PB variant to this line. Chage
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) || defined (__AVR_ATmega328PB__)
Our test involved sleeping the MCU for 8s at a time, it would wake up, receive radio messages and go back to sleep. Adding this line to the code:
LowPower.powerDown(SLEEP_8S, ADC_ON, BOD_OFF);
To calculate the power draw, we disconnected the power board from the controller board, soldered cables to power and ground pins and connected to multimeter in A mode.
Initially the radios were chirping and LEDs were flashing to indicate messages received and acknowledgement. The power readings were all over the place. The sleep seemed promising as we'd note a shift to about 16ma when the sleep cycle kicked in and it would jump to 37ma when there was clearly no sleep happening. The LEDs drawing up to 20ma was a little concerning as we'd see the power bounce all over, so we decided to turn all LEDs off to get a better read on the situation.
At this point we still don't have a good sense of what the radios are doing when we're not explicitly sending or receiving anything. We hope not much. The power draw calculations without LEDs and unused radios are such:
- During sleep, power draw was about 2mA
- Without using the low power mode - 26mA