www.dragino.com LSN50 LoRa Sensor Node User Manual Document Version: 1.6.4 Image Version: v1.6.3 Version 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 Description Release Add steps of install STM320x; Add ST-Link Upload firmware method Add trouble shooting for UART upload, Add change log for firmware v1.
www.dragino.com 1. Introduction 1.1 What is LSN50 LoRa Sensor Node 1.2 Specifications 1.3 Features 1.4 Applications 1.5 Pin Definitions 1.6 Hardware Change log 1.7 Hole Option 2. Use LSN50 with LoRaWAN firmware 2.1 How it works 2.2 Quick guide to connect to LoRaWAN server (OTAA) 2.3 Working Mode & Uplink Payload 2.3.1 MOD=1 (Default Mode) 2.3.2 MOD=2 (Distance Mode) 2.3.3 MOD=3 (3 ADC + I2C) 2.3.4 MOD=4 (3 x DS18B20) 2.3.5 MOD=5(Weight Measurement by HX711) 2.3.6 Decode payload in The Things Network 2.
www.dragino.com 6. FAQ 6.1 Why there is 433/868/915 version? 6.2 What is the frequency range of LT LoRa part? 6.3 How to change the LoRa Frequency Bands/Region? 6.4 Can I use Private LoRa protocol? 6.5 How to set up LSN50 to work with Single Channel Gateway such as LG01/LG02? 6.6 How to configure the EUI keys in LSN50? 7. Trouble Shooting 7.1 Connection problem when uploading firmware. 7.2 Why I can’t join TTN in US915 / AU915 bands? 7.3 AT Command input doesn’t work 8. Order Info 9. Packing Info 10.
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.
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): 902 ~ 928Mhz ● ● ● ● ● ● ● ● ● ● ● ● ● Battery: ● ● ● ● ● Programmable bit rate up to 300 kbps. High sensitivity: down to -148 dBm. Bullet-proof front end: IIP3 = -12.5 dBm.
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.
www.dragino.com 1.5 Pin Definitions No. Signal Direction Function Remark 1 VCC(2.
www.dragino.com 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 13 VCC(2.
www.dragino.com LSN50 v1.2: Add LED.
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.
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.
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.
www.dragino.com You can enter this key in the LoRaWAN Server portal.
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.
www.dragino.com 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.
www.dragino.com 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.
www.dragino.com 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.
www.dragino.com 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.
www.dragino.com 2.3.5 MOD=5(Weight Measurement by HX711) This mode is supported in firmware version since v1.6.2. Notes about hardware connection: 1) Don’t connect the HX711 module VCC to LSN50 3.3v VCC, in this case, the LSn50 will always power on HX711 and the battery will run out soon. 2) HX711 support 5v VCC, but while connect the LSN50’s +5V to HX711 VCC, the value from HX711 is not stable. 3) Connect LSn50 +5V to HX711 VCC via a LDO module is stable. Each HX711 need to be calibrated before used.
www.dragino.com 2.3.6 Decode payload in The Things Network While using TTN network, you can add the payload format to decode the payload. The payload decoder function for TTN are here: LSN50 TTN Payload Decoder: http://www.dragino.
www.dragino.com 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 Example: If payload is: 0105H: (0105 & FC00 == 0), temp = 0105H /10 = 26.1 degree If payload is: FF3FH : (FF3F & FC00 == 1) , temp = (FF3FH - 65536)/10 = -19.3 degrees. 2.4.
www.dragino.com 2.4.4 Analogue Digital Converter (ADC) The ADC monitors the voltage on the PA0 line, in mV. Ex: 0x021F = 543mv, Example1: Reading an Oil Sensor (Read a resistance value): * 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.
www.dragino.com According to above diagram: ( 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 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. Example to use with door sensor (Requires firmware > 1.5.1) The door sensor is shown at right.
www.dragino.com 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.
www.dragino.com 2.4.6 I2C Interface (SHT20) The PB6(SDA) and PB7(SCK) 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). Below is the connection to SHT20. The device will be able to get the I2C sensor data now and upload to IoT Server.
www.dragino.com 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.
www.dragino.com You can see the serial output in ULT mode as below: In TTN server: 2.4.9 +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.
www.dragino.
www.dragino.com 2.5 Downlink Payload By default, LSN50 prints the downlink payload to console port. Downlink Control Type TDC (Transmit Time Interval) RESET AT+CFM INTMOD FPort Any Any Any Any Type Code 01 04 05 06 Downlink payload size(bytes) 4 2 4 4 Examples Set TDC If the payload=0100003C, it means set the END Node’s TDC to 0x00003C=60(S), while type code is 01.
www.dragino.com 2.6 Show Data in Mydevices IoT Server Mydevices provides a human friendly interface to show the sensor data, once we have data in TTN, we can use Mydevices to connect to TTN and see the data in Mydevices. 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 Mydevices you will need to add integration.
www.dragino.com Step 3: Create an account or log in Mydevices. Step 4: Search the LSN50 and add DevEUI. Use the LSN50 v1.6+ for the firmware version > v1.6 under LoRa --> The things network After added, the sensor data arrive TTN, it will also arrive and show in Mydevices.
www.dragino.com MOD=3.
www.dragino.com 2.7 Firmware Change Log Firmware download link V1.6.3 Firmware(Not Release) Add AT+5VT command to control 5v output time. Fix payload order error generate in v1.6.2 V1.6.2 Firmware Add mode 5: weight mode by HX711 sensor Update LoRaWAN stack to DR-LWS-002 V1.6.1 Firmware: Add 3 x DS18B20 mod V1.6 Firmware: Improve Interrupt feature. Downlink to change AT+CFM. Downlink to change AT+INTMOD Add 3ADC + I2C mode. Fix power consumption bug in v1.5.
www.dragino.com V1.2 Firmware: Support Class C After the configuration key can be stored in. No need to configure again even after power off. Add auto send feature after power on Solve negative temperature issue. Support Mydevices_LPP payload, user need to recompile firmware again. V1.1 Firmware: Support Battery Voltage(mV) ,the data of Oil Sensor ,the data of DS18B20, Digital I/0, ADC_IN1(PA1), Proximity switch, I2C Device Example V1.
www.dragino.com 2.8 Battery Analysis 2.8.1 Battery Type The LSN50 battery is a combination of a 4000mAh Li/SOCI2 Battery and a Super Capacitor. The battery is non-rechargeable battery type with a low discharge rate (<2% per year). This type of battery is commonly used in IoT devices such as water meter. The battery is designed to last for more than 5 years for the LSN50.
www.dragino.com 2. 3. Sampling current while reading DS18B20 and Oil Sensor ● Oil Sensor sampling time: 200us, current: 0.3mA ● DS18B20 sampling time: 750ms, current: 0.64mA ● Above power should add 8mA CPU power in working mode. LoRaWAN transmit and receive time consumption. The LoRa TX / RX time and power can be found in the LoRa calculator tool. In a typical LoRaWAN data transmit.
www.dragino.com Note: Ignore the 18 year result, because the battery has a max 2% discharge per year. 2.8.3 Battery Note The Li-SICO battery is designed for small current / long period application. It is not good to use a high current, short period transmit method. The recommended minimum period for use of this battery is 5 minutes. If you use a shorter period time to transmit LoRa, then the battery life may be decreased. 2.8.4 Replace the battery You can change the battery in the LSN50.
www.dragino.com In the PC, you need to set the serial baud rate to 9600 to access the serial console for LSN50.
www.dragino.com (http://www.dragino.com/downloads/index.php?dir=LSN50LoRaST/&file=DRAGINO_STM_AT_Commands_v1.3.
www.dragino.com AT+CHE : Get or Set eight channels mode, Only for US915, AU915, CN470 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.
www.dragino.com 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.
www.dragino.
www.dragino.com Step4: Switch SW1 back to flash state and push the RESET button. The LSN50 will then run the new firmware.
www.dragino.com 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: 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.
www.dragino.com 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.
www.dragino.com 5. Developer Guide Software Source Code Download Link. (https://github.com/dragino/LoRa_STM32/tree/master/STM32CubeExpansion_LRWAN) Hardware Source Code Download Link (https://github.com/dragino/Lora/tree/master/LSN50) LSN50 is an open source project, developer can use compile their firmware for customized applications. User can get the source code from: Software Source Code: https://github.
www.dragino.com 2.
www.dragino.com 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.
www.dragino.com LoRa Shield + UNO: Use the LoRa Library and upload the LoRa_Receive Sketch to Arduino. Refs: http://www.dragino.com/downloads/index.php?dir=LSN50-LoRaST/LoRa_Raw_Example/Arduino/&file=LoRa.zip http://www.dragino.com/downloads/downloads/LSN50-LoRaST/LoRa_Raw_Example/Arduino/LoRaReceiver.ino 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 . The project file is in: MDK-ARM\STM32L072CZ-Nucleo
www.dragino.com Note: You need to make sure the above three keys match in the device and in TTN. You can change them either in TTN or in the Device to make them match. In TTN, NETSKEY and APPSKEY can be configured in the setting page, but the Device Addr is generated by TTN. You can also change the Device ADDR in TTN by using the The Things Network CLI.
www.dragino.com 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: 6.
www.dragino.com 7. Trouble Shooting 7.1 Connection problem when uploading firmware. Please refer to this link: http://wiki.dragino.com/index.php?title=Firmware_Upgrade_Instruction_for_STM32 _base_products . 7.2 Why I can’t join TTN in US915 / AU915 bands? Might relate to this: http://wiki.dragino.com/index.php?title=LoRaWAN_Communication_Debug#Notice_ of_US915.2FCN470.
www.dragino.com 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.
www.dragino.com 8. Order Info Part Number: LSN50-XX-YY or LSN50-v2-XX-YY 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 YY: ● ● ● ● 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 9.
www.dragino.com 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 Product Page (http://www.dragino.