This tutorial illustrates how to optimize the energy when the TeensyWiNo is powered by a LiPo battery.
Connecting a LiPo battery
The TeensyWiNo can be powered by a LiPo battery via the battery connector. It embeds a LiPo charger to recharge any LiPo battery. Do not connect another battery type on this connector. When the LiPo battery is connected, the TeensyWiNo acts as a charger as soon as the USB is powered. When the charger is on, the dedicated red LED automatically turned on (no control by software). When the LiPo battery is full, this LED is turned off.
|The TeensyWiNo battery connector||LiPo charger active: charger LED on|
Theoretical energy consumption
The two mains energy consumers on TeensyWiNo are the MCU (Teensy) and the transceiver (RFM22b). When designing an application, remember that:
- The higher the MCU frequency, the higher the energy consumption,
- the transceiver consumes energy even in reception and idle modes.
The following table summarizes the power consumption of the MCU (Teensy: Freescale MK20DX256 VLH7) and the transceiver (HopeRF RFM22b) (source: datasheets).
|Teensy||Sleep, any freq, LPTMR wake||2mW|
|Teensy||Deepsleep, any freq, LPTMR wake||650μW|
|Teensy||Hibernate, any freq, LPTMR wake||<30μW|
Enabling sleep states on the MCU and transceiver
The best way to save the battery is enabling sleep states on both MCU and transceiver.
On the transceiver
With RadioHead, enable the RFM22b sleep mode with:
The transceiver enters in sleep mode just after calling the sleep() method; it then consumes less than 5µW and does not receive messages anymore until waking-up. Wake the transceiver by calling recv(), send()… as indicated in the RadioHead documentation.
On the MCU
Enabling the sleep states (sleep, deepsleep and hibernate) of the Teensy is easy using the Snooze library. The examples sketches work out-of-the-box on the TeensyWiNo.
Note that the USB Serial is lost when the Teensy enters sleep mode.
The lifetime on battery depends heavily on actions on the MCU and the transceiver. Here is an example of a simple code that:
- Get the temperature using the BMP085,
- Get the voltage and charge of the LiPo battery,
- Send these data on radio in an ASCII JSON string,
- Wait 50ms for nothing,
- Turns the transceiver on sleep mode,
- Turns the MCU on sleep mode for 10 seconds.
and can be used to evaluate the lifetime of a TeensyWiNo on a battery.