Dragino LSN50 LoRa Sensor Node User manual

Category
Gateways/controllers
Type
User manual
www.dragino.com
LSN50 LoRa Sensor Node User Manual 1 / 56
LSN50 LoRa Sensor Node User Manual
Document Version: 1.5.0
Image Version: v1.5
Version
Description
Date
1.0
Release
2018-Dec-4
1.1
Add steps of install STM320x; Add ST-Link Upload firmware method
2018-Dec-27
1.2
Add trouble shooting for UART upload, Add change log for firmware v1.4
2019-Jan-23
1.2.1
More detail description for 8 channel mode and trouble shooting for using in
US915/AU915
2019-Feb-21
1.2.2
Modify trouble shooting for upload via Flashloader
2019-Mar-13
1.2.3
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
1.5.0
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 Cayenne support
2019-Apr-19
1.5.1
Improve Interrupt feature, change interrupt example to use door sensor
www.dragino.com
LSN50 LoRa Sensor Node User Manual 2 / 56
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 Definition .............................................................................................................................. 7
1.6 Hardware Change log ................................................................................................................. 8
1.7 Hole Option ................................................................................................................................ 9
2. Use LSN50 with stock LoRaWAN firmware .............................................................................. 10
2.1 How it works? ........................................................................................................................... 10
2.2 Quick guide to connect to LoRaWAN server (OTAA) ................................................................. 11
2.3 Uplink Payload .......................................................................................................................... 14
2.3.1 Payload explain ............................................................................................................... 14
2.3.2 Decode payload in The Things Network ......................................................................... 15
2.4 Payload explain and sensor interface ....................................................................................... 17
2.4.1 Battery Info ..................................................................................................................... 17
2.4.2 Temperature (DS18B20) .................................................................................................. 18
2.4.3 Digital Input .................................................................................................................... 18
2.4.4 ADC ................................................................................................................................. 19
2.4.5 Digital Interrupt .............................................................................................................. 21
2.4.6 I2C Interface (SHT20) ...................................................................................................... 24
2.4.7 Ultrasonic Sensor ............................................................................................................ 25
2.4.8 +5V output ...................................................................................................................... 26
2.5 Downlink Payload ..................................................................................................................... 27
2.6 Show data in Cayenne IoT Server ............................................................................................. 27
2.7 Firmware Change Log............................................................................................................... 30
2.8 Battery Analyze ........................................................................................................................ 31
2.8.1 Battery Type .................................................................................................................... 31
2.8.2 Power consumption Analyze .......................................................................................... 31
2.8.3 Battery notice ................................................................................................................. 33
2.8.4 Replace the battery......................................................................................................... 33
3. Use AT Command .................................................................................................................... 34
3.1 Access AT Command ................................................................................................................. 34
www.dragino.com
LSN50 LoRa Sensor Node User Manual 3 / 56
3.2 Common AT Command Sequence ............................................................................................. 36
3.2.1 Multi-channel ABP mode (Use with SX1301/LG308) ...................................................... 36
3.2.2 Single-channel ABP mode (Use with LG01/LG02) ........................................................... 36
4. Upload Firmware .................................................................................................................... 37
4.1 Upload Firmware via Serial Port ............................................................................................... 37
4.2 Upload Firmware via ST-Link V2 ............................................................................................... 40
5. Developer Guide ..................................................................................................................... 42
5.1 Source Code .............................................................................................................................. 42
5.2 Compile Source Code ................................................................................................................ 42
5.2.1 Set up Keil compile environment .................................................................................... 42
5.2.2 Install STM32L0 Series Device......................................................................................... 45
5.2.3 Compile Source Code ...................................................................................................... 46
6. FAQ ......................................................................................................................................... 48
6.1 Why there is 433/868/915 version? ......................................................................................... 48
6.2 What is the frequency range of LT LoRa part? ......................................................................... 48
6.3 How to change the LoRa Frequency Bands/Region? ................................................................ 49
6.4 Can I use Private LoRa protocol? .............................................................................................. 49
6.5 How to set up LSN50 to work in 8 channel mode in US915, AU915, CN470 bands? ................ 50
6.6 How to set up LSN50 to work with Single Channel Gateway such as LG01/LG02?................... 52
6.7 How to configure the EUI keys in LSN50? ................................................................................. 53
7. Trouble Shooting ..................................................................................................................... 54
7.1 Connection problem while using USB <----> TTL to upload firmware. ...................................... 54
7.2 Why I can’t join TTN in US915 /AU915 bands? ......................................................................... 54
8. Order Info ............................................................................................................................... 55
9. Packing Info ............................................................................................................................ 55
10. Support ................................................................................................................................... 55
11. Reference ................................................................................................................................ 56
www.dragino.com
LSN50 LoRa Sensor Node User Manual 4 / 56
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.
www.dragino.com
LSN50 LoRa Sensor Node User Manual 5 / 56
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
www.dragino.com
LSN50 LoRa Sensor Node User Manual 6 / 56
Max boost current: 2A, 1 second
Power Consumption
STOP Mode: 2.7uA @ 3.3v
LoRa Transmit Mode: 125mA @ 20dBm 44mA @ 14dBm
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
www.dragino.com
LSN50 LoRa Sensor Node User Manual 7 / 56
1.5 Pin Definition
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
www.dragino.com
LSN50 LoRa Sensor Node User Manual 8 / 56
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
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
www.dragino.com
LSN50 LoRa Sensor Node User Manual 9 / 56
1.7 Hole Option
The LSN50 provide different hole size option for different size sensor case. the option now
provided is M12/M16 and M20. The definition is as below:
www.dragino.com
LSN50 LoRa Sensor Node User Manual 10 / 56
2. Use LSN50 with stock 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, user
just need to input the OTAA keys in the LoRaWAN IoT server and power on the LSN50. It will auto
join the network via OTAA.
Below shows the working flow in default firmware (version v1.5):
In case user can’t set the OTAA keys in the LoRaWAN OTAA server and has to use the keys from
the server. User can use AT Command to set the keys in LSN50.
www.dragino.com
LSN50 LoRa Sensor Node User Manual 11 / 56
2.2 Quick guide to connect to LoRaWAN server (OTAA)
Here is an example for how to join the TTN LoRaWAN Network. Below is the network structure,
we use LG308 as LoRaWAN gateway in this example.
The LG308 is already set to connect to TTN network . So what we need to now is only configure
the TTN:
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:
www.dragino.com
LSN50 LoRa Sensor Node User Manual 12 / 56
User can enter this key in their LoRaWAN Server portal. Below is TTN screen shot:
Add APP EUI in the application
Add APP KEY and DEV EUI
www.dragino.com
LSN50 LoRa Sensor Node User Manual 13 / 56
Step 2: Power on LSN50
Put a Jumper on JP2 to power on the device.
Step 3: and it will auto join to the TTN network. After join success, it will start to upload message
to TTN and user can see in the panel.
www.dragino.com
LSN50 LoRa Sensor Node User Manual 14 / 56
2.3 Uplink Payload
The uplink payload is totally 11 bytes as shown below:
2.3.1 Payload explain
The uplink payload includes totally 11 bytes. Uplink packets use FPORT=2 and every 10 minutes
send one uplink by default.
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)
www.dragino.com
LSN50 LoRa Sensor Node User Manual 15 / 56
2.3.2 Decode payload in The Things Network
While using TTN network, user can add the payload format to decode the payload.
The function is :
function Decoder(bytes, port) {
// Decode an uplink message from a buffer
// (array) of bytes to an object of fields.
var value=bytes[0]<<8 | bytes[1];
var batV=value/1000;//Battery,units:V
value=bytes[2]<<8 | bytes[3];
if(bytes[2] & 0x80)
{value |= 0xFFFF0000;}
var tempc=(value/10).toFixed(2);//DS18B20,PB3,units:
var adc_ch0=(bytes[4]<<8 | bytes[5])/1000;//PA0,ADC Channel 0,units:V
if(bytes[6] & 0x08)
{
var mod3="3ADC"; //work mode
}
else if(bytes[6] & 0x04)
{
var mod2="ULT"; //work mode
}
else if(!(bytes[6] & 0x04))
{
var mod1="IIC"; //work mode
}
var digital_IS=(bytes[6] & 0x02)? "H":"L";//PA12Digital Input Status
var exti_trigger=(bytes[6] & 0x01)? "TRUE":"FALSE";//PB14,GPIO_MODE_IT_FALLING
var switch_=(bytes[6] & 0x80)? "CLOSE":"OPEN";//PB14,GPIO_MODE_IT_FALLING
if(mod3=="3ADC")
{
var adc_ch1=(bytes[7]<<8 | bytes[8])/1000;//PA1,ADC Channel 1,units:V
var adc_ch4=(bytes[9]<<8 | bytes[10])/1000;//PA4,ADC Channel 4,units:V
www.dragino.com
LSN50 LoRa Sensor Node User Manual 16 / 56
}
else if(mod2=="ULT")
{
value=bytes[7]<<8 | bytes[8];
var ult=(value/10); //ultrasonic,units:cm
}
else if(mod1=="IIC")
{
value=bytes[7]<<8 | bytes[8];
if(bytes[7] & 0x80)
{value |= 0xFFFF0000;}
var temp_SHT=(value/10).toFixed(2);//SHT20,temperature,units:
value=bytes[9]<<8 | bytes[10];
var hum_SHT=(value/10).toFixed(1);//SHT20,Humidity,units:%
}
return {
BatV:batV,
TempC:tempc,
ADC_CH0V:adc_ch0,
ADC_CH1V:adc_ch1,
ADC_CH4V:adc_ch4,
Digital_IStatus:digital_IS,
EXTI_Trigger:exti_trigger,
Door_status:switch_,
MOD1:mod1,
MOD2:mod2,
MOD3:mod3,
Ultrasonic:ult,
TempC_SHT:temp_SHT,
Hum_SHT:hum_SHT
};
}
And the uplink payload will show as below:
www.dragino.com
LSN50 LoRa Sensor Node User Manual 17 / 56
2.4 Payload explain and sensor interface
2.4.1 Battery Info
Check the battery voltage for LSN50.
Ex1: 0x0B45 = 2885mV
Ex2: 0x0B49 = 2889mV
www.dragino.com
LSN50 LoRa Sensor Node User Manual 18 / 56
2.4.2 Temperature (DS18B20)
If there is a DS18B20 connected to PB3 pin. The temperature will be uploaded in the payload.
Connection:
Example:
If read: 0105H: if (0105 & FC00 == 0), temp = 0105H /10 = 26.1 degree
If read: FF3FH : if (FF3F & FC00 == 1) ,temp = (FF3FH - 65536)/10 = -19.3 degrees.
2.4.3 Digital Input
The digital input for pin PA12,
When PA12 is high, the bit2 of payload byte 6 is 1.
When PA12 is low, the bit2 of payload byte 6 is 0.
www.dragino.com
LSN50 LoRa Sensor Node User Manual 19 / 56
2.4.4 ADC
Monitor the voltage in PA0, in mv.
Ex: 0x021F = 543mv,
Example1: Reading an Oil Sensor (Read a resistance value):
In the LSN50, we can use PB4 and PA0 pin to calculate the resistance for the oil sensor. Steps:
1. Solder a 10K resistor between PA0 and VCC.
2. Screw oil sensors two pins to PA0 and PB4.
The equip circuit is as below:
According to above photo:
(  
  

* Bouy on top, the oil sensor act as a 10K resistor.
* Bouy on bottom, it act as a 0ohm resistor,
To get the deep for the liquid, we can measure the
output resistance for oil sensor and calculate
where the bouy is so to calculate the height of oil.
10 ~ 70cm
ADC Pin
PB4 will be set to low(0v) at
every sampling
1) Solder a 10K Resistor
between PA0 and VCC
2) Connect oil sensor to PA0
and PB4
www.dragino.com
LSN50 LoRa Sensor Node User Manual 20 / 56
So
  
  

 is the reading of ADC. So if ADC=0x05DC=0.9 v and VCC (BAT) is 2.9v
The    
 4.5K ohm
Since the Bouy is linear resistance from 10 ~ 70cm.
The position of Bouy is 
  , from the bottom of Bouy
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41
  • Page 42 42
  • Page 43 43
  • Page 44 44
  • Page 45 45
  • Page 46 46
  • Page 47 47
  • Page 48 48
  • Page 49 49
  • Page 50 50
  • Page 51 51
  • Page 52 52
  • Page 53 53
  • Page 54 54
  • Page 55 55
  • Page 56 56

Dragino LSN50 LoRa Sensor Node User manual

Category
Gateways/controllers
Type
User manual

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI