Two way data over LoRaWAN using Multitech mDot
This is example firmware for the Multitech mDot. It demonstrates how to:
- Do two-way data.
- Sleep aggressively and only wake up when the wake-up pin is triggered.
- Handle errors, retries and duty cycle errors.
- Cache data in non-volatile storage.
Based on mbed OS 5.1, hard faults against mbed OS 5.3 unfortunately. Can be compiled with GCC and ARMCC (but not IAR).
To do a new transmission, short pin D6 / PA_1.
Diff: README.md
- Revision:
- 0:20fbd6f66b11
- Child:
- 1:b604a2d6c54d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Tue Jan 03 13:20:36 2017 +0000 @@ -0,0 +1,52 @@ +# LoRa Soap dispenser + +Smart soap dispenser that sends out stuff over LoRa. Does not build with GCC, only ARMCC (also with mbed CLI). + +## Setup + +1. Set jumper JP95 (next to RESET button) to the two pins closest to the mDot. +2. Attach something that generates an interrupt on D6 / PA_1. +3. RFID code needs to be implemented, currently spits out a random ID. + +To get data into Device Connector: + +1. First get keys by exchanging a device cert for LoRa keys at http://apm-lora-eu2.cloudapp.net:5101. +2. Add the keys to ``main.cpp``. +3. Then under 'Resources' add: + + ``` + { + "dispenser/0/value": { + "mode": "r", + "defaultValue": "0" + }, + "meta/0/timestamp": { + "mode": "r", + "defaultValue": "" + }, + "meta/0/ids_seen": { + "mode": "r", + "defaultValue": "" + } + } + ``` + +4. Under 'Process Data' add: + + ```js + function (bytes) { + var ids = []; + for (var i = 0; i < (bytes.length - 2) / 4; i++) { + var c = bytes.slice(2 + (i * 4), 2 + (i * 4) + 4); + ids.push((c[0] << 24) + (c[1] << 16) + (c[2] << 8) + (c[3])); + } + + return { + "dispenser/0/value": (bytes[0] << 8) + bytes[1], + "meta/0/timestamp": new Date().toISOString(), + "meta/0/ids_seen": ids.join(',') + }; + } + ``` + +5. Click 'Save' and your data should show up in Device Connector (after the next transmission).