© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 1
22080 IoT2Connecting your IoT Device with LoRaWAN™ to The Things NetworkA Global IoT Data Network
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 2
Class Objectives
When you walk out of this class you will be able to…• Explain how a global LoRaWAN™
network like The Things Network works.• Create a full IoT ecosystem by sending
data through the entire IoT data path• IoT device Gateway Network Server User Application
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 3
Agenda• What is LoRa® and LoRaWAN™• Microchip’s LoRa® and LoRaWAN™ Solutions• IoT Sensor: The SODAQ ExpLoRer
• Lab 1 – Pass Through Demo• IoT Gateway: A LoRaWAN™ Gateway• Network Server: The Things Network (TTN)
• Lab 2 – Setup TTN Account and Application• Connecting your Sensor to TTN
• Lab 3 – Connect ExpLoRer to TTN• User Application: Node-RED
• Lab 4 – Node-RED Application• Summary
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 4
Agenda
LoRaWAN™ Servers
Part 2:IoT Gateway
Part 3:Network Servers
Labs 2 & 3:Getting Data from
IoT Device to Server
Part 4:User Apps
Lab 4:Creating a User App
The IoT with LoRaWAN™
Part 1:IoT Sensor
Lab 1:RN2903
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 5
Agenda
LoRaWAN™ Servers
Part 2:IoT Gateway
Part 3:Network Servers
Labs 2 & 3:Getting Data from
IoT Device to Server
Part 4:User Apps
Lab 4:Creating a User App
The IoT with LoRaWAN™
Part 1:IoT Sensor
Lab 1:RN2903
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 6
Agenda
LoRaWAN™ Servers
Part 2:IoT Gateway
Part 3:Network Servers
Labs 2 & 3:Getting Data from
IoT Device to Server
Part 4:User Apps
Lab 4:Creating a User App
The IoT with LoRaWAN™
Part 1:IoT Sensor
Lab 1:RN2903
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 7
Agenda
LoRaWAN™ Servers
Part 2:IoT Gateway
Part 3:Network Servers
Labs 2 & 3:Getting Data from
IoT Device to Server
Part 4:User Apps
Lab 4:Creating a User App
The IoT with LoRaWAN™
Part 1:IoT Sensor
Lab 1:RN2903
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 8
Agenda• What is LoRa® and LoRaWAN™• Microchip’s LoRa® and LoRaWAN™ Solutions• IoT Sensor: The SODAQ ExpLoRer
• Lab 1 – Pass Through Demo• IoT Gateway: A LoRaWAN™ Gateway• Network Server: The Things Network (TTN)
• Lab 2 – Setup TTN Account and Application• Connecting your Sensor to TTN
• Lab 3 – Connect ExpLoRer to TTN• User Application: Node-RED
• Lab 4 – Node-RED Application• Summary
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 9
What is LoRa® and LoRaWAN™ - Agenda -
• Overview• LoRa® Technology Modulation & Data Rate• Adaptive Data Rate (ADR)• LoRaWAN™ Network Protocol & Components• End-Device Classes• End-Device Activation and Security• End-Device Data Communication (Class A)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 10
What is LoRa® and LoRaWAN™ - Agenda -
• Overview• LoRa® Technology Modulation & Data Rate• Adaptive Data Rate (ADR)• LoRaWAN™ Network Protocol & Components• End-Device Classes• End-Device Activation and Security• End-Device Data Communication (Class A)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 11
What is LoRa® Technology?
• A combination of two major concepts:• LoRa® spread spectrum modulation (The “PHY” layer)
• Provides the core long range capabilityUp to 5km range in urban environment, up to 15km suburban
• Developed by Semtech, built in to SX127x transceiver ICs• SX1301 gateway baseband chip allows multiple receive
channels• LoRaWAN™ network protocol
• Provides a cellular-like network (aka large-star topology)• Defined by IBM & Actility, made open by the LoRaTM Alliance
• https://lora-alliance.org/resource-hub/lorawantm-specification-v11
• Microchip developed/owns/maintains a LoRaWAN stack for our modules.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 12
LoRa® Technology Benefits
Key Features Customer Benefit
168dBm link budget (-148dBm sensitivity, +20dBm Tx @ 900MHz) Longest range
Jamming resistant – tolerant to burst interference
Robust links and network efficiency>100dB blocking
Multiple Nodes on same channel
Insensitive to XTAL offsets (no TCXO)
Lower system costLong Range - Eliminates need for repeaters
10mA RX current, uA sleep current Extended battery lifetime
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 13
What is LoRa® and LoRaWAN™ - Agenda -
• Overview• LoRa® Technology Modulation & Data Rate• Adaptive Data Rate (ADR)• LoRaWAN™ Network Protocol & Components• End-Device Classes• End-Device Activation and Security• End-Device Data Communication (Class A)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 14
• Proprietary Spread Spectrum Technology• Developed by Semtech Corporation (http://www.semtech.com/)• Chirped-FM• Processing gain = increased receive sensitivity• Enables longer range at expense of lower data rate
LoRa® Technology Modulation
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 15
• Spreading Factor (SF)• Programmable SF:
7, 8, 9, 10, 11, 12• The higher the SF the more information transmitted per bit;
therefore higher processing gain• Bandwidth (BW)
• Programmable signal BW settings:125 kHz, 250 kHz, 500 kHz
• For a given SF, a narrower BW = increased receive sensitivity; however, increased time on air
• Forward Error Correction (FEC) Code Rate (CR)• Additional coding rate provides more redundancy to detect errors
and correct them
• Great info @ https://youtu.be/T3dGLqZrjIQ?t=2122
LoRa® Technology Modulation
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 16
• License free Sub-GHz Frequencies• North America: 915 MHz Band• Upstream: 64-125kHz channels numbered 0 to 63
• Data Rates: DR0 to DR3• Upstream: 8-500kHz channels numbered 64 to 71
• Data Rates: DR4• Downstream: 8-500kHz channels numbered 0 to 7
• Data Rates: DR8 to DR13
LoRaWAN™ North American Channels
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 17
LoRaWAN™ Modulation Settings for North America
10 9 8 7 8
0 1 2 3 4
Range
Bitrate (BR) (bps)
Spreading Factor (SF)
Data Rate (DR)
125125
125125
500 Bandwidth (BW) (kHz)
9761757
3125
5468
12500
LoRa® Modulation
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 18
Data Rate (DR) vs. Bit Rate vs. Payload Size – North America
• (Uplink) DR set via pair [SF,BW]• Can be 0, 1, 2, 3, 4 for North America
• Bit rate is restricted by uplink transmission dwell time specification• 400mS for North America (per FCC
Regulation)• Application Payload Length is also
restricted by the max. dwell time
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 19
Data Rate (DR) vs. Bit Rate vs. Payload Size – North America(Uplink)
DR ConfigurationApprox. Bit
Rate [bit/sec]Max. Payload
[bytes]
0 SF10 / 125kHz 980 11
1 SF9 / 125kHz 1760 53
2 SF8 / 125kHz 3125 125
3 SF7 / 125kHz 5470 242
4 SF8 / 500 kHz 12500 242
See Tables 11 and 14 in “LoRaWAN-Regional-Parameters-v1.1rA”
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 20
• For Longest Distance:• Data Rate (DR) = 0
• LoRa® modulation• Spreading Factor (SF) = SF10• Bandwidth (BW) = 125 kHz• Coding Rate (CR) = 4/5
• Bit Rate = 976 bps• Max Application Payload Size = 11 bytes
• Time On Air = 371 ms
Modulation Settings ExampleFor North America
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 21
• For Highest Bit Rate:• Data Rate (DR) = 4
• LoRa® modulation• Spreading Factor (SF) = SF8• Bandwidth (BW) = 500 kHz• Coding Rate (CR) = 4/5
• Bit Rate = 12500 bps• Max Application Payload Size = 242 bytes
• Time On Air = 175 ms
Modulation Settings Example for North America
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 22
What is LoRa® and LoRaWAN™ - Agenda -
• Overview• LoRa® Technology Modulation & Data Rate• Adaptive Data Rate (ADR)• LoRaWAN™ Network Protocol & Components• End-Device Classes• End-Device Activation and Security• End-Device Data Communication (Class A)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 23
Adaptive Data Rate (ADR)
• LoRaWAN™ Network can manage• data rate and • RF power output
• For each end-device to • Optimize for fastest data rate,• Maximize battery life, and • Maximize network capacity
• Based on RSSI, SNR as reported by the gateway
• Nodes decide if ADR is used or not
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 24
DR (therefore Max. Packet Length Allowed) can change dynamically!
• Via LoRaWAN™ Network ADR protocol• Increases DR to minimize on-air time• Based on RSSI, SNR as reported by the
gateway• Via RN2903 retransmit mechanism
• Decreases DR to increase transmitted energy per bit • Applied for “confirmed-data” messages only
• Can invalidate your packet size selection
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 25
LoRaWAN™ Modulation & DR Settings- Best Practices -
• Keep messages short (< 11 bytes)• Binary messages rather than ASCII• Only use “confirmed-data”
transmissions for critical messages• Reduces network loading• Many Gateway radios are not full-duplex
• Not able to receive transmissions from nodes while it is transmitting
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 26
What is LoRa® and LoRaWAN™ - Agenda -
• Overview• LoRa® Technology Modulation & Data Rate• Adaptive Data Rate (ADR)• LoRaWAN™ Network Protocol & Components• End-Device Classes• End-Device Activation and Security• End-Device Data Communication (Class A)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 27
Physical Topology
IP IP
Gateways Network Server
Application Servers
Sub-GHz RF
End-Devices
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 28
End-Device
• The “Thing” in IoT• Single-hop wireless communication to one or many
Gateway(s).
Sensors
Host MCU
App
licat
ion
Actuators UART
LoR
aWA
N P
roto
col
Wireless Module
Rad
io T
rans
ceiv
er
Inte
rnet
Pro
toco
l
Rad
io T
rans
ceiv
er
RN2xx3
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 29
• LoRaWAN™ RF Network to LoRaWAN™ Backend Services• Data is “passed through” to Servers• Connected to Network Server via standard IP connection.• Listens to multiple channels at the same time
Gateway
IPIn
tern
et P
roto
col
Rad
io T
rans
ceiv
er
Inte
rnet
Pro
toco
l
Net
wor
k Se
rver
Rad
io T
rans
ceiv
er
Bas
eban
d Pr
oces
sor
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 30
Inte
rnet
Pro
toco
l
App
licat
ion
Serv
er
Network Server
Inte
rnet
Pro
toco
l
Net
wor
k Se
rver
IPIP
Inte
rnet
Pro
toco
l
Rad
io T
rans
ceiv
er• Network Server authenticates data• If data is addressed to Network Server, data is processed• Else data will be forwarded to Application Server• Connected to the Application Server via standard IP
connection.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 31
Application Server
• Consumer of data• Application Server decrypts data• Multiple Application Servers can exist within the same
LoRaWAN™ Network
Inte
rnet
Pro
toco
l
App
licat
ion
Serv
erIP
Inte
rnet
Pro
toco
l
Net
wor
k Se
rver
Example: Each Application Server handles specific type of data
Electric Meter
Vending Machine
Smoke alarms
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 32
Logical Data Flow- Programmers Model -
End-DevicesGateway Network
ServerApplication
Server
IP IP
End-device to/from Application ServerData Data
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 33
What is LoRa® and LoRaWAN™ - Agenda -
• Overview• LoRa® Technology Modulation & Data Rate• Adaptive Data Rate (ADR)• LoRaWAN™ Network Protocol & Components• End-Device Classes• End-Device Activation and Security• End-Device Data Communication (Class A)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 34
• Each end-device class has different behavior depending on the choice of optimization:• Battery Powered – Class A• Low Latency – Class B• No Latency – Class C
End-Device Classes
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 35
• Battery Powered – Class A• Bidirectional communications• Unicast messages• Small payloads• Long intervals• End-device initiates communication (uplink)• Server communicates with end-device (downlink) during
predetermined response windows:
Class A Devices
RX2RxDelay1
RxDelay2
Transmit RX1
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 36
• Battery Powered – Class A• Pros
• Lowest power consumption = longest battery life• Cons
• Long latency
• Examples• Battery powered sensors
Class A (Pros/Cons)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 37
• Low Latency – Class B• Bidirectional with scheduled receive slots• Unicast and Multicast (Downlink) messages• Small payloads• Long intervals• Periodic beacon from gateway• Extra receive window (ping slot)• Server can initiate transmission at fixed intervals
Class B Devices
Ping SlotBeacon Period
RX2RxDelay1
RxDelay2
Transmit BCNBCN PNG RX1
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 38
• Low Latency – Class B• Pros
• Deterministic latency• Cons
• Higher power consumption
• Examples• Battery powered actuator end-device
Class B (Pros/Cons)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 39
Class C Devices
• No Latency – Class C• Bidirectional communications• Unicast and Multicast (Downlink) messages• Small payloads• Server can initiate transmission at any time• End-device is constantly receiving
RX1 RX2
RxDelay1RxDelay2
Transmit RX2
Extends RX2 until next TX
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 40
• No Latency – Class C• Pros
• Lowest receive latency• End-device has continuous receive window
• Cons• Highest power consumption
(expect end-device to be mains powered)
• Examples• Mains-powered, low-latency actuator (end-device)
Class C (Pros/Cons)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 41
What is LoRa® and LoRaWAN™ - Agenda -
• Overview• LoRa® Technology Modulation & Data Rate• Adaptive Data Rate (ADR)• LoRaWAN™ Network Protocol & Components• End-Device Classes• End-Device Activation and Security• End-Device Data Communication (Class A)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 42
Message Security Overview
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 43
• Before an end-device can communicate on the LoRaWAN™ network, it must be activated
• The goal of the device activation process is to obtain:• Device Address (DevAddr)
• 32-bit unique (network-wide) identifier• Network Session Key (NwkSKey)
• Used by the Network Server to authenticate the device• Application Session Key (AppSKey)
• Used by the Application Server to decrypt application data
End-Device Activation(Joining the Network)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 44
Key Usage
End-DevicesGateway Network
ServerApplication
Server
Sub-GHz RF
IP IP
Network Session Key (NwkSKey)
Application Session Key (AppSKey)App
licat
ion
Application
Data Data
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 45
• To exchange this information, two activation methods are available:
Activation (Join) Methods
Activation By Personalization (ABP)
• Shared keys stored at production time
• Locked to a specific network
Over-the-Air Activation(OTAA)
• Based on Globally Unique Identifier
• Over the air message handshaking
• Supports Roaming
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 46
• Over-the-Air-Activation (OTAA)• End-device transmits Join Request to application
server containing:• Globally unique end-device identifier (DevEUI)• Application identifier (AppEUI)• Authentication with Application key (AppKey)
• End-device receives Join Accept from application server
(continued…)
OTAA Procedure
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 47
• Over-the-Air-Activation (OTAA)• End-device authenticates Join Accept • End-device decrypts Join Accept• End-device extracts and stores Device Address
(DevAddr)• End-device derives:
• Network Session Key (NwkSKey)• Application Session Key (AppSKey)
OTAA Procedure (Continued)
SecurityKeys
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 48
What is LoRa® and LoRaWAN™ - Agenda -
• Overview• LoRa® Technology Modulation & Data Rate• Adaptive Data Rate (ADR)• LoRaWAN™ Network Protocol & Components• End-Device Classes• End-Device Activation and Security• End-Device Data Communication (Class A)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 49
• Uplink Message• End-Device to Network Server relayed by one or
many Gateways
End-Device Data Communications (Class A)
Gateways Network Server
Application Servers
Sub-GHz RF
End-Devices
IP IP
Uplink
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 50
• Downlink Message• Sent by the Network Server to only one End-Device
and is relayed by a single Gateway
End-Device Data Communications (Class A)
Gateways Network Server
Application Servers
Sub-GHz RF
End-Devices
IP IP
Downlink
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 51
End-Device Data Message does not require an acknowledgement from the
Application Server
Let’s look at an example…
End-Device Data Communications (Class A)
“Unconfirmed-Data” Message
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 52
Unconfirmed-Data Message
Gateways Network Server
Application Servers
1. Electric meter transmits data
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 53
Gateways Network Server
Application Servers
Unconfirmed-Data Message
2. Gateway receives data and passes to Network Server
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 54
Gateways Network Server
Application Servers
Unconfirmed-Data Message
3. The Network Server authenticates data and passes it to Electric Meter Application Server
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 55
Gateways Network Server
Application Servers
Unconfirmed-Data Message
4. Electric Meter Application Server decrypts data
Data
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 56
End-Device Data Message has to be acknowledged by the Application Server
Let’s look at an example…
End-Device Data Communications (Class A)
“Confirmed-Data” Message
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 57
Gateways Network Server
Application Servers
Confirmed-Data Message
1. Vending Machine transmits data. It is received by two Gateways.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 58
Gateways Network Server
Application Servers
Confirmed-Data Message
2. Both gateways “pass through” the data to the Network Server.
Data
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 59
Gateways Network Server
Application Servers
Confirmed-Data Message
3. The Network Server forwards the data to the Vending Machine Applications Server
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 60
Gateways Network Server
Application Servers
Confirmed-Data Message
4. The Vending Machine Applications Server sends an acknowledgement
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 61
Gateways Network Server
Application Servers
ACK
Confirmed-Data Message
5. The Network Server selects the best path (gateway) to transmit the acknowledgement to the end-device.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 62
Gateways Network Server
Application Servers
Confirmed-Data Message
6. The Gateway transmits the acknowledgement to the end-device
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 63
If the Application Server has a Data Message for the End-Device…… the Application Server has to wait until the
End-Device initiates a transmission.
Let’s look at an example…
End-Device Data Communications (Class A)
Application Server Data Message
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 64
Gateways Network Server
Application Servers
Application Server Data Message
Data
1. The Smoke Detector Application Server has Data for the highlighted Smoke Detector
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 65
Gateways Network Server
Application Servers
Application Server Data Message
Zzz…
2. However, it has to wait until the Smoke Detector wakes up and transmits a Data Message
Data
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 66
Gateways Network Server
Application Servers
Application Server Data Message
3. When the Smoke Detect transmits, the Data Message moves Upstream
Data
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 67
Gateways Network Server
Application Servers
Application Server Data Message
4. Passed through the Gateway…
Data
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 68
Gateways Network Server
Application Servers
Application Server Data Message
5. … and the Network Server sends to the Smoke Detector Application Server.
DataData
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 69
Gateways Network Server
Application Servers
Application Server Data Message
6. The Smoke Detector Application Server can now send the data message to the Smoke Detector.
Data
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 70
Gateways Network Server
Application Servers
Application Server Data Message
7. The Network Server sends the Data Message to the appropriate Gateway.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 71
Gateways Network Server
Application Servers
Application Server Data Message
8. The Data Message is transmitted to the Smoke Detector during one of the two Receive Windows.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 72
Agenda• What is LoRa® and LoRaWAN™• Microchip’s LoRa® and LoRaWAN™ Solutions• IoT Sensor: The SODAQ ExpLoRer
• Lab 1 – Pass Through Demo• IoT Gateway: A LoRaWAN™ Gateway• Network Server: The Things Network (TTN)
• Lab 2 – Setup TTN Account and Application• Connecting your Sensor to TTN
• Lab 3 – Connect ExpLoRer to TTN• User Application: Node-RED
• Lab 4 – Node-RED Application• Summary
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 73
LoRa® Technology Wireless Modules
• RN2483A LoRa® Technology Transceiver Module• European (EU) 868/433 MHz• R&TTE Directive Assessed Radio Module• TX Power: up to +14 dBm• Power Consumption: 1.6 uA in Sleep
• RN2903A LoRa® Technology Transceiver Module• North American (NA) 915 MHz• FCC and IC modular certification• TX Power: up to +20 dBm• Power Consumption: 2.2 uA in Sleep
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 74
Introducing RN2903AFCC LoRaWAN™ Modem
Key Features• LoRaWANv1.0 Class-A “Golden Unit” Stack• 915MHz, external antenna• Integrated filtering and matching circuits• I/O Expansion: 6x analog, 6x digital, UART, I2C• Compact size: 27 x 18 x 3.2 mm• FCC Modular Certification
Complete Solution!• Integrates LoRa® Radio, PIC MCU &
LoRaWAN Stack• Pre-tested against all major
LoRaWAN gateways & servers• Simple ASCII Command Set• Optimized for Embedded Designs• Quick Time-to-Market
Development Tools• PICtail™ boards for Microchip
MCU kits • Mote for portable testing• Both support USB Interface• Demo Code available
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 75
3rd Party ToolsBased on Microchip RN2XX3
• Arduino Base
• LoRaONE prototype
• Click Board
• Arduino Shield
Marvin
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 76
LoRa® Technology Wireless ModulesBlock Diagram
LoRa® TechnologyRadio Transceiver
I2C Real Time Clock SPI
LoRaWAN™ Protocol StackGPIO
14
Status LEDs,switches,
logic IOs, etc.External Antenna(s)
Command Interface
UARTMCU
32768 HzCrystal
EUI-64EEPROM
Host MCURN2483 / RN2903
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 77
LoRa® Technology Wireless Modules
RFH
RXTX
RTSCTS
UART GPIOs
Status LEDs,switches,logic IOs,
etc.
Host MCU
TXRX
CTSRTS
Notes:Default Baud Rate: 57600, 8N1, no flow control
915 MHz
RN2903 LoRa® Technology Transceiver Module
RN2903VDDGNDRESET
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 78
• Command Syntax• Keyword(s) issued, followed by optional parameter(s)• Separated by space Character
• Beware of extra white space characters• Keyword(s) are Case Sensitive• Parameter(s) are Case Insensitive• CR+LF Command Delimiter
• Command Request example: < mac set devaddr 048E436e\r\n
• Command Reply example:> ok\r\n
LoRa® RN Modem API: Command Syntax Style
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 79
Command Interface
LoRaWAN™ Protocol
Radio Driver
Radio HardwareHardware (GPIO, System Timer, etc.)
mac
radio
sys
LoRa® RN Modem API: Command Structure
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 80
Command Interface
LoRaWAN™ Protocol
Radio Driver
Radio HardwareHardware (GPIO, System Timer, etc.)
mac
radio
sys
mac : Issues LoRaWAN™ Class A protocol network communication behaviors, actions and configurations commands
LoRa® RN Modem API: mac-Level Commands
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 81
mac : Issues LoRaWAN™ Class A protocol network communication behaviors, actions and configurations commands
LoRa® RN Modem API: mac-Level Commands
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 82
< mac set devaddr 048E436E> ok
< mac set nwkskey 2bb2fc45e4834954310402ae0c2084a0> ok
< mac set appskey d403a3aeda9f285864973ef6b45a54a0> ok
< mac join abp> ok> accepted
LoRa® RN Modem API: mac-Level Commands
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 83
Command Interface
LoRaWAN™ Protocol
Radio Driver
Radio HardwareHardware (GPIO, System Timer, etc.)
mac
radio
sys
radio : Issues radio specific configurations, directly accessing and updating the transceiver setup
LoRa® RN Modem API: radio-Level Commands
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 84
radio : Issues radio specific configurations, directly accessing and updating the transceiver setup
LoRa® RN Modem API: radio-Level Commands
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 85
< radio cw on> ok
< radio get mod> lora
LoRa® RN Modem API: radio-Level Commands
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 86
Command Interface
LoRaWAN™ Protocol
Radio Driver
Radio HardwareHardware (GPIO, System Timer, etc.)
mac
radio
sys
sys : Issues system level behavior actions, gathers status information on the firmware and hardware version, or accesses the module user EEPROM memory
LoRa® RN Modem API: sys-Level Commands
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 87
sys : Issues system level behavior actions, gathers status information on the firmware and hardware version, or accesses the module user EEPROM memory
LoRa® RN Modem API: sys-Level Commands
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 88
< sys sleep 5000> ok
< sys reset> RN2903 0.9.5 Sep 02 2015 17:19:55
LoRa® RN Modem API: sys-Level Commands
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 89
LoRaWAN™ LibraryTTN’s “arduino-device-lib”
• The Things Network Device Library• Provides API to RN2xxx LoRaWAN
network commands• https://github.com/TheThingsNetwork/ard
uino-device-lib• Pre-installed in the student sketches
folder (\Sketches\Libraries\)• Although we will be using the TTN
network today, this library can also be used with other LoRaWAN networks.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 90
Agenda• What is LoRa® and LoRaWAN™• Microchip’s LoRa® and LoRaWAN™ Solutions• IoT Sensor: The SODAQ ExpLoRer
• Lab 1 – Pass Through Demo• IoT Gateway: A LoRaWAN™ Gateway• Network Server: The Things Network (TTN)
• Lab 2 – Setup TTN Account and Application• Connecting your Sensor to TTN
• Lab 3 – Connect ExpLoRer to TTN• User Application: Node-RED
• Lab 4 – Node-RED Application• Summary
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 91
Agenda
LoRaWAN™ Servers
Part 2:IoT Gateway
Part 3:Network Servers
Labs 2 & 3:Getting Data from
IoT Device to Server
Part 4:User Apps
Lab 4:Creating a User App
The IoT with LoRaWAN™
Part 1:IoT Sensor
Lab 1:RN2903
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 92
SODAQ ExpLoRer
Micro USB: Arduino®
IDE & charging
LiR2450rechargeable battery120mAh, 3.6V
RGB LED for statusIndication
RN4871 BT-Smart
Atmel SAM-D21Cortex® -M0+ based
microcontroller
RN2xx3 LoRaWAN™
Low-cost (removable)
PCB IFA antenna
Footprint for optional SMA
Standard headersfor feature expansion(sensors, GPS, solar)
ECC508A Crypto Device
MCP9700AT Temperature
Sensor
Blue LED
Push Button
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 93
Why Arduino??
• Open Source• Industry standard• Easily accessible
• Free IDEs• No flashing tools needed – only a USB cable• Simple structure (setup & loop) with examples
• Excellent HAL • Re-use projects across AVR, Cortex and other
cores• Hugely popular!• Beware of source code licenses!
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 94
Arduino® IDE and Sketch
setup()
loop()
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 95
COM Ports
• SODAQ ExpLoRer enumerates as one of 2 virtual COM ports
• One used for applications• One used for programming
(bootloader)• Board should automatically
re-enumerate between application-bootloader-application COM port during Upload procedure
• Can manually force bootloader mode by double-tapping on RESET 2x/sec
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 96
Lab 1Pass Through Demo
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 97
Lab 1 Objectives
• Run a simple “Pass Through” sketch• Verify your board’s basic functionality• Interact with RN2903 via its serial
command/control interface to• Verify the RN2903 firmware version• Collect the DevEUI of RN2903• Perform a factory reset
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 98
Lab 1 Summary
• An IoT device is often a simple sensor.• Arduino® is a quick way to prototype designs.• RN2903 implements a serial command/control
interface for LoRaWAN™ connectivity.• The “Pass Through” sketch allowed you to
• Experiment with the ASCII command interface of the RN2903 and perform a “factory reset” of all parameters.
• Collect the DevEUI from the RN2903 (this will be needed to provision your device onto the network)
• Display data in an Arduino debug terminal
• What you have so far:• IoT device Gateway Network Server User Application
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 99
Agenda• What is LoRa® and LoRaWAN™• Microchip’s LoRa® and LoRaWAN™ Solutions• IoT Sensor: The SODAQ ExpLoRer
• Lab 1 – Pass Through Demo• IoT Gateway: A LoRaWAN™ Gateway• Network Server: The Things Network (TTN)
• Lab 2 – Setup TTN Account and Application• Connecting your Sensor to TTN
• Lab 3 – Connect ExpLoRer to TTN• User Application: Node-RED
• Lab 4 – Node-RED Application• Summary
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 100
The Gateway
LoRaWAN™ Servers
Part 2:IoT Gateway
Part 3:Network Servers
Labs 2 & 3:Getting Data from
IoT Device to Server
Part 4:User Apps
Lab 4:Creating a User App
The IoT with LoRaWAN™
Part 1:IoT Sensor
Lab 1:RN2903
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 101
IoT Gateway: A LoRaWAN™ Gateway- Agenda -
• Overview• Typical Architecture• Gateway Options• Provisioning a Gateway
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 102
IoT Gateway: A LoRaWAN™ Gateway- Agenda -
• Overview• Typical Architecture• Gateway Options• Provisioning a Gateway
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 103
Overview
• Low-IQ Base station or LoRa® concentrator• Act as a protocol converter• Device that relays message between end-
devices and a network server• Can contain the network server
UDP/IPSub GHz RF
Net ServerEnd devices
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 104
Frequency Sub-Band Plans
• Full-capacity North American LoRa®
Gateways are relatively expensive• Many LoRa trials and prototypes are
using lower cost 8-channel gateways• A defacto "Frequency Sub-Band"
(FSB) numbering scheme has emerged amongst LoRa gateway & network server providers using FSB 1 to 8
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 105
Frequency Sub-Band Plans (continued)
• FSB 1 = Channels 0, 1, 2, 3, 4, 5, 6, 7 (125 kHz channels) plus 64 (500 kHz channel), plus a downlink ch.
• FSB 2 = Channels 8, 9, 10, 11, 12, 13, 14, 15 plus 65• FSB 3 = Channels 16, 17, 18, 19, 20, 21, 22, 23 plus 66• ....• FSB 8 = Channels 56, 57, 58, 59, 60, 61, 62, 63 plus 71
• For North America, TTN have decided that all such gateways for this band shall be set to listen on FSB 2.
• RN2903 can transmit on all channels, so this information is used for appropriate channel masking to prevent dropping of packets!
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 106
IoT Gateway: A LoRaWAN™ Gateway- Agenda -
• Overview• Typical Architecture• Gateway Options• Provisioning a Gateway
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 107
The Things Gateway
• Developed in collaboration with Microchip and The Things Network• https://www.thethingsnetwork.org/docs/ga
teways/gateway/
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 108
The Things Gateway
• Provides up to 10 km radius of network coverage
• Can serve thousands of nodes (depending on traffic)
• Available at Newark in the US
• http://www.newark.com/the-things-network/ttn-gw-915/accessory-type-wireless-gateway/dp/05AC1807
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 109
Laird Sentrius RG191https://www.lairdtech.com/products/rg1xx-lora-gateway
• 8-channel LoRaWAN™ Gateway• Based on Semtech
SX1301/SX1257 chipset• Presets for TTN Network Service
• Server port numbers• 8 Frequency Channels (FSB 2)
• Multiple Interfaces• LoRaWAN, Bluetooth 4.0, 802.11
a/b/g/n, Ethernet
• FCC/IC/CE Certifications• Industrial Temperature Range (-
30o – 70oC)• IP67 Outdoor Enclosure version
available
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 110
Other Gateway Options• Several Commercial Gateway providers
• Kerlink, Sagemcom, MultiTech, Everynet, Cisco
• Robust, Industrial Grade solutions for indoor and outdoor usage
• Many offer Carrier Grade Gateways• Reliability, quality, maintainability,
specifications etc. are acceptable for use in cellular grade network
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 111
Provisioning RG191 to TTN
• Built-in configuration web server
• Apply pre-sets for “The Things Network US”
• Ports• Forwarder• Channel Map (sub-band)
• Enter “Gateway Key”• From your TTN account
• See Lab Manual Appendix C for detailed instructions
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 112
Agenda• What is LoRa® and LoRaWAN™• Microchip’s LoRa® and LoRaWAN™ Solutions• IoT Sensor: The SODAQ ExpLoRer
• Lab 1 – Pass Through Demo• IoT Gateway: A LoRaWAN™ Gateway• Network Server: The Things Network (TTN)
• Lab 2 – Setup TTN Account and Application• Connecting your Sensor to TTN
• Lab 3 – Connect ExpLoRer to TTN• User Application: Node-RED
• Lab 4 – Node-RED Application• Summary
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 113
Network Server: The Things Network
• Topics to cover:• Description of Network Servers and how
they work.• TTN• Creating an TTN application
• Description of Application ID• Description of Access Key
• Adding a device in your TTN applications
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 114
Network Server
Part 1:IoT Sensor
LoRaWAN™ Servers
Part 2:IoT Gateway
Part 3:Network Servers
Part 4:User Apps
The IoT with LoRaWAN™
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 115
Network Server
• Device that speaks LoRaWAN™ to Gateway
• Device that gets the data to your Application
• IP protocol App ServerGateway
UDP/IP IP
Net Server
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 116
TTN
• Who’s The Things NetworkAn OPEN, free-to-use community network
TTN mission is to build a DECENTRALIZED, OPEN and CROWDSOURCED INTERNET OF THINGS data network OWNED and OPERATED by its USERS
Easiest LoRaWAN™ infrastructure to use for developing and experimenting with the Internet of Things
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 117
TTN
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 118
TTN
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 119
TTN
• https://www.thethingsnetwork.org/• Create an Account
• Account needs to be activated with email supplied during creation.
• Will work without activation for few days.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 120
TTN
• https://console.thethingsnetwork.org/• Create an Application
• Needs to be unique name within TTN infrastructure. Even amongst users.
• Multiple Apps possible• TTN will generate:
• “AppEUI” (for sensor & apps)• “Access Key” (for apps)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 121
TTN Application
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 122
TTN
• Register a Device• Device ID
• Unique readable name of device within Application (ex: “explorer0001”)
• Device EUI (“DevEUI”)• Unique hardware address identifier for the
device on the network• Typically the MAC address of the sensor
• AppKey (16 bytes)• Used by the sensor to access the application
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 123
TTN Device
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 124
TTN Activation• Over The Air Activation (OTAA)
• Using AppEUI, DevEUI and AppKey
• Activation By Personalization (ABP)• Requires DevAdr, NetSKey, AppSKey
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 125
LoRaWAN™ Network Server
• Multiple ways for apps to connect to Network Server• HTTP• Node-Red• MQTT• ….
Lets look at a few….
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 126
Connecting to TTN• Browser access (HTTP)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 127
Connecting to TTN• MQTT
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 128
Lab 2Setup TTN Account and Application
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 129
Lab 2 Objectives
• Create and log in to your TTN account
• Create the Application that will be used in future labs.
• Register your device to the application• Use the DevEUI from Lab 1
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 130
Lab 2 Summary
• Our IoT gateway is connected to The Things Network servers.
• A TTN account is required to connect your device to TTN network servers.
• You create applications in the TTN Console to collect data from your devices.
• Each device must be registered to an application.
• You can register your own gateway or connect to existing gateways.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 131
Agenda• What is LoRa® and LoRaWAN™• Microchip’s LoRa® and LoRaWAN™ Solutions• IoT Sensor: The SODAQ ExpLoRer
• Lab 1 – Pass Through Demo• IoT Gateway: A LoRaWAN™ Gateway• Network Server: The Things Network (TTN)
• Lab 2 – Setup TTN Account and Application• Connecting your Sensor to TTN
• Lab 3 – Connect ExpLoRer to TTN• User Application: Node-RED
• Lab 4 – Node-RED Application• Summary
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 132
Connecting to TTN in Arduino• APIs that abstract RN2xx3 LoRaWAN
commands/responses.• SODAQ’s “Sodaq_RN2483” Library
• https://github.com/SodaqMoja/Sodaq_RN2483• TTN’s “arduino-device-lib” Library
• https://github.com/TheThingsNetwork/arduino-device-lib
• Documentation• https://github.com/TheThingsNetwork/arduin
o-device-lib/blob/master/docs/TheThingsNetwork.md
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 133
Device Parameters(Gateway)
Parameter Description How Chosen Value used in this class
Frequency Band Regional Frequency Selected via Radio Choice US 902-928
DRx Upstream Data Rate (based on [SF, BW] pairing), values 0..4. Downstream Data Rate [SF, BW] is derived from this (see section 2.2.7 in LoRaWAN Regional Parameters specification document).
Optimize based on desired data rate and payload size, given 400mS dwell-time limit. TTN Library supports DR 0..3
DR3 [SF7, 125kHz], 5.5kbps,
242 byte max. payload
FSB x Frequency Sub-Band(1 thru 8)
Select based on recommendation of network provider (TTN for example)
FSB 2
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 134
Device Parameters(Activation)
Parameter Description How Chosen Value used in this class
Activation Method How the device obtains keys and joins the network.
OTAA: Derived keys, ABP: Pre-shared keys. OTAA is the standard method and supports roaming.
OTAA
AppEUIIEEE EUI64 identifier that uniquely identifies the application provider of the device. The AppEUI is stored in the end-device before the activation procedure is executed.
Required for OTAA.Created during application provisioning on TTN.
Copy/PasteFrom your
TTN Account
AppKeyAdditional 128-bit key that is required for the device to derive the actual security keys (NwkSkey and AppSKey)
Required for OTAA.Created during application provisioning on TTN.
Copy/PasteFrom your
TTN Account
DevEUIGlobal end-device ID in IEEE EUI64 address space that uniquely identifies the end-device.
Required for OTAA.Serialized by the RN2xx3 device, based on its IEEE EUI64 HwEUI.
Embedded in RN2xx3
Module
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 135
Device Parameters(Network/Application)
Parameter Description How Chosen Value used in this class
ADR Adaptive Date Rate Mechanism (Enabled/Disabled)
Select whether you want the network to dynamically change the SF and/or Tx pwr to optimize battery life/network capacity.
Disabled
Class AUplink Message Type Confirmed/Unconfirmed
Based on application requirements, or gateway downlink capacity limitations Unconfirmed**
FPort Identifies the end application or service. Port 0 is reserved for MAC messages. Comparable with a TCP/UDP port number for a TCP/IP device.
Up to the application developer. Valid range of values is 1..223
1
**Note that with unconfirmed transmissions, your node still perceives a successful Tx even if the gateway network connection becomes disconnected!!
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 136
TTN Payload Decoder Function
• Custom JavaScript code running in your TTN application
• Used to format compact byte-array payloads to something more usable by external applications
• Conversion of uplink payload:[0x02, 0x32, 0x34, 0x2E, 0x30] {rgbLed: “green”, temperature: “24.0”}
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 137
Payload Decoder Function in Action
RawPayload
DecodedPayload
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 138
Lab 3Connect ExpLoRer to TTN
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 139
Lab 3 Objectives
• Use TTN arduino-device-lib APIs to• Configure LoRaWAN™ Gateway parameters
• Frequency Band, Frequency Sub-Band (FSB x), Data Rate (DR)
• Configure LoRaWAN Activation parameters• AppEUI, AppKey, DevEUI
• Configure LoRaWAN Network/Application parameters• Adaptive Data Rate (ADR), Uplink Message Type
(Confirmed/Unconfirmed), Application port number (Fport)• Join the Network• Transmit Uplink Messages to your TTN Application• Receive Downlink Messages from your TTN Application
• Learn how to view your connected device’s status/data in the TTN console.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 140
Lab 3 ResultsRGB LED is GREEN
MCP9700AT Temperature Sensor (A6)
Blue LED Blinks 1x/sec
Push Button Cycles through colors
LoRaWAN message sent to TTN every 10 seconds:[0x02, 0x32, 0x34, 0x2E, 0x30]
[current color, current temperature]
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 141
Lab 3 Summary
• A network server will collect data from devices are that are connected to gateways.
• With an appKey and appEUI, you can connect your device to The Things Network if you are in range of a gateway.
• The TTN “arduino-device-lib” contains APIs that implement Class A device interactions with a LoRaWAN network, using RN2xx3
• The TTN Console allows you to see activity from your devices and send downlink data to the device.
• What you have so far:• IoT device Gateway Network Server User Application
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 142
Agenda• What is LoRa® and LoRaWAN™• Microchip’s LoRa® and LoRaWAN™ Solutions• IoT Sensor: The SODAQ ExpLoRer
• Lab 1 – Pass Through Demo• IoT Gateway: A LoRaWAN™ Gateway• Network Server: The Things Network (TTN)
• Lab 2 – Setup TTN Account and Application• Connecting your Sensor to TTN
• Lab 3 – Connect ExpLoRer to TTN• User Application: Node-RED
• Lab 4 – Node-RED Application• Summary
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 143
Agenda
LoRaWAN™ Servers
Part 2:IoT Gateway
Part 3:Network Servers
Labs 2 & 3:Getting Data from
IoT Device to Server
Part 4:User Apps
Lab 4:Creating a User App
The IoT with LoRaWAN™
Part 1:IoT Sensor
Lab 1:RN2903
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 144
User Application: Node-RED- Agenda -
• Application Server Options• Node-RED Overview
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 145
Application Server Options
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 146
Introduction
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 147
Overview• What is Node-Red?
• Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
• Built on Node.js server-side framework.• It provides a browser-based editor that makes it easy to
wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.
• JavaScript functions can be created within the editor using a rich text editor.
• A built-in library allows you to save useful functions, templates or flows for re-use.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 148
Platforms
Image from: https://nodered.org/
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 149
A “Flow”Nodes & Messages
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 150
Nodes & Messages
• Messages pass between nodes• Moving from input nodes to output nodes
• 3 main types of nodes:• Input Nodes (eg. inject)• Output Nodes (eg. debug)• Processing Nodes (ex. function)
• Messages are JavaScript Objects that contain (at least) a “payload” parameter
msg = { payload: ”message payload” };
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 151
Custom Processing
• “function” node adds Javascript coding
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 152
Node Types Available
• Categories• Input• Output• Function• Social• Storage• many more…
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 153
Sharing Flows
• Flows can be exported as JSON formatted text files and imported into Node-RED
• “MQTT TTN” Node
[{
"id":"390f22e4.c6f0de","type":"mqtt in","z":"16786fc8.aa8f2","name":"MQTT TTN",“topic":"#","qos":"2","broker":"f130deb5.0ecf2","x":90,"y":80,"wires":[["eafc8d62.15037","e1533fd3.1eacc"]
]},
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 154
Dashboard
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 155
Search New Nodes
• https://flows.nodered.org
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 156
Installation
• See Appendix D in Lab Manual for Windows Installation procedures
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 157
Starting Node-RED
• Launch Node-RED application
• Browsing the home page (localhost:1880)
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 158
Demo
• Creating your first Flow
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 159
Learning Resources
• More info at http://noderedguide.com/
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 160
TTN Nodes for Node-REDRequired Parameters
• “node-red-contrib-ttn v2.0.4”• https://flows.nodered.org/node/node-red-contrib-ttn
Parameter Description How Chosen Value used in this class
Application ID Application identifier text Created during application provisioning on TTN.
Copy/PasteFrom your
TTN Account
Access Key128-bit key used to authenticate MQTT accesses to the data server
Created during application provisioning on TTN.
Copy/PasteFrom your
TTN Account
Device ID Device identifier text Created during application provisioning on TTN.
Copy/PasteFrom your
TTN Account
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 161
Lab 4Node-RED Application
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 162
Lab 4 Objectives
• Create/modify simple Node-RED application that• Runs on your local machine in a browser• Collects temperature data from the TTN
server• Graphs temperature data in Node-RED• Collects/Displays current RGB LED color• Changes color of RGB LED on SODAQ.
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 163
Lab 4 Summary
• User applications use the data from an IoT sensor to do something useful.
• Node-RED applications can run on your local machine or a server.
• Node-RED applications are quick way to prototype web applications.
• What you have so far:• IoT device Gateway Network Server User Application
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 164
Class Summary
• Today we covered:• How a global LoRaWAN™ network like
The Things Network (TTN) works.• How to deploy an RN2903-based
LoRaWAN™ node using the TTN arduino-device-lib library in Arduino®.
• How to create a full IoT ecosystem by sending data through the entire IoT data path• IoT device Gateway Network Server User Application
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 165
Additional Resources
• TTN Documentation Homepage• LoRa® Alliance Website• Additional Arduino Libraries for SODAQ
ExpLoRer• Sodaq_RN2483 (LoRaWAN API)
• https://github.com/SodaqMoja/Sodaq_RN2483• Microchip_RN487x (BLE Module)
• https://github.com/SodaqMoja/Microchip_RN487x• RN2483/RN2903 FirmwareUpdater
• https://github.com/SodaqMoja/RN2483FirmwareUpdater
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 166
Additional Resources
• “TTN Mapper”• 3rd party application to map actual coverage
of a gateway. Dynamic web page shows coverage map of all Gateways in TTN.
• https://ttnmapper.org• An App is available from Google Play Store
• “TTN Mobile”• 3rd party app used to monitor your TTN
Applications and Devices• Available from Google Play Store
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 167
Dev Tools For This Class
• SODAQ ExpLoRer (PN: THW1021)• SODAQ ExpLoRer Support Page• Purchase on microchipDirect
• Gateways• Laird Sentrius RG191• The Things Network
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 168
Thank You!
© 2018 Microchip Technology Incorporated. All Rights Reserved. 22080 IoT2 Slide 169
LEGAL NOTICESOFTWARE: You may use Microchip software exclusively with Microchip products. Further, use of Microchip software is subject to the copyright notices, disclaimers, and any license terms accompanying such software, whether set forth at the install of each program or posted in a header or text file.
Notwithstanding the above, certain components of software offered by Microchip and 3rd parties may be covered by “open source” software licenses – which include licenses that require that the distributor make the software available in source code format. To the extent required by such open source software licenses, the terms of such license will govern.
NOTICE & DISCLAIMER: These materials and accompanying information (including, for example, any software, and references to 3rd party companies and 3rd party websites) are for informational purposes only and provided “AS IS.” Microchip assumes no responsibility for statements made by 3rd party companies, or materials or information that such 3rd parties may provide.
MICROCHIP DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY DIRECT OR INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL, OR CONSEQUENTIAL LOSS, DAMAGE, COST, OR EXPENSE OF ANY KIND RELATED TO THESE MATERIALS OR ACCOMPANYING INFORMATION PROVIDED TO YOU BY MICROCHIP OR OTHER THIRD PARTIES, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBLITY OF SUCHDAMAGES OR THE DAMAGES ARE FORESEEABLE. PLEASE BE AWARE THAT IMPLEMENTATION OF INTELLECTUAL PROPERTY PRESENTED HERE MAY REQUIRE A LICENSE FROM THIRD PARTIES.
TRADEMARKS: The Microchip name and logo, the Microchip logo, AnyRate, AVR, AVR logo, AVR Freaks, BitCloud, chipKIT, chipKIT logo, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR, Heldo, JukeBlox, KeeLoq, Kleer, LANCheck, LINK MD, maXStylus, maXTouch, MediaLB, megaAVR, MOST, MOST logo, MPLAB, OptoLyzer, PIC, picoPower, PICSTART, PIC32 logo, Prochip Designer, QTouch, SAM-BA, SpyNIC, SST, SST Logo, SuperFlash, tinyAVR, UNI/O, and XMEGA are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.ClockWorks, The Embedded Control Solutions Company, EtherSynch, Hyper Speed Control, HyperLight Load, IntelliMOS, mTouch, Precision Edge, and Quiet-Wire are registered trademarks of Microchip Technology Incorporated in the U.S.A.Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BodyCom, CodeGuard, CryptoAuthentication, CryptoAutomotive, CryptoCompanion, CryptoController, dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit Serial Programming, ICSP, INICnet, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, memBrain, Mindi, MiWi, motorBench, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, PowerSmart, PureSilicon, QMatrix, REAL ICE, Ripple Blocker, SAM-ICE, Serial Quad I/O, SMART-I.S., SQI, SuperSwitcher, SuperSwitcher II, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries. All other trademarks mentioned herein are property of their respective companies.© 2018, Microchip Technology Incorporated, All Rights Reserved.