​​​ 

image-20220627094803-5.png

               

Table of Contents:

Data URI image

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, building automation, and so on.

LSN50 uses STM32l0x chip from ST, STML0x is the ultra-low-power STM32L072xxxx 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.

1656294562709-486.png

1.2  Specifications

Micro Controller:

  • MCU: STM32L072xxxx
  • Flash: 128KB
  • 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

​1.3  Features

  • LoRaWAN 1.0.3 Class A, Class C
  • STM32L072xxxx 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/MA869
  • Open-source hardware / software
  • Available Band:433/868/915/920 Mhz
  • IP66 Waterproof Enclosure
  • Ultra-Low Power consumption
  • AT Commands to change parameters
  • 4000mAh or 8500mAh Battery for long term use.

1.4 ​ Applications

  • Smart Cities
  • Smart Factory
  • Smart Metering
  • Smart Agriculture
  • Smart Buildings & Home Automation
  • Logistics and Supply Chain Management

1.5  Pin Definitions and Switch

1656295519542-152.png

1656295532863-613.png

No.SignalDirectionFunctionRemark
1VCC(2.9V)OUTPUTVCCDirectly connect to main power for board
2PA0In/OutDirectly from STM32 chipUsed as ADC in LSN50 image
3PA1In/OutDirectly from STM32 chip 
4PA2In/OutDirectly from STM32 chip, 10k pull up to VCCUsed as UART_TXD in LSN50 image
5PA3In/OutDirectly from STM32 chip, 10k pull up to VCCUsed as UART_RXD in LSN50 image
6PB6In/OutDirectly from STM32 chip, 10k pull up to VCC 
7PB7In/OutDirectly from STM32 chip, 10k pull up to VCC 
8PB3In/OutDirectly from STM32 chip, 10k pull up to VCC 
9PB4In/OutDirectly from STM32 chip 
10PA9In/OutDirectly from STM32 chip, 10k pull up to VCC 
11PA10In/OutDirectly from STM32 chip, 10k pull up to VCC 
12GND Ground 
13VCC(2.9V)OUTPUTVCCDirectly connect to main power for board
14Jumper Power on/off jumper 
15PA4In/OutDirectly from STM32 chip 
16NRSTInReset MCU 
17PA12In/OutDirectly from STM32 chip 
18PA11In/OutDirectly from STM32 chip 
19PA14In/OutDirectly from STM32 chip 
20PB13In/OutDirectly from STM32 chip 
21PB12In/OutDirectly from STM32 chip 
22PB15In/OutDirectly from STM32 chip 
23PB14In/OutDirectly from STM32 chip 
24PA13In/OutDirectly from STM32 chip 
25PA8In/OutDirectly from STM32 chipDefault use to turn on/off LED1 in LSN50 image
26GND Ground 
27+5VOut5v output power

Controlled by PB5(Low to Enable, High to Disable)

Continuous output : max 600mA

Pulse output : max 1A

28LED1 Controlled by PA8Blink on transmit
29BOOT MODE Configure device in working mode or ISP program mode

Flash: Normal Working mode and send AT Commands

ISP: UART Program Mode

30NRSTInReset MCU 

 

1.5.1  Jumper JP2

Power on Device when put this jumper.

1.5.2  BOOT MODE / SW1

1. ISP:     upgrade mode, device won't have any signal in this mode. but ready for upgrade firmware. LED won't work. Firmware won't run.

2. Flash:  work mode, device starts to work and send out console output for further debug

1.5.3  Reset Button

Press to reboot the device.

1.5.4  LED

It will flash:

1. When boot the device in flash mode

2. Send an uplink packet

1.6  Hardware Change log

Note: Hardware version is marked in the PCB.

LSN50 v2.1:

  1. Change R14 to 1M ohm
  2. Change R3, R4 to 4.7Kohm. So no need to modify them for 3 DS18B20 connection.
  3. Add ESD to each I/O

LSN50 v2.0:

  • Change to a new enclosure. Improve with external antenna, IP66, ear hook.

LSN50 v1.3:

  • Add P-MOS to control 5V output

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)

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:

image-20220627104757-1.png

1656298089706-973.png

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.8.0):  

 

image-20220823174408-9.png

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.

2.2  ​Quick guide to connect to LoRaWAN server (OTAA)

Following is an example for how to join the TTN V3 LoRaWAN Network. Below is the network structure; we use the LG308  as a LoRaWAN gateway in this example.  

Data URI image1655891470063-521.png1656298385089-555.png

 

The LG308 is already set to connected to TTN V3 network , so what we need to now is configure the TTN V3 server.Data URI imageData URI image

 

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:

image-20230425173445-3.png

Data URI imageData URI imageData URI imageData URI image

You can enter this key in the LoRaWAN Server portal. Below is TTN screen shot:

Register the device:

Data URI imageData URI imageData URI imageData URI imageData URI imageData URI imageData URI image​​

Data URI imageData URI imageimage-20231028092240-1.png

Add APP EUI ,DEV EUI and AppKey:

image-20231028092510-2.png

Step 2: Power on LSN50

Put a Jumper on JP2 to power on the device.

image-20220627145643-5.png

For LSn50v2:

1656313034748-905.png

Step 3:  The LSN50 will auto join to the TTN V3 network. After join success, it will start to upload messages to TTN V3 and you can see the messages in the panel.

1656312908855-552.png

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 5 minutes.

2.3.1  MOD=1 (Default Mode)

In this mode, uplink payload includes in total 11 bytes. Uplink packets use FPORT=2.

Size(bytes)222122
ValueBatTemperature(DS18B20)ADCDigital in & Digital InterruptTemperature(SHT20 or SHT31 or BH1750 Illumination Sensor)Humidity(SHT20)

image-20220627150949-6.png

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.

Size(bytes)222122
ValueBAT

Temperature(DS18B20)

ADCDigital in & Digital Interrupt

Distance measure by:
1) LIDAR-Lite V3HP
Or
2) Ultrasonic Sensor

Reserved

1656324539647-568.png

Connection of LIDAR-Lite V3HP:

1656324581381-162.png

Connection to Ultrasonic Sensor:

1656324598488-204.png

For the connection to TF-Mini or TF-Luna , MOD2 payload is as below:

Size(bytes)221222
ValueBAT

Temperature(DS18B20)

Digital in & Digital InterruptADC

Distance measure by:1)TF-Mini plus LiDAR
Or 
2) TF-Luna LiDAR

Distance signal  strength

1656376779088-686.png

Connection to TF-Mini plus LiDAR(UART version):

Need to remove R3 and R4 resistors to get low power. Since firmware v1.7.0

1656376795715-436.png

Connection to TF-Luna LiDAR (UART version):

Need to remove R3 and R4 resistors to get low power. Since firmware v1.7.0

1656376865561-355.png

Please use firmware version > 1.6.5 when use MOD=2, in this firmware version, user can use LSn50 v1 to power the ultrasonic sensor directly and with low power consumption.

2.3.3  MOD=3 (3 ADC + I2C)

This mode has total 12 bytes. Include 3 x ADC + 1x I2C

Size(bytes)

2221221
ValueADC(Pin PA0)ADC2(PA1)ADC3 (PA4)

Digital in(PA12)&Digital Interrupt1(PB14)

Temperature(SHT20 or SHT31 or BH1750 Illumination Sensor)Humidity(SHT20 or SHT31)Bat

1656377431497-975.png

2.3.4  MOD=4 (3 x DS18B20)

This mode is supported in firmware version since v1.6.1. Software set to AT+MOD=4

Hardware connection is as below,

( Note:

  • In hardware version v1.x and v2.0 , R3 & R4 should change from 10k to 4.7k ohm to support the other 2 x DS18B20 probes.
  • In hardware version v2.1 no need to change R3 , R4, by default, they are 4.7k ohm already.

See here for hardware changelog.

1656377461619-156.png

This mode has total 11 bytes. As shown below:

Size(bytes)222122
ValueBAT

Temperature1
(DS18B20)
(PB3)

ADCDigital in & Digital InterruptTemperature2
(DS18B20)
(PA9)
Temperature3
(DS18B20)
(PA10)

1656377606181-607.png

2.3.5  MOD=5(Weight Measurement by HX711)

This mode is supported in firmware version since v1.6.2.  Please use v1.6.5 firmware version so user no need to use extra LDO for connection.

 

1656378224664-860.png

Each HX711 need to be calibrated before used. User need to do below two steps:

  1. Zero calibration. Don't put anything on load cell and run AT+WEIGRE to calibrate to Zero gram.
  2. Adjust calibration factor (default value 400): Put a known weight thing on load cell and run AT+WEIGAP to adjust the Calibration Factor.
  3. Remove the limit of plus or minus 5Kg in mode 5, and expand from 2 bytes to 4 bytes(Since its maximum number of bytes is 4 bytes with positive and negative
    So its maximum weight is 2,147,483,647), the unit is g.(Since v1.8.0)

For example:

AT+WEIGAP =403.0

Response:  Weight is 401 g

Check the response of this command and adjust the value to match the real value for thing. 

Size(bytes)

222142
ValueBatTemperature(DS18B20)ADCDigital Input and Digitak InterruptWeightReserved

image-20220820120036-2.png

2.3.6  MOD=6 (Counting Mode, Since firmware v1.6.5)

In this mode, the device will work in counting mode. It counts the interrupt on the interrupt pins and sends the count on TDC time.

Connection is as below. The PIR sensor is a count sensor, it will generate interrupt when people come close or go away. User can replace the PIR sensor with other counting sensors.

1656378351863-572.png

Note: LoRaWAN wireless transmission will infect the PIR sensor. Which cause the counting value increase +1 for every uplink. User can change PIR sensor or put sensor away of the LSN50 to avoid this happen.

           Power loss or restart will reset the count

Size(bytes)22214
ValueBATADCDigital inCount(PB14)

1656378441509-171.png

2.3.7  MOD=7 Three interrupt contact modes (the hardware version needs to support three interrupt versions, Since firmware v1.8.0)

image-20220820140109-3.png

Size(bytes)

2221112
ValueBATTemperature(DS18B20)ADC

Digital in(PA12)&Digital Interrupt1(PB14)

Digital Interrupt2(PB15)Digital Interrupt3(PA4)Reserved

2.3.8  MOD=8 (3ADC+1DS18B20, Since firmware v1.8.0)

Size(bytes)

222122
ValueBATTemperature(DS18B20)

ADC1(PA0)

Digital in
& Digital Interrupt(PB14)

ADC2(PA1)

ADC3(PA4)

image-20220823164903-2.png

2.3.9  MOD=9 3DS18B20+ two Interrupt count mode (the hardware version needs to support 3 interrupt versions, Since firmware v1.8.0)

Note: Power loss or restart will reset the count

Size(bytes)

2221244
ValueBAT

Temperature1(PB3)

Temperature2(PA9)

Digital in
& Digital Interrupt(PA4)

Temperature3(PA10)

Count1(PB14)

Count2(PB15)

image-20220823165322-3.png

The newly added AT command is issued correspondingly:

1. Set Interrupt Mode:

Before using the interrupt function of the INT pin, users can set the interrupt triggering mode as required.

AT Command: AT+INTMODx

AT+INTMODx:

  • AT+INTMOD1   // Set the interrupt mode for  PB14 pin.
  • AT+INTMOD2   // Set the interrupt mode for  PB15 pin.
  • AT+INTMOD3   // Set the interrupt mode for  PA4 pin.

Parameter setting:

  • 0: Disable Interrupt
  • 1: Trigger by rising and falling edge
  • 2: Trigger by falling edge
  • 3: Trigger by rising edge

Example:

  • AT+INTMOD1=0    //Disable the PB14 pin interrupt function
  • AT+INTMOD2=2    //Set the interrupt of the PB15 pin to be triggered by the falling edge
  • AT+INTMOD3=3    //Set the interrupt of the PA4 pin to be triggered by the rising edge

Downlink Command: 0x06 00 aa bb

Format: Command Code (0x06) followed by 3 bytes.

aa: Set the corresponding pin. (00: PB14 Pin;   01PB15 Pin;   02: PA4 Pin.)

bb: Set interrupt mode. (00 Disable, 01 falling or rising, 02 falling, 03 rising)

Example:

  • Downlink Payload: 06 00 00 01     // Equal to AT+INTMOD1=1
  • Downlink Payload: 06 00 01 02     // Equal to AT+INTMOD2=2
  • Downlink Payload: 06 00 02 03     // Equal to AT+INTMOD3=3

 2. Set the counting value:

AT+SETCNT=aa,bb  

When aa is 1, set the count of PB14 pin to BB    Corresponding downlink:09 01 bb bb bb bb

When aa is 2, set the count of PB15 pin to BB    Corresponding downlink:09 02 bb bb bb bb

2.3.10  ​Decode payload in The Things Network

While using TTN V3 network, you can add the payload format to decode the payload.

1656378466788-734.png

The payload decoder function for TTN V3 are here:

2.4  Payload Explanation and Sensor Interface

2.4.1  Battery Info

Check the battery voltage for LSN50.

Ex1: 0x0B45 = 2885mV

Ex2: 0x0B49 = 2889mV

2.4.2  Temperature (DS18B20)

If there is a DS18B20 connected to PB3 pin. The temperature will be uploaded in the payload.

More DS18B20 can check the 3 DS18B20 mode

Connection:

1656378573379-646.png

Example:

If payload is: 0105H:  (0105 & 8000 == 0), temp = 0105H /10 = 26.1 degree

If payload is: FF3FH :  (FF3F & 8000 == 1) , temp = (FF3FH - 65536)/10 = -19.3 degrees.

(FF3F & 8000 : Judge whether the highest bit is 1, when the highest bit is 1, it is negative)

2.4.3  Digital Input

The digital input for pin PA12,

  • When PA12 is high, the bit 1 of payload byte 6 is 1.
  • When PA12 is low, the bit 1 of payload byte 6 is 0.

2.4.4  Analogue Digital Converter (ADC)

The ADC pins in LSN50 can measure range from 0~Vbat, it use reference voltage from STM32. If user need to measure a voltage > VBat, please use resistors to divide this voltage to lower than VBat, otherwise, it may destroy the ADC pin.

Note: minimum VBat is 2.5v, when batrrey lower than this value. Device won't be able to send LoRa Uplink.

The ADC monitors the voltage on the PA0 line, in mV.

Ex: 0x021F = 543mv,

 Example1:  Reading an Oil Sensor (Read a resistance value):

 

image-20220627172409-28.png

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 sensor's two pins to PA0 and PB4.

The equipment circuit is as below:

image-20220627172500-29.png

According to above diagram:

image-20220628091043-4.png

So

image-20220628091344-6.png

image-20220628091621-8.png  is the reading of ADC. So if ADC=0x05DC=0.9 v and VCC (BAT) is 2.9v

The image-20220628091702-9.png  4.5K ohm

Since the Bouy is linear resistance from 10 ~ 70cm.

The position of Bouy is  image-20220628091824-10.png  , from the bottom of Bouy.

2.4.5  Digital Interrupt

Digital Interrupt refers to pin PB14, and there are different trigger methods. When there is a trigger, the LSN50 will send a packet to the server.

 Interrupt connection method:

1656379178634-321.png

Example to use with door sensor : (Requires firmware > 1.5.1)

The door sensor is shown at right. It is a two wire magnetic contact switch used for detecting the open/close status of doors or windows.

1656379210849-860.png

When the two pieces are close to each other, the 2 wire output will be short or open (depending on the type), while if the two pieces are away from each other, the 2 wire output will be the opposite status. So we can use LSN50 interrupt interface to detect the status for the door or window.

 Below is the installation example:

Fix one piece of the magnetic sensor to the door and connect the two pins to LSN50 as follows:

  • One pin to LSN50's PB14 pin

  • The other pin to LSN50's VCC pin

Install the other piece to the door. Find a place where the two pieces will be close to each other when the door is closed. For this particular magnetic sensor, when the door is closed, the output will be short, and PB14 will be at the VCC voltage.

Door sensors have two types:  NC (Normal close) and NO (normal open). The connection for both type sensors are the same. But the decoding for payload are reverse, user need to modify this in the IoT Server decoder.

When door sensor is shorted, there will extra power consumption in the circuit, the extra current is 3v3/R14 = 3v2/1Mohm = 0.3uA which can be ignored.

1656379283019-229.png

The above photos shows the two parts of the magnetic switch fitted to a door.

The software by default uses the falling edge on the signal line as an interrupt. We need to modify it to accept both the rising edge (0v --> VCC , door close) and the falling edge (VCC --> 0v , door open) as the interrupt.

The command is:

AT+INTMOD=1       //(more info about INMOD please refer AT Command Manual)

Below shows some screen captures in TTN V3:

1656379339508-835.png

In MOD=1, user can use byte 6 to see the status for door open or close. TTN V3 decoder is as below:

door= (bytes[6] & 0x80)? "CLOSE":"OPEN";

Notice for hardware version LSN50 v1 < v1.3 (produced before 2018-Nov).

In this hardware version, there is no R14 resistance solder. When use the latest firmware, it should set AT+INTMOD=0 to close the interrupt. If user need to use Interrupt in this hardware version, user need to solder R14 with 10M resistor and C1 (0.1uF) on board.

1656379563303-771.png

2.4.6  I2C Interface (SHT20)

The PB6(SCL) and PB7(SDA) are I2C interface lines. You can use these to connect to an I2C device and get the sensor data.

We have made an example to show how to use the I2C interface to connect to the SHT20 Temperature and Humidity Sensor. This is supported in the stock firmware since v1.5 with AT+MOD=1 (default value).

Notice: Different I2C sensors have different I2C commands set and initiate process, if user want to use other I2C sensors, User need to re-write the source code to support those sensors. SHT20 code in LSN50 will be a good reference.

Below is the connection to SHT20/ SHT31. The connection is as below:

image-20220902163605-2.png

The device will be able to get the I2C sensor data now and upload to IoT Server.

1656379664142-345.png

Convert the read byte to decimal and divide it by ten.

Example:

Temperature:  Read:0116(H) = 278(D)  Value:  278 /10=27.8℃;

Humidity:    Read:0248(H)=584(D)       Value:  584 / 10=58.4, So 58.4%

If you want to use other I2C device, please refer the SHT20 part source code as reference.

2.4.7  ​Distance Reading

Refer Ultrasonic Sensor section.

2.4.8  Ultrasonic Sensor

The LSN50 v1.5 firmware supports ultrasonic sensor (with AT+MOD=2) such as SEN0208 from DF-Robot. This Fundamental Principles of this sensor can be found at this link: https://wiki.dfrobot.com/Weather_-_proof_Ultrasonic_Sensor_with_Separate_Probe_SKU___SEN0208

The LSN50 detects the pulse width of the sensor and converts it to mm output. The accuracy will be within 1 centimeter. The usable range (the distance between the ultrasonic probe and the measured object) is between 24cm and 600cm.

The picture below shows the connection:

1656380061365-178.png

Connect to the LSN50 and run AT+MOD=2 to switch to ultrasonic mode (ULT).

The ultrasonic sensor uses the 8th and 9th byte for the measurement value.

Example:

Distance:  Read: 0C2D(Hex) = 3117(D)  Value:  3117 mm=311.7 cm

1656384895430-327.png

1656384913616-455.png

You can see the serial output in ULT mode as below:

1656384939855-223.png

In TTN V3 server:

1656384961830-307.png

1656384973646-598.png

2.4.9  Battery Output - VDD pin

The VDD pin of LSN50v2 is connected to the Battery directly. If users want to use VDD pin to power an external sensor. User need to make sure the external sensor is of low power consumption. Because the VDD pin is always open. If the external sensor is of high power consumption. the battery of LSN50v2 will run out very soon.

2.4.10  +5V Output

Since v1.2 hardware version, a +5v output is added in the hardware. The +5V output will be valid for every sampling.  LSN50 will enable +5V output before all sampling and disable the +5v after all sampling.  

Since firmware v1.6.3, The 5V output time can be controlled by AT Command.

AT+5VT=1000

Means set 5V valid time to have 1000ms. So the real 5V output will actually have 1000ms + sampling time for other sensors.

By default the AT+5VT=500. If the external sensor which require 5v and require more time to get stable state, user can use this command to increase the power ON duration for this sensor.

2.4.11  Weigh Sensor HX711

Since v1.6.2 firmware, LSN50 support Weigh Sensor HX711.

2.4.12  BH1750 Illumination Sensor

Since v1.7.0 firmware, MOD=1 support this sensor. The sensor value is in the 8th and 9th bytes.

image-20220628110012-11.jpeg

image-20220628110012-12.png

2.4.13  Working MOD

The working MOD info is contained in the Digital in & Digital Interrupt byte (7th Byte).

User can use the 3rd ~ 7th   bit of this byte to see the working mod:

Case 7th Byte >> 2 & 0x1f:

  • 0: MOD1
  • 1: MOD2
  • 2: MOD3
  • 3: MOD4
  • 4: MOD5
  • 5: MOD6

User can configure LSN50 via AT Commands or LoRaWAN Downlink Commands

There are two kinds of Commands:

  • Common Commands: They should be available for each sensor, such as: change uplink interval, reset device. For firmware v1.7.0, user can find what common commands it supports:  End Device AT Commands 
  • Sensor Related Commands: These commands are special designed for LSN50.  User can see these commands below:

2.5.1  Common Commands:

They should be available for each of Dragino Sensors, such as: change uplink interval, reset device. For firmware v1.7.0, user can find what common commands it supports: End Device AT Commands

2.5.2  Sensor related commands:

Set work mode:

  • AT Command:

       AT+MOD=2        // Set work MOD =2. (1: IIC mode, 2: Distance mode, 3: 3ADC mode, 4: 3DS18B20 mode, 5: weight mode)

       AT+MOD=?      //  Get current work MOD

  • Downlink Payload:

0x0A aa     // Same as AT+MOD=aa

Set the trigger interrupt mode:

  • AT Command:

       AT+INTMOD=2        // Set INTMOD =2. (0: Disable, 1:falling or rising, 2: falling, 3: rising)

       AT+INTMOD=?      //  Get current INTMOD

  • Downlink Payload:

0x06 000003             // Set AT+INTMOD=3

Set the 5V power open time during sampling:

  • AT Command:

       AT+5VT=1000     // Set 5v open time to 1000ms

       AT+5VT=?          //  Check current 5v open duration

  • Downlink Payload:

0x07 aa bb            // Equal AT+5VT=0x(aa bb)

Set the weight to 0g (Zero Calibration):

  • AT Command:

AT+WEIGRE       // Set the weight to 0g

  • Downlink Payload:

0x08 01         // Set the weight to 0g

Get or Set the GAP Value (calibrate factor) of measurement:

  • AT Command:

       AT+WEIGAP=403.0       // Set GAP Value =403.0  (response: Weight: xx g)

       AT+WEIGAP=?            //  Get current GAP Value

  • Downlink Payload:

0x08 02 aa bb         // Equal to AT+WEIGAP=0x(aa bb)/10

Encrypt upload:

  • AT Command:

       AT+DECRYPT=1       // The payload is uploaded without encryption

       AT+DECRYPT=0       //  Encrypt when uploading payload (default)

Get data:

  • AT Command:

       AT+GETSENSORVALUE=0      // The serial port gets the reading of the current sensor

       AT+GETSENSORVALUE=1      //  The serial port gets the current sensor reading and uploads it.

Resets the downlink packet count:

  • AT Command:

       AT+DISFCNTCHECK=0      // When the downlink packet count sent by the server is less than the node downlink packet count or exceeds 16384, the node will no longer receive downlink packets (default)

       AT+DISFCNTCHECK=1      //  When the downlink packet count sent by the server is less than the node downlink packet count or exceeds 16384, the node resets the downlink packet count and keeps it consistent with the server downlink packet count

When the limit bytes are exceeded, upload in batches:

  • AT Command:

       AT+DISMACANS=0     // When the MACANS of the reply server plus the payload exceeds the maximum number of bytes of 11 bytes (DR0 of US915, DR2 of AS923, DR2 of AU195), the node will send a packet with a payload of 00 and a port of 4. (default)

       AT+DISMACANS=1      // When the MACANS of the reply server plus the payload exceeds the maximum number of bytes of the DR, the node will ignore the MACANS and not reply, and only upload the payload part.

  • Downlink Payload:

0x21 00 01          // Set  the DISMACANS=1

Copy downlink to uplink:

  • AT Command:

       AT+RPL=5       // After receiving the package from the server, it will immediately upload the content of the package to the server, the port number is 100.

Example: aa xx xx xx xx         // aa indicates whether the configuration has changed, 00 is yes, 01 is no; xx xx xx xx are the bytes sent.

image-20220823173747-6.png

For example, sending 11 22 33 44 55 66 77 will return invalid configuration 00 11 22 33 44 55 66 77.

image-20220823173833-7.png

For example, if 01 00 02 58 is issued, a valid configuration of 01 01 00 02 58 will be returned.

Query version number and frequency band 、TDC:

  • Downlink: 26 01     //  Downlink 26 01 can query device upload frequency, frequency band, software version number, TDC time.

Example:

image-20220823173929-8.png

Add rejoin feature if device offline: (Since V1.8.0)

  • AT Command:

AT+DDETECT=<Flag>,<ACK_Timout_1>,<ACK_Timout_2>    (Default Value: AT+DDETECT=1,1440,2880)

Flag:   1 Enable online detect, 0: Disable online detect

ACK_Timout_1:  Unit: min

ACK_Timout_2:  Unit: min

Example: AT+DDETECT=1,1440,2880

Enable Online Detect, if end node doesn't receive any downlink within ACK_Timout_1( 1440 minutes or 24 hours). End node will use confirmed uplink to send packets during ACK_Timout_1 (the 24th hour) to ACK_Timout_2 ( the 48th hour).

If from the 24th to 48th hour, end node got an downlink from server, it will switch back to unconfirmed uplink. end node will restart ACK_Timout_1.

If from the 24th to 48th hour, end node still not got any downlink, means device doesn't get ACK in 48 hours. Device will process rejoin, rejoin request interval is AT+RJTDC period. For AU915/ US915, device will use the sub-band used for last join. 

  • Downlink: 0x32 01 05A0 0B40 

    0x01 : Flag

    0x05A0: ACK_Timout_1

    0x0B40: ACK_Timout_2

     

Add new feature to control NBTrans for unconfirmed uplink mode:

  • AT Command:

 AT+SETMAXNBTRANS=value1,value2         // NBTrans specified how many re-transmission for each packet. If LoRaWAN LinkADR from server set NBTrans to high value. The battery will consume fast. 

AT+SETMAXNBTRANS=value1,value2    Default Value: AT+SETMAXNBTRANS=1,0

value1:  Set max NBTrans. For example, if value1(NBTrans)=1, end node set NBTrans max to 1 , even downlink LinkADR request end node to set NBTrans to higher value such as 6. 

value2:  0: uplink fcnt doesn't change for each NBTrans;  1: uplink fcnt increase by 1 for each NBTrans.

set value2 to 1 for Chirpstack server, because Chirpstack will ignore same FCNT in re-transmission.

Example: AT+SETMAXNBTRANS=2,1

Set max NBTrans to 2, fcnt will increase +1 for each NBTrans

  • Downlink: 0x33 02 01

    value1=0x02

          value2=0x01

2.6  Show Data in Datacake IoT Server

Datacake provides a human friendly interface to show the sensor data, once we have data in TTN V3, we can use Datacake to connect to TTN V3 and see the data in Datacake. Below are the steps:

Step 1: Be sure that your device is programmed and properly connected to the network at this time.

Step 2: To configure the Application to forward data to Datacake you will need to add integration. To add the Datacake integration, perform the following steps:

1656385623971-339.png

1656385646347-395.png

1656385662459-942.png

Step 3Create an account or log in Datacake.

Step 4: Search the LSN50 and add DevEUI.

1656385688973-317.png

2.7  ​Firmware Change Log

2.8  Use VDD or +5V to Power External Sensor

User can use VDD or +5V to power external sensor.

Note:

  1. VDD is 2.5~3.3v from the battery + diode, the VDD is always on, so when use VDD to power external sensor, make sure the sensor has a low power consumption in sleep mode ( less 50 uA) to get a long battery life.

  2. +5V output is only ON when sampling. And MCU will turn off it after sampling. So if sensor can support 5v, +5V out is the best choice. See here for more info.

Note: Always test the actually current pass by the JP2 jumper when connect to a new type of sensor.

2.9  Battery & Power Consumption

LSN50v2 uses ER26500 + SPC1520 battery pack. See below link for detail information about the battery info and how to replace.

Battery Info & Power Consumption Analyze .

3.  Using the AT Commands

3.1  Access AT Commands

LSN50 supports AT Command set in the stock firmware. You can use a USB to TTL adapter to connect to LSN50 for using AT command, as below.

LSN50 v1 UART connection photo

image-20220627165424-24.png

LSN50 v2 UART connection photo

image-20220627165424-25.png

In the PC, you need to set the serial baud rate to 9600 to access the serial console for LSN50. LSN50 will output system info once power on as below:

 image-20220627165531-26.png  

3.2  Common AT Command Sequence

3.2.1  Multi-channel ABP mode (Use with SX1301/LG308)

If device has not joined network via OTAA:

AT+FDR

AT+NJM=0

ATZ

If device already joined network:

AT+NJM=0

ATZ

3.2.2  Single-channel ABP mode (Use with LG01/LG02)

See Sect 6.7

4.  Upload Firmware

Notes:

  • Since image v1.3, the firmware will show version info during boot. If your device doesn't show version info, you may have a very old image version.
  • Always run AT+FDR to reset parameters to factory default after an update image.
    If the update is from image >= v1.3 to another image version >=v1.3, then the keys will be kept after running AT+FDR.
    Otherwise (e.g. from v1.2 to v1.3), AT+FDR may erase the keys.

4.1  Upload Firmware via Serial Port

The LSN50's AT Command port can be used for firmware upgrade. The hardware connection for upgrade firmware is as below:

image-20220627163506-18.png

Step1: Download flash loader.

Step2: Download the LSN50 Image files.

Step3Open flashloader; choose the correct COM port to update

image-20220627163821-19.png

image-20220627163930-20.png

image-20220627164030-21.png

Step4Switch SW1 back to flash state and push the RESET button.

The LSN50 will then run the new firmware.

4.2  Upload Firmware via ST-Link V2

You can use ST-LINK to upgrade firmware into LSN50. The hardware connection for upgrade firmware is as below:

1656319349131-664.png

Connection:

  • ST-LINK v2 GND     <--> LSN50 GND
  • ST-LINK v2 SWCLK <--> LSN50 PA14
  • ST-LINK v2 SWDIO <--> LSN50 PA13
  • ST-LINK v2 RST      <-->  LSN50 NRST

Step1: Install ST-LINK driver first and then install ST-LINK Utility

Step2: Download the LSN50 Image files.

Step3: Open ST-LINK utility, file --> open file to select the image to be upgraded. 

Step4: Click the “Program Verify button on ST-LINK.

image-20220627164303-22.png

Step5: The led on the ST-LINK adapter will now blinking, and the ST-Link utility will pop up a download window. Click the start button to download the image to LSN50.

NOTE: If this step fails, ST-LINK can't establish connection to LSN50, please try to swap SWDIO & SWCLK pin. Some ST-LINK v2 devices are incorrectly marked.

image-20220627164303-23.png

5.  Developer Guide

LSN50 is an open source project, developer can use compile their firmware for customized applications. User can get the source code from:

Use Keil to open project file:

STM32CubeExpansion_LRWAN/Projects/Multi/Applications/LoRa/DRAGINO-LRWAN(AT)/MDK-ARM/STM32L072CZ-Nucleo/Lora.uvprojx

 

In Keil, you can see what frequency band the code support.

image-20220627162417-15.png

1. If you want to change frequency, modify the Preprocessor Symbols.

For example, change EU868 to US915

1656318662202-530.png

2. Compile and build

image-20220627163212-17.png

6.  FAQ

6.1  Why there is 433/868/915 version?

Different countries have different rules for the ISM band for LoRa. Although the LoRa chip can support a wide range of Frequencies, we provide different versions of the hardware for best tune of the LoRa hardware part.

6.2  What is the frequency range of LT LoRa part?

Different LT version supports different frequency range, below is the table for the working frequency and recommend bands for each model:

image-20220627155456-9.png

6.3  How to change the LoRa Frequency Bands/Region?

You can follow the instructions for how to upgrade image.
When downloading the images, choose the required image file for download.

6.4  Can I use Private LoRa protocol?

The stock firmware is based on LoRaWAN protocol. You can use a private LoRa protocol in LSN50. This section describes an example for base LoRa transfer. It is a reference/demo and we do not provide further software development support on this topic.

In this demo, we will show the communication between LoRa Shield and LSN50, both of them using the basic LoRa library. LSN50 will send a message to a LoRa Shield and the LoRa Shield will print it to the console.

 

LoRa Shield + UNO:

Use the LoRa Library and upload the LoRa Receive Sketch to Arduino.

Refs:  https://www.dropbox.com/sh/u9s41qdx5yujwcb/AAAT5r4QkMaeOogWrzJt7Wn4a?dl=0

Open the serial monitor to Arduino. The device acts as a LoRa Receiver and listen on the frequency 868.3Mhz by default.

LSN50:

Use the <LoRa RAW code> . The project file is in: MDK-ARM\STM32L072CZ-Nucleo\ Lora.uvprojx

Compile it and Upload it to LSN50, the LSN50 will transfer on the frequency 868.3Mhz.

In the Arduino Console, it will see the received packets as below.

image-20220627160116-10.png

6.5  How to set up LSN50 to work in 8 channel mode

By default, the frequency bands US915, AU915, CN470 work in 72 frequencies. Many gateways are 8 channel gateways, and in this case, the OTAA join time and uplink schedule is long and unpredictable while the end node is hopping in 72 frequencies.

You can configure the end node to work in 8 channel mode by using the AT+CHE command. The 500kHz channels are always included for OTAA.

 

For example, in US915 band, the frequency table is as below. By default, the end node will use all channels (0~71) for OTAA Join process. After the OTAA Join, the end node will use these all channels (0~71) to send uplink packets.

image-20220627160940-13.png

When you use the TTN V3 network, the US915 frequency bands use are:

  • 903.9 - SF7BW125 to SF10BW125

  • 904.1 - SF7BW125 to SF10BW125

  • 904.3 - SF7BW125 to SF10BW125

  • 904.5 - SF7BW125 to SF10BW125

  • 904.7 - SF7BW125 to SF10BW125

  • 904.9 - SF7BW125 to SF10BW125

  • 905.1 - SF7BW125 to SF10BW125

  • 905.3 - SF7BW125 to SF10BW125

  • 904.6 - SF8BW500

Because the end node is now hopping in 72 frequency, it makes it difficult for the devices to Join the TTN V3 network and uplink data. To solve this issue, you can access the device via the AT commands and run:

AT+CHE=2

ATZ

to set the end node to work in 8 channel mode. The device will work in Channel 8-15 & 64-71 for OTAA, and channel 8-15 for Uplink.

The AU915 band is similar. Below are the AU915 Uplink Channels.

image-20220627161124-14.png

6.6  How to set up LSN50 to work with Single Channel Gateway such as LG01/LG02?

In this case, users need to set LSN50 to work in ABP mode and transmit in only one frequency.

Assume we have a LG02 working in the frequency 868400000 now, below is the steps.

Step1: Log in TTN V3, Create an ABP device in the application and input the network session key (NETSKEY), app session key (APPSKEY) from the device.

image-20220627160542-11.png

Note: You need to make sure the above three keys match in the device and in TTN V3. You can change them either in TTN V3 or in the Device to make them match. In TTN V3, NETSKEY and APPSKEY can be configured in the setting page, but the Device Addr is generated by TTN V3.

You can also change the Device ADDR in TTN V3 by using the The Things Network CLI.

Step2:  Run AT commands to make the LSN50 work in Single frequency and ABP mode. Below are the AT commands:

AT+FDR   :    Reset Parameters to Factory Default, Keys Reserve

AT+NJM=0 : Set to ABP mode

AT+ADR=0 : Set the Adaptive Data Rate Off

AT+DR=5   : Set Data Rate (Set AT+DR=3 for 915 band)

AT+TDC=300000  :      Set transmit interval to 5 minutes

AT+CHS=868400000 : Set transmit frequency to 868.4Mhz

AT+DADDR=26 01 1A F1  :Set Device Address to 26 01 1A F1

ATZ      :                               Reset MCU

As shown  below:

image-20220627160542-12.png

6.7  How to configure the EUI keys in LSN50?

The early version of LSN50 firmware doesn't have pre-configured keys.
It is recommended that you update the image to the latest version before configure the keys. Refer upgrade_image to update the firmware to the latest version.

Run AT commands to set the keys to desired keys; refer AT Command manual

 

6.8 Why can't users switch working modes?

LSN50v2 and LSNS0v2-S31B use different firmware. If the user purchased LSN50V2-S31B, the working mode cannot be switched according to this manual.

LSN50v2 and LSN50V2-S31b use the same motherboard, users can refer to the following burning instructions to change the LSN50V2-S31B firmware to LSN50v2.

Firmware Upgrade Instruction for STM32 base products - DRAGINO

 

7.  Trouble Shooting

7.1  Connection problem when uploading firmware.

Issue: While using USB to TTL to upload firmware via UART interface. It works for several times but most of times it fails.

 

Checklist:

1. Double check if follow up exactly the steps as manual.

2. Check if hardware works fine: a) check if AT command works, b) check if ISP / flash switch works: PA12 will have different output level while set the ISP/Flash Switch in different position. c) check if reset button works.

3. If you use Windows10 system. Please change the flash loader to run in Windows7 compatibility mode.

image-20220627153421-8.png

4. We have seen cases where the FT232 USB TTL adapter has a reliability issue with the PC USB chipset (Intel). In this case, even though points 1 and 2 above work, it still has a reliability issue for uploading. If this happens, change to a different PC or change the USB to TTL adapter to solve the issue.

7.2  Why I can't join TTN V3 in US915 / AU915 bands?

It is due to channel mapping. Please see the Eight Channel Mode section above for details. 

7.3  AT Command input doesn't work

In the case if user can see the console output but can't type input to the device. Please check if you already include the ENTER while sending out the command. Some serial tool doesn't send ENTER while press the send key, user need to add ENTER in their string. 

8.  Order Info

Part Number: LSN50-XX-YY  or  LSN50v2-XX-YY-ZZ

XX: The default frequency band

  • AS923 : LoRaWAN AS923 band
  • AU915 : LoRaWAN AU915 band
  • EU433 : LoRaWAN EU433 band
  • EU868 : LoRaWAN EU868 band
  • KR920 : LoRaWAN KR920 band
  • US915 : LoRaWAN US915 band
  • IN865 :  LoRaWAN IN865 band
  • CN470 : LoRaWAN CN470 band

YYHole Option

  • 12: With M12 waterproof cable hole
  • 16: With M16 waterproof cable hole
  • 20: With M20 waterproof cable hole (LSN50 v2 doesn't have this version)
  • NH: No Hole

ZZBattery Option ( Only valid for v2 model)

  • 4: with 4000mAh battery
  • 8: with 8500mAg battery

9. ​ Packing Info

For LSN50:

Package Includes:

  • LSN50 LoRa Sensor Node x 1

Dimension and weight:

  • Device Size: 8 x 6.5 x 5 cm
  • Device Weight: 137g
  • Package Size / pcs : 9 x 7 x 6cm
  • Weight / pcs : 160g

For LSN50 v2:

Package Includes:

  • LSN50v2 LoRa Sensor Node x 1
  • External antenna x 1
  • Spring Antenna (evaluate purpose)

Dimension and weight:

  • Device Size: 9.7 x 6.5 x 4.7 cm
  • Device Weight: 150g
  • Package Size / pcs : 14.0 x 8x 5 cm
  • Weight / pcs : 180g

10.  ​Support

  • Support is provided Monday to Friday, from 09:00 to 18:00 GMT+8. Due to different timezones we cannot offer live support. However, your questions will be answered as soon as possible in the before-mentioned schedule.
  • Provide as much information as possible regarding your enquiry (product models, accurately describe your problem and steps to replicate it etc) and send a mail to support@dragino.com.

11.  References

Tags:
    
Copyright ©2010-2024 Dragino Technology Co., LTD. All rights reserved
Dragino Wiki v2.0