Connecting to TTN (The Things Network) via Dragino LG01-P Gateway and Arduino Uno + LoRa Shield sensor device. Presentation at TTN Dallas on April 17, 2019.
1. You’ve got mail.
Connecting to The Things Network (Public LoRaWan)
The Things Networks Dallas – April 17, 2019
2. Need notification on mailbox door open
https://www.amazon.com/Kangaroo-Home-Security-Motion-Sensor/dp/B07DHXB6XV/
The Good:
• 2AA batteries
• Robust, easy to install
• Wide sensor angle, good sensitivity
3. Notification not working + other issues...
● Kangaroo is meant for indoor use
● Weak device WiFi, does not reach far beyond front door
● Data cannot be exported, or IFTTT-ed, or scraped…
● The Call911 button issue - does it instantly dial 911?
⇒ Perfect opportunity for a LoRaWan/TTN application
4. Demo Outline
1. Dragino gateway intro
○ Installation and configuration
○ Packet forwarders
2. Arduino + LoRa Shield sends data to TTN
○ Message tracking on device Serial interface
○ Check settings and messages on TTN gateway, application, device
3. Cayenne (MyDevices) integration
○ LPP (Low Power Payloads) data types
○ Live data and Dashboard
5. ● Managed by Web GUI, SSH via LAN or WiFi
● Supports WiFi AP, Client or Ad-Hoc(Mesh) mode
● Internet connection via LAN, WiFi, 3G or 4G
● Failsafe design provides robust system
● Arduino IDE compatible. Easy to program.
● LoRa band available at 433/868/915/920 Mhz
● Max range in LoRa : 5 ~ 10km
Low cost comes with limitations:
● 1-channel gateway
● ABP only mode
Gateway: Dragino LG01-P-915-US ($60)
https://www.robotshop.com/en/lg01-p-lora-gateway-915-mhz-north-america.html
6. End device: Arduino Uno + LoRa Shield ($27.99)
Dragino Lora Shield 915Mhz, RFM95W Wireless, Compatible with Arduino UNO
Mega 2560 Leonardo Due, 3.3V or 5V Low Power Consumption, Antenna IPEX
https://www.amazon.com/gp/product/B07HD1MH3J/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1
7. The Demo setup (detail)
Mobile hotspot and TP-Link router make the setup venue independent
● Need Dragino connected to WAN Internet (Ethernet) so I can connect to it WiFi from laptop
● Dragino WiFi access needed to check LoRa radio on Arduino module
TP-Link TL-WR802N Wireless-N300 Nano Router
https://www.amazon.com/TP-Link-Wireless-Portable-Travel-Router/dp/B00TQEX8BO
USB
Assume no Ethernet at Improving
8. The Demo setup (will draw if I have time)
Items in red added for venue-independent Demo setup.
● Dragino WAN (Ethernet) to Cloud
● Dragino LAN (Ethernet) to Laptop (has Internet access)
● Laptop WiFi to Dragino to connect LoRa radio on Arduino
● Laptop USB to Arduino + LoRa Shield device - to track on Arduino
10. 1. Laptop
○ Arduino sketches for Client and Server
○ CMD ipconfig
2. Dragino http://10.130.1.1
3. TP-Link http://tplinkwifi.net/
4. Mobile hotspot
5. TTN
○ Gateways https://console.thethingsnetwork.org/gateways
○ TTN Applications https://console.thethingsnetwork.org/applications
6. Cayenne (myDevices) https://cayenne.mydevices.com/cayenne/dashboard
The Demo setup
11. The Demo setup - TP-Link nano router
WiFi Client Configuration setup
● WiFi SSID / password: TP-LINK_AE82 / *******
● Web management page: http://tplinkwifi.net/
● Default login: admin / admin
Notes:
1. There will be no Internet connection, AP opens and serves for TP-Link
configuration only, to connect it to the local WiFi
2. If needed, Reset to factory default: 5 sec pin push, until fast blinking
12. The Demo setup - TP-Link nano router (cont.)
Quick Setup > Client > select from AP List my cell phone hotspot SSID
17. Dragino LG01-P-915-US
LG01 LoRa Gateway User Manual
https://www.robotshop.com/media/files/pdf2/lg01_lora_gateway_user_manual.pdf
2.2 Program microcontroller.
The MCU (microcontroller) M328P is used to communicate with LoRa Radio part and Dragino Linux module.
The program language for the MCU is based on C and program tool is Arduino IDE.
Dragino board library:
http://www.dragino.com/downloads/downloads/YunShield/package_dragino_yun_test_index.json
2.3.1 Installing LoRa Library
The Library used here for LoRa communication is called Radiohead; our sketch will use this library
so we need to download it from:
https://github.com/dragino/RadioHead/archive/master.zip
Detailed, good
instructions
18. LG01 LoRa Gateway User Manual
https://www.robotshop.com/media/files/pdf2/lg01_lora_gateway_user_manual.pdf
Gateway settings Dragino LG01-P-915-US
● 10.130.1.1
● root/ dragino
Detailed, good
instructions
19. LG01 LoRa Gateway User Manual
https://www.robotshop.com/media/files/pdf2/lg01_lora_gateway_user_manual.pdf
Gateway settings Dragino - Network
Detailed, good
instructions
20. LG01 LoRa Gateway User Manual
https://www.robotshop.com/media/files/pdf2/lg01_lora_gateway_user_manual.pdf
Gateway settings Dragino - Sensor
Detailed, good
instructions
Single_pkt_fwd source code: https://github.com/dragino/Arduino-Profile-
Examples/tree/master/libraries/Dragino/examples/LoRa/LoRaWAN
21. LG01 LoRa Gateway User Manual
https://www.robotshop.com/media/files/pdf2/lg01_lora_gateway_user_manual.pdf
Gateway settings Dragino - LoRa/LoRaWan
Detailed, good
instructions
22. Step-by-step: Connect to TTN
Detailed instructions, for both Dragino and Arduino device at:
http://wiki.dragino.com/index.php?title=Connect_to_TTN#Use_LoRa_Shield_and_Arduino_as_LoRa_End_Device
Detailed, good
instructions
24. Example1 -- Use with LMIC library for LoRaWAN compatible
http://wiki.dragino.com/index.php?title=Lora_Shield#Example1_--_Use_with_LMIC_library_for_LoRaWAN_compatible
25. Arduino-lmic-master > src > lmic > lorabase.h
Default frequency plan for US 915 MHz ISM band
// Default frequency plan for US 915MHz
enum { US915_125kHz_UPFBASE = 902300000,
US915_125kHz_UPFSTEP = 200000,
US915_500kHz_UPFBASE = 903000000,
US915_500kHz_UPFSTEP = 1600000,
US915_500kHz_DNFBASE = 923300000,
US915_500kHz_DNFSTEP = 600000
};
enum { US915_FREQ_MIN = 902000000,
US915_FREQ_MAX = 928000000 };
26. The Library used by Dragino for LoRa communication is
called Radiohead, download it from:
https://github.com/dragino/RadioHead/archive/master.zip
Arduino Client setup
42. LoRa Questions
LoRa Questions answered on Dragino WiKi page:
http://wiki.dragino.com/index.php?title=LoRa_Questions#What_is_the_difference_between_LG01_single_channel_gateway
_and_a_8-channel_LoRaWAN_gateway.3F
● How can i change the Bandwidth of the LoRa Radio
● What is the difference between LG01 single channel gateway and a 8-channel LoRaWAN gateway?
● Can Dragino devices communicate with LoRa Devices from other vendor?
● How many LoRa client node can LG01/OLG01 support?
43. ● 600 ft (200 m) radius?
● Max range in LoRa : 5 ~ 10 km
Dragino LG01-P and Arduino w. LoRa Shield reach
44. The Faraday cage
A Faraday cage or Faraday shield is an enclosure used to block electromagnetic fields.
A Faraday shield may be formed by a continuous covering of conductive material, or
in the case of a Faraday cage, by a mesh of such materials. Faraday cages are named
after the English scientist Michael Faraday, who invented them in 1836.
Block BT beaconsFaraday cage
45. A metal mailbox blocks all EMF
● Signals emitted in closed box are not detected
● Short and narrow window to detect mailbox opened, mail placed, mailbox closed
● Need to check sensor every few seconds
https://www.youtube.com/watch?v=WgAFBP2loo8
April 16, 11:45 am
46. Application frame counters
LoRaWan Security
https://www.thethingsnetwork.org/docs/lorawan/security.html
Frame counters used to block replay attacks.
47. TTN Learn - devices; duty cycle; frequency plans
https://www.thethingsnetwork.org/docs/devices/
https://www.thethingsnetwork.org/docs/lorawan/duty-cycle.html
● Duty Cycle indicates the fraction of time a resource is busy.
● When a single device transmits on a channel for 2 time units
every 10 time units, this device has a duty cycle of 20%.
● In most regions this duty cycle is set to 1%.
https://www.thethingsnetwork.org/docs/lorawan/frequency-plans.html
49. Gateway: Dragino LG01-P-915-US
LG01 LoRa Gateway User Manual
https://www.robotshop.com/media/files/pdf2/lg01_lora_gateway_user_manual.pdf
2.2 Program microcontroller.
The MCU (microcontroller) M328P is used to communicate with LoRa Radio part and Dragino Linux module.
The program language for the MCU is based on C and program tool is Arduino IDE.