Proof of concept for an "ultra low power" LoRaWAN / The Things Network node using the Arduino MKR WAN 1300.
The MKR WAN 1300 uses too much power in sleep mode to be used as ultra low power device (a bit more than 1mA).
This proof of concept uses a Texas Instrument TPL5110 Ultra Low Power Timer to bring the sleep current under 50nA.
As the device is completely powered off during sleep time we use a FRAM module to save the LoRaWAN session keys and frame counters.
Two test nodes:
Top left: display and Maxim DS18B20 temperature sensor
Bottom left: Bosch BME280 temperature humidity and pressure sensor
Top right: sleep current
Bottom right: running current (node with the display)
- TPL5110 wakes up and power on the MKR WAN 1300
- Read saved data from FRAM
- Join the network
- OTAA the first time (no data in FRAM)
- ABP using the saved session keys and frame counters afterwards
- Collect data from sensors
- Send LoRaWAN payload in Cayenne LPP format
- Check for downlink message
- Enter sleep mode (raise the Done pin of the TPL5110)
The code relies on the following hardware:
- Arduino MKR WAN 1300 -- Firmware 1.1.7 or newer
- TPL5110 breakout
- FRAM breakout
- Sensors, sample code provided for
- Battery voltage (using the built-in divider)
- Maxim DS18B20 temperature sensor (One Wire)
- Bosch BME280 temperature humidity pressure sensor
- Optional
- SH1106 128X64 I2C display for debugging
- Button to force reset (OTAA join) at boot time
Any similar hardware should work, but might need some code change.
The Arduino IDE with following libraries (all available from the Arduino Library Manager):
- Arduino MKRWAN version 1.1.7 or newer
- Adafruit FRAM (SPI version)
- TheThingsNetwork version 2.5.13 or newer (not 2.5.12!)
- For the BME280 sensor
- For the Maxim DS18B20 sensor
- For the optional display: U8g2
Sample setup with an SH1106 OLED display and a DS18B20 sensor:
- Copy
arduino_secrets_distr.h
toarduino_secrets.h
and enter your keys obtained from TheThingsNetwork console - In
TTNMkrWanNode
uncomment the defines for your sensors.
The Voltage sensor is always available, it uses the built-in divider. Note that givent the fact that the divider is 1/3rd and the voltage reference is 1.0v, the maximum you can measure is 3.0v... - In
debug.h
choose your debugging option:#define DEBUG
commented out: no debug code generated#define DEBUG
uncommented: debug on the (USB) serial console. The node will wait for the console!#define DEBUG
and#define OLED
uncommented: debug messages on the OLED display.
- In
ttn.h
you can set your LoRaWan default port and data rate
Disconnect power coming from the TPL5110 (DRV) when powering from USB.
If the FRAM does not contain valid data or if the button is pressed when the MKR WAN 1300 starts, the device will perform an OTAA join.
Before sleeping the node will check for downlink message:
- 0x01: Reset. The node will perform an OTAA join during next cycle
- 0x02 0xpp: Set port. The node will use port
pp
when sending data - 0x03 0xdd: Set data rate. The node will use the requested data rate.
- When powered from USB, the node will idle for 5 minutes then reset itself
- When powered through the TPL5110 the sleep time is driven by a resistor (on the Adafruit breakout you can use the trimpot on the board)