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.
README.md@0:20fbd6f66b11, 2017-01-03 (annotated)
- Committer:
- janjongboom
- Date:
- Tue Jan 03 13:20:36 2017 +0000
- Revision:
- 0:20fbd6f66b11
- Child:
- 1:b604a2d6c54d
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
janjongboom | 0:20fbd6f66b11 | 1 | # LoRa Soap dispenser |
janjongboom | 0:20fbd6f66b11 | 2 | |
janjongboom | 0:20fbd6f66b11 | 3 | Smart soap dispenser that sends out stuff over LoRa. Does not build with GCC, only ARMCC (also with mbed CLI). |
janjongboom | 0:20fbd6f66b11 | 4 | |
janjongboom | 0:20fbd6f66b11 | 5 | ## Setup |
janjongboom | 0:20fbd6f66b11 | 6 | |
janjongboom | 0:20fbd6f66b11 | 7 | 1. Set jumper JP95 (next to RESET button) to the two pins closest to the mDot. |
janjongboom | 0:20fbd6f66b11 | 8 | 2. Attach something that generates an interrupt on D6 / PA_1. |
janjongboom | 0:20fbd6f66b11 | 9 | 3. RFID code needs to be implemented, currently spits out a random ID. |
janjongboom | 0:20fbd6f66b11 | 10 | |
janjongboom | 0:20fbd6f66b11 | 11 | To get data into Device Connector: |
janjongboom | 0:20fbd6f66b11 | 12 | |
janjongboom | 0:20fbd6f66b11 | 13 | 1. First get keys by exchanging a device cert for LoRa keys at http://apm-lora-eu2.cloudapp.net:5101. |
janjongboom | 0:20fbd6f66b11 | 14 | 2. Add the keys to ``main.cpp``. |
janjongboom | 0:20fbd6f66b11 | 15 | 3. Then under 'Resources' add: |
janjongboom | 0:20fbd6f66b11 | 16 | |
janjongboom | 0:20fbd6f66b11 | 17 | ``` |
janjongboom | 0:20fbd6f66b11 | 18 | { |
janjongboom | 0:20fbd6f66b11 | 19 | "dispenser/0/value": { |
janjongboom | 0:20fbd6f66b11 | 20 | "mode": "r", |
janjongboom | 0:20fbd6f66b11 | 21 | "defaultValue": "0" |
janjongboom | 0:20fbd6f66b11 | 22 | }, |
janjongboom | 0:20fbd6f66b11 | 23 | "meta/0/timestamp": { |
janjongboom | 0:20fbd6f66b11 | 24 | "mode": "r", |
janjongboom | 0:20fbd6f66b11 | 25 | "defaultValue": "" |
janjongboom | 0:20fbd6f66b11 | 26 | }, |
janjongboom | 0:20fbd6f66b11 | 27 | "meta/0/ids_seen": { |
janjongboom | 0:20fbd6f66b11 | 28 | "mode": "r", |
janjongboom | 0:20fbd6f66b11 | 29 | "defaultValue": "" |
janjongboom | 0:20fbd6f66b11 | 30 | } |
janjongboom | 0:20fbd6f66b11 | 31 | } |
janjongboom | 0:20fbd6f66b11 | 32 | ``` |
janjongboom | 0:20fbd6f66b11 | 33 | |
janjongboom | 0:20fbd6f66b11 | 34 | 4. Under 'Process Data' add: |
janjongboom | 0:20fbd6f66b11 | 35 | |
janjongboom | 0:20fbd6f66b11 | 36 | ```js |
janjongboom | 0:20fbd6f66b11 | 37 | function (bytes) { |
janjongboom | 0:20fbd6f66b11 | 38 | var ids = []; |
janjongboom | 0:20fbd6f66b11 | 39 | for (var i = 0; i < (bytes.length - 2) / 4; i++) { |
janjongboom | 0:20fbd6f66b11 | 40 | var c = bytes.slice(2 + (i * 4), 2 + (i * 4) + 4); |
janjongboom | 0:20fbd6f66b11 | 41 | ids.push((c[0] << 24) + (c[1] << 16) + (c[2] << 8) + (c[3])); |
janjongboom | 0:20fbd6f66b11 | 42 | } |
janjongboom | 0:20fbd6f66b11 | 43 | |
janjongboom | 0:20fbd6f66b11 | 44 | return { |
janjongboom | 0:20fbd6f66b11 | 45 | "dispenser/0/value": (bytes[0] << 8) + bytes[1], |
janjongboom | 0:20fbd6f66b11 | 46 | "meta/0/timestamp": new Date().toISOString(), |
janjongboom | 0:20fbd6f66b11 | 47 | "meta/0/ids_seen": ids.join(',') |
janjongboom | 0:20fbd6f66b11 | 48 | }; |
janjongboom | 0:20fbd6f66b11 | 49 | } |
janjongboom | 0:20fbd6f66b11 | 50 | ``` |
janjongboom | 0:20fbd6f66b11 | 51 | |
janjongboom | 0:20fbd6f66b11 | 52 | 5. Click 'Save' and your data should show up in Device Connector (after the next transmission). |