Dragino LSN50, LSN50 LoRa User Manual

www.dragino.com
Description
Date
Release
2018-Dec-4
Add steps of install STM320x; Add ST-Link Upload firmware method
2018-Dec-27
Add trouble shooting for UART upload, Add change log for firmware v1.4
2019-Jan-23
More detail description for 8 channel mode and trouble shooting for using in US915/AU915
2019-Feb-21
Modify trouble shooting for upload via Flashloader
2019-Mar-13
Add ISP Mode / Flash mode different/ Add working flow diagram (Chapter 2.1 how it works) Add FAQ for how to configure the Keys
2019-Apr-1
Upgrade to v1.5 version firmware Add ultrasonic sensor support and description. Add downlink description Change decoder for v1.5 Add working flow chart Add Mydevices support
2019-Apr-19
Improve Interrupt feature, change interrupt example to use door sensor
Various minor text and format edits.
2019-Jun-10
Update to firmware v1.6 version, add 3ADC mode
2019-Aug-7
Trouble shooting for AT Command input Add support for 3 * DS18B20 (MOD4)
2019-Sep-18
LSN50 LoRa Sensor Node User Manual
Document Version: 1.6.1 Image Version: v1.6
LSN50 LoRa Sensor Node User Manual 1 / 60
www.dragino.com
1. Introduction 4
1.1 What is LSN50 LoRa Sensor Node 4
1.2 Specifications 5
1.3 Features 6
1.4 Applications 6
1.5 Pin Definitions 7
1.6 Hardware Change log 8
1.7 Hole Option 9
2. Use LSN50 with LoRaWAN firmware 10
2.1 How it works 10
2.2 Quick guide to connect to LoRaWAN server (OTAA) 11
2.3 Working Mode & Uplink Payload 14
2.3.1 MOD=1 (Default Mode) 14
2.3.2 MOD=2 (Distance Mode) 15
2.3.3 MOD=3 (3 ADC + I2C) 16
2.3.4 MOD=4 (3 x DS18B20) 17
2.3.5 Decode payload in The Things Network 18
2.4 Payload Explanation and Sensor Interface 21
2.4.1 Battery Info 21
2.4.2 Temperature (DS18B20) 21
2.4.3 Digital Input 21
2.4.4 Analogue Digital Converter (ADC) 22
2.4.5 Digital Interrupt 23
2.4.6 I2C Interface (SHT20) 25
2.4.7 Distance Reading 26
2.4.8 Ultrasonic Sensor 26
2.4.9 +5V Output 27
2.5 Downlink Payload 28
2.6 Show Data in Mydevices IoT Server 29
2.7 Firmware Change Log 32
2.8 Battery Analysis 34
2.8.1 Battery Type 34
2.8.2 Power consumption Analyze 34
2.8.3 Battery Note 35
2.8.4 Replace the battery 35
3. Using the AT Commands 36
3.1 Access AT Commands 36
3.2 Common AT Command Sequence 38
3.2.1 Multi-channel ABP mode (Use with SX1301/LG308) 38
3.2.2 Single-channel ABP mode (Use with LG01/LG02) 38
4. Upload Firmware 39
4.1 Upload Firmware via Serial Port 39
4.2 Upload Firmware via ST-Link V2 42
5. Developer Guide 44
5.1 Source Code 44
5.2 Compile Source Code 44
LSN50 LoRa Sensor Node User Manual 2 / 60
www.dragino.com
5.2.1 Set up Keil Compile Environment 44
5.2.2 Install STM32L0 Series Device 48
5.2.3 Compile Source Code 50
6. FAQ 52
6.1 Why there is 433/868/915 version? 52
6.2 What is the frequency range of LT LoRa part? 52
6.3 How to change the LoRa Frequency Bands/Region? 52
6.4 Can I use Private LoRa protocol? 52
6.5 How to set up LSN50 to work in 8 channel mode 53
6.6 How to set up LSN50 to work with Single Channel Gateway such as LG01/LG02? 55
6.7 How to configure the EUI keys in LSN50? 56
7. Trouble Shooting 57
7.1 Connection problem when uploading firmware. 57
7.2 Why I can’t join TTN in US915 / AU915 bands? 57
7.3 AT Command input doesn’t work 58
8. Order Info 59
9. Packing Info 59
10. Support 60
11. References 60
LSN50 LoRa Sensor Node User Manual 3 / 60
www.dragino.com
1. Introduction
1.1 What is LSN50 LoRa Sensor Node
LSN50 is a Long Range LoRaWAN Sensor Node. It is designed for outdoor data logging and powered by Li/SOCl2 battery for long term use and secure data transmission. It is designed to facilitate developers to quickly deploy industrial level LoRa and IoT solutions. It helps users to turn the idea into a practical application and make the Internet of Things a reality. It is easy to program, create and connect your things everywhere.
It is based on SX1276/SX1278 allows the user to send data and reach extremely long ranges at low data-rates. It provides ultra-long range spread spectrum communication and high interference immunity whilst minimizing current consumption. It targets professional wireless sensor network applications such as irrigation systems, smart metering, smart cities, smartphone detection, building automation, and so on.
LSN50 uses STM32l0x chip from ST, STML0x is the ultra-low-power STM32L072xx
microcontrollers incorporate the connectivity power of the universal serial bus (USB 2.0 crystal-less) with the high-performance ARM® Cortex®-M0+ 32-bit RISC core operating at a 32 MHz frequency, a memory protection unit (MPU), high-speed embedded memories (192 Kbytes of Flash program memory, 6 Kbytes of data EEPROM and 20 Kbytes of RAM) plus an extensive range of enhanced I/Os and peripherals.
LSN50 is an open source product, it is based on the STM32Cube HAL drivers and lots of libraries can be found in ST site for rapid development.
LSN50 LoRa Sensor Node User Manual 4 / 60
www.dragino.com
1.2 Specifications
Micro Controller:
STM32L072CZT6 MCU
MCU: STM32L072CZT6
Flash: 192KB
RAM: 20KB
EEPROM: 6KB
Clock Speed: 32Mhz
Common DC Characteristics:
Supply Voltage: 2.1v ~ 3.6v
Operating Temperature: -40 ~ 85°C
I/O pins: Refer to STM32L072 datasheet
LoRa Spec:
Frequency Range, Band 1 (HF): 862 ~ 1020 Mhz
or
Band 2 (LF): 410 ~ 528 Mhz
168 dB maximum link budget.
+20 dBm - 100 mW constant RF output vs.
+14 dBm high efficiency PA.
Programmable bit rate up to 300 kbps.
High sensitivity: down to -148 dBm.
Bullet-proof front end: IIP3 = -12.5 dBm.
Excellent blocking immunity.
Low RX current of 10.3 mA, 200 nA register retention.
Fully integrated synthesizer with a resolution of 61 Hz.
FSK, GFSK, MSK, GMSK, LoRaTM and OOK modulation.
Built-in bit synchronizer for clock recovery.
Preamble detection.
127 dB Dynamic Range RSSI.
Automatic RF Sense and CAD with ultra-fast AFC.
Packet engine up to 256 bytes with CRC.
LoRaWAN 1.0.2 Specification
Battery:
Li/SOCI2 un-chargeable battery
Capacity: 4000mAh
Self Discharge: <1% / Year @ 25°C
Max continuously current: 130mA
Max boost current: 2A, 1 second
Power Consumption
STOP Mode: 2.7uA @ 3.3v
LoRa Transmit Mode: 125mA @ 20dBm 44mA @ 14dBm
LSN50 LoRa Sensor Node User Manual 5 / 60
www.dragino.com
1.3 Features
LoRaWAN 1.0.2 Class A,Class C
STM32L072CZT6 MCU
SX1276/78 Wireless Chip
Pre-load bootloader on USART1/USART2
MDK-ARM Version 5.24a IDE
I2C, LPUSART1, USB, SPI2
3x12bit ADC, 1x12bit DAC
20xDigital I/Os
LoRa™ Modem
Preamble detection
Baud rate configurable
CN470/EU433/KR920/US915/IN865
EU868/AS923/AU915
Open source hardware / software
Available Band:433/868/915/920 Mhz
IP66 Waterproof Enclosure
Ultra Low Power consumption
AT Commands to change parameters
4000mAh Battery for long term use
1.4 Applications
Smart Buildings & Home Automation
Logistics and Supply Chain Management
Smart Metering
Smart Agriculture
Smart Cities
Smart Factory
LSN50 LoRa Sensor Node User Manual 6 / 60
www.dragino.com
Pin No.
Signal
Direction
Function
Remark
1
VCC(2.9V)
OUTPUT
VCC
Directly connect to main power for board
2
PA0
In/Out
Directly from STM32 chip
Used as ADC in LSN50 image
3
PA1
In/Out
Directly from STM32 chip
4
PA2
In/Out
Directly from STM32 chip, 10k pull up to VCC
Used as UART_TXD in LSN50 image
5
PA3
In/Out
Directly from STM32 chip, 10k pull up to VCC
Used as UART_RXD in LSN50 image
6
PB6
In/Out
Directly from STM32 chip, 10k pull up to VCC
7
PB7
In/Out
Directly from STM32 chip, 10k pull up to VCC
8
PB3
In/Out
Directly from STM32 chip, 10k pull up to VCC
9
PB4
In/Out
Directly from STM32 chip
10
PA9
In/Out
Directly from STM32 chip, 10k pull up to VCC
11
PA10
In/Out
Directly from STM32 chip, 10k pull up to VCC
12
GND Ground
13
VCC(2.9V)
OUTPUT
VCC
Directly connect to main power for board
14
Jumper
Power on/off jumper
15
PA4
In/Out
Directly from STM32 chip
16
NRST
In
Reset MCU
1.5 Pin Definitions
LSN50 LoRa Sensor Node User Manual 7 / 60
www.dragino.com
17
PA12
In/Out
Directly from STM32 chip
18
PA11
In/Out
Directly from STM32 chip
19
PA14
In/Out
Directly from STM32 chip
20
PB13
In/Out
Directly from STM32 chip
21
PB12
In/Out
Directly from STM32 chip
22
PB15
In/Out
Directly from STM32 chip
23
PB14
In/Out
Directly from STM32 chip
24
PA13
In/Out
Directly from STM32 chip
25
PA8
In/Out
Directly from STM32 chip
Default use to turn on/off LED1 in LSN50 image
26
GND Ground
27
+5V
Out
5v output power
Controlled by PB5(Low to Enable, High to Disable)
28
LED1
Controlled by PA8
Blink on transmit
29
BOOT MODE
Configure device in working mode or ISP program mode
Flash: Normal Working mode and send AT Commands ISP: UART Program Mode
30
NRST
In
Reset MCU
1.6 Hardware Change log
LSN50 v1.2:
Add LED. Turn on for every LoRa transmit
Add pin PA4, PB13, NRST
Add 5V Output, on/off control by PB5(Low to Enable, High to Disable)
LSN50 v1.3:
Add P-MOS to control 5V output
LSN50 LoRa Sensor Node User Manual 8 / 60
www.dragino.com
1.7 Hole Option
The LSN50 provides different hole size options for different size sensor cable. The options provided are M12, M16 and M20. The definition is as below:
LSN50 LoRa Sensor Node User Manual 9 / 60
www.dragino.com
2. Use LSN50 with LoRaWAN firmware
2.1 How it works
The LSN50 is pre-loaded with a firmware and is configured as LoRaWAN OTAA Class A mode by default. It has OTAA keys to join LoRaWAN network. To connect a local LoRaWAN network, you just need to input the OTAA keys in the LoRaWAN IoT server and power on the LSN50. It will automatically join the network via OTAA.
The diagram below shows the working flow in default firmware (Ver 1.6):
In case you can’t set the OTAA keys in the LoRaWAN OTAA server, and you have to use the keys from the server, you can use AT Commands to set the keys in the LSN50.
LSN50 LoRa Sensor Node User Manual 10 / 60
www.dragino.com
2.2 Quick guide to connect to LoRaWAN server (OTAA)
Following is an example for how to join the TTN LoRaWAN Network. Below is the network structure; we use the LG308 as a LoRaWAN gateway in this example.
The LG308 is already set to connected to TTN network , so what we need to now is configure the TTN server.
Step 1: Create a device in TTN with the OTAA keys from LSN50. Each LSN50 is shipped with a sticker with the default device EUI as below:
LSN50 LoRa Sensor Node User Manual 11 / 60
www.dragino.com
You can enter this key in the LoRaWAN Server portal. Below is TTN screen shot:
Add APP EUI in the application
Add APP KEY and DEV EUI
LSN50 LoRa Sensor Node User Manual 12 / 60
www.dragino.com
Step 2: Power on LSN50
Put a Jumper on JP2 to power on the device.
Step 3: The LSN50 will auto join to the TTN network. After join success, it will start to upload messages to TTN and you can see the messages in the panel.
LSN50 LoRa Sensor Node User Manual 13 / 60
www.dragino.com
Size(bytes )
2 2 1 2 2
2
Value
BAT
Temperature (DS18B20)
Digital in & Digital Interrupt
ADC
Temperature (SHT20 or SHT31 or Ultrasonic Sensor)
Humidity (SHT20)
2.3 Working Mode & Uplink Payload
LSN50 has different working mode for the connections of different type of sensors. This section describes these modes. Use can use the AT Command AT+MOD to set LSN50 to different working modes.
For example: AT+MOD=2 // will set the LSN50 to work in MOD=2 distance mode which target to measure distance via Ultrasonic Sensor.
NOTE:
1. Some working modes has payload more than 12 bytes, The US915/AU915/AS923
frequency bands definition has maximum 11 bytes in DR0. Server sides will see NULL payload while LSn50 transmit in DR0 with 12 bytes payload.
2. All modes share the same Payload Explanation from HERE.
3. By default, the device will send an uplink message every 10 minutes.
2.3.1 MOD=1 (Default Mode)
In this mode , uplink payload includes in total 11 bytes. Uplink packets use FPORT=2.
LSN50 LoRa Sensor Node User Manual 14 / 60
www.dragino.com
Size(bytes)
2 2 1 2 2
2
Value
BAT
Temperature (DS18B20)
Digital in & Digital Interrupt
ADC
Distance measure by:
1) LIDAR-Lite V3HP Or
2) Ultrasonic Sensor
Humidity (SHT20)
2.3.2 MOD=2 (Distance Mode)
This mode is target to measure the distance. The payload of this mode is totally 11 bytes. The 8th and 9th bytes is for the distance.
Connection of LIDAR-Lite V3HP:
LSN50 LoRa Sensor Node User Manual 15 / 60
www.dragino.com
Size(bytes)
2 2 2 1 2
2
1
Value
ADC1
(Pin PA0)
ADC2 (PA1)
ADC3 (PA4)
Digital in &
Digital
Interrupt
Temperature
(SHT20 or
SHT31)
Humidity
(SHT20 or
SHT31)
BAT
Connection to Ultrasonic Sensor:
While connecting to Ultrasonic sensor, the sleep current will jump to 250uA. It is recommend to use external power source for ultrasonic sensor.
2.3.3 MOD=3 (3 ADC + I2C)
This mode has total 12 bytes. Include 3 x ADC + 1x I2C
LSN50 LoRa Sensor Node User Manual 16 / 60
www.dragino.com
Size(bytes)
2 2 2 1 2
2
Value
BAT
Temperature1
(DS18B20)
(PB3)
ADC
Digital in &
Digital
Interrupt
Temperature2
(DS18B20)
(PA9)
Temperature3
(DS18B20)
(PA10)
2.3.4 MOD=4 (3 x DS18B20)
This mode is supported in firmware version since v1.6.1
Hardware connection is as below, (Note: R3 & R4 should change from 10k to 4.7k to
support DS18B20, Software set to AT+MOD=4)
This mode has total 11 bytes. As shown below:
LSN50 LoRa Sensor Node User Manual 17 / 60
www.dragino.com
2.3.5 Decode payload in The Things Network
While using TTN network, you can add the payload format to decode the payload.
The payload decoding function is as follows:
function Decoder(bytes, port) { // Decode an uplink message from a buffer // (array) of bytes to an object of fields. if(bytes[6] & 0x10) { var mod4="3DS18B20"; //work mode }
else if(bytes[6] & 0x08) { var mod3="3ADC"; //work mode
LSN50 LoRa Sensor Node User Manual 18 / 60
Loading...
+ 42 hidden pages