www.dragino.com LG01 LoRa Gateway User Manual Document Version: 1.3 Firmware Version: IoT Mesh v4.3.0 Version Description Date 0.1 Initiate 2016-Oct-29 1.0 Release, Add ThingSpeak Examples 2016-Dec-9 1.1 Add Example List for connecting to TTN 2017-May-17 1.2 Add Link for RN2483 Support, OLG01 Antenna description , modify fallback ip 2017-Sep-7 description, Add More FAQ links, Console README, Web update sketch, Add Hardware Source code 1.
www.dragino.com Index: 1. Introduction ............................................................................................................ 5 1.1 What is LG01 ............................................................................................. 5 1.2 Specifications ............................................................................................ 5 1.3 Features..................................................................................................... 8 1.
www.dragino.com 8. 9. 10. 11. 12. 13. 7.1 Upgrade via Web UI ................................................................................ 37 7.2 Upgrade via Linux console ...................................................................... 37 Upgrade Micro Controller Sketch.......................................................................... 38 8.1 Upgrade Sketch via Arduino IDE ............................................................. 38 8.2 Upgrade Sketch via Web UI .................
www.dragino.com 14. 15. 16. 17. 13.3 Arduino IDE doesn’t detect LG01 ............................................................ 62 13.4 I get kernel error when install new package, how to fix? ....................... 62 13.5 How to recover the LG01 if firmware crash ............................................ 63 13.6 I configured LG01 for WiFi access and lost its IP. What to do now? ....... 64 Order Info ...................................................................................................
www.dragino.com 1. Introduction 1.1 What is LG01 The LG01 is an open source single channel LoRa Gateway. It lets you bridge LoRa wireless network to an IP network base on WiFi, Ethernet, 3G or 4G cellular. LG01 runs on open source embedded Linux system; it has USB host port and has full Ethernet and 802.11 b/g/n WiFi capabilities. The USB host port can be used to connect cellular modules so LG01 is very flexible to bridge LoRa Network to different kinds of network to fit user’s requirement.
www.dragino.com IEEE 802.11 b/g/n Frenquency Band: 2.4 ~ 2.462GHz Tx power: 11n tx power : mcs7/15: 11db 11b tx power: 18db 11g 54M tx power: 12db 11g 6M tx power: 18db mcs0 : 17db Wifi Sensitivity 11g 54M : -71dbm 11n 20M : -67dbm LoRa Spec: Frequency Range: Band 1 (HF): 862 ~ 1020 Mhz Band 2 (LF): 410 ~ 528 Mhz 168 dB maximum link budget. +20 dBm - 100 mW constant RF output vs. +14 dBm high efficiency PA.
www.dragino.com Quectel UC20 LTE module Micro SIM Slot Internal 3G/4G Antenna + External 3G/4G Sticker Antenna. Up to 14.4Mbps downlink and 5.
www.dragino.com 1.3 Features Open source Linux (OpenWrt) inside. User can modify or compile the firmware with custom features and own brand. Low power consumption. Compatible with Arduino IDE 1.5.4 or later, user can program, debug or upload sketch to the MCU via Arduino IDE. 1.4 Managed by Web GUI, SSH via LAN or WiFi. Software upgradable via network. Auto-Provisioning. Built-in web server. Support internet connection via LAN port, WiFi or 3G /4G dongle.
www.dragino.com 1.
www.dragino.com 1.6 Hardware Variants There are different LG01 variants for difference applications. Below table shows the difference between these models. Model LG01-P LG01-S Photo Description The most general version can be used as a LoRa Gateway. Include screw terminal which can connect to external sensors Outdoor version, this version doesn’t include LoRa OLG01 antenna, instead, it has a SMA connector, user can connect it to a high gain LoRa antenna.
www.dragino.com 2. Quick Start Guide 2.1 Access and config LG01 The LG01 is configured as a WiFi AP by factory default. User can access and configure the LG01 after connect to its WiFi network. At the first boot of LG01, it will auto generate an unsecure WiFi network call dragino2-xxxxxx User can use the laptop to connect to this WiFi network. The laptop will get an IP address 10.130.1.xxx and the LG01 has the default IP 10.130.1.1 Open a browser in the laptop and type 10.130.1.
www.dragino.com 2.2 Program microcontroller. The MCU (microcontroller) M328P is used to communicate with LoRa Radio part and Dragino Linux module. The program language for the MCU is based on C and program tool is Arduino IDE. Below the way shows how to do program it. 2.2.1 Download and configure Arduino IDE Download the latest Arduino Software(IDE) from Arduino official site: https://www.arduino.
www.dragino.com After install Dragino’s board info in the IDE, we can see the boards info from the IDE, as below screenshot. For LG01, we should choose: Dragino Yun-UNO or LG01/OLG01. Note: If user has trouble to install via Board Manager. User can manually add the board profile.
www.dragino.com 2.2.2 Upload a sketch in the MCU For the very start, we can try to upload a simple sketch to the MCU and see how it works. Make sure your computer and the LG01 is in the same network, if you already connect to the LG01 WiFi SSID, then both devices are in the same WiFi network. In the IDE, select the correct port as below screenshot.
www.dragino.com Check result The blink sketch will set the A2 pin of the MCU to periodically high and low. This pin connects to the HEART LED of the LG01. So if successfully upload this sketch, user can see the HEART LED turn on and turn off periodically.
www.dragino.com 2.3 Simple LoRa wireless example To test LoRa wireless, we at least need 2 devices both support LoRa. In this example we will use below devices: LoRa Gateway: LG01 ; LoRa Client: LoRa Shield + Arduino Uno In this example, we will show the basic LoRa Communication: The LoRa Client will broadcast a data via LoRa wireless, the LG01 gateway will get this data and show the data in the PC.
www.dragino.com 2.3.1 Installing LoRa Library The Library used here for LoRa communication is called Radiohead; our sketch will use this library so we need to download it from: https://github.com/dragino/RadioHead/archive/master.zip.
www.dragino.com 2.3.2 Upload Sketch to LoRa Client a) In the Arduino IDE, first choose Dragino Yun – LG01, b) Then choose the example: LoRa_Simple_Client_Arduino c) In the window of LoRa_Simple_Client_Arduino, choose the board Arduino UNO which is the correct board for LoRa Shield + UNO: d) Unload the LoRa_Simple_Client_Arduino example sketch to LoRa Shield + UNO via the USB com port. And then open serial monitor to see the output.
www.dragino.com 2.3.3 Upload Sketch to LoRa Gateway LG01 a) Click the Arduino.exe to open another new instance. It is very important to open a new instance so we can two serial monitor, one for LoRa Client and one for LG01. b) In this new instance, Select LG01 board in Arduino IDE and choose the example LoRa_Simple_Server_Yun c) Upload this Sketch to the LG01, then open the serial monitor to monitor the LG01 status.
www.dragino.com 2.3.4 Analyze Test Result Below screenshot shows the result of this example. The Upper window shows the LoRa Client keep sending the LoRa packet out, and wait for the reply of this packet. The lower window is from LG01, which shows LG01 get a “Hello World” packet via LoRa, after LG01 get the “Hello World” packet, it will sent a broadcast LoRa packet “And hello back to you”, the LoRa Client will then receive it and print it on the serial monitor.
www.dragino.com 3. Typical Network Setup 3.1 Overview LG01 support flexible network set up for different environment. This section describes the typical network topology can be set in LG01.
www.dragino.com 3.2 General WiFi AP Network In the General AP Mode, LG01 gets internet access from its WAN port or USB 3G/4G/GPRS. LG01 itself acts as a WiFi Access Point and provide a WiFi AP network. LG01 shares the internet to its AP network or LAN interface.
www.dragino.com 3.3 WAN Port Internet Mode The LG01 will use WAN port for internet connection. When connect LG01’s WAN port to router, LG01 will get IP from router and have internet access. This is the default setting. It also shares the internet to its LAN port and WiFi AP network for other devices. 3.4 WiFi Client Mode In the WiFi Client Mode, Dragino acts as a WiFi client and gets DHCP from uplink router via WiFi. It also shares the internet to its LAN port for other devices.
www.dragino.com 3.5 Mesh WiFi Network In the mesh network topology, user should choose the device to be a mesh gateway node or mesh client node Mesh Gateway: use WAN port or USB 3G/4G modem to get internet access from uplink router. It also shares the internet to its Mesh Network for other Mesh Clients. The Mesh Gateway also acts as a DHCP router for its mesh network. Mesh Client: Connects to the Mesh Gateway via mesh network, it also bridge internet via the LAN and WiFi AP interface. 3.5.
www.dragino.com Network --> LAN and DHCP Enable DHCP server in its LAN port Set Gateway to 255.255.255.255 Network --> Access Point Enable WiFi AP (not necessary), Can set same SSID in the mesh network Network --> Mesh Network Enable WiFi Mesh Network Input Mesh Group //Note: Mesh Device within same group can communicate with each other. Mesh Group is a translation for BSSID for easy configure and remember.
www.dragino.com 3.5.2 Mesh Client Set Up Network --> Internet Access Access Internet set to Disable Network --> LAN and DHCP Disable DHCP server in its LAN port and Set gateway point to mesh gateway.
www.dragino.com Network --> Access Point Enable WiFi AP (not necessary,can use same SSID or difference SSID with other mesh node) Network --> Mesh Network Enable WiFi Mesh Network Input Mesh Group //Note: Mesh Device within same group can communicate with each other. Mesh Group is a translation for BSSID for easy configure and remember.
www.dragino.com 3.6 USB Dial Up Modem Set Up Dragino USB interface can be used for GPRS/3G/4G connections. Below are some set up examples. Note: if user use EC20/UC20 module, he just need to choose USB modem in the internet setting and reboot the device. the device will auto configure to support these modules.
www.dragino.com 3.7 USB 3G/4G Ethernet Dongle Some USB dongles are not using the dial up to connect internet. Instead, they appear as a network interface and has built-in router feature. Huawei Hilink dongles are a typical of these.
www.dragino.
www.dragino.com 4. Linux System The LG01 bases on OpenWrt Linux System. It is open source, and user are free to configure and modify the inside Linux settings. 4.1 SSH Access for Linux console User can access to the Linux console via SSH protocol. Make sure your PC and the LG01 is in the same network, then use a SSH tool (such as putty) to access it.
www.dragino.com 4.2 Edit and Transfer files The LG01 support SCP protocol and has a built SFTP server. There are many ways to edit and transfer files using these two protocols. One of the easiest is through WinSCP utility. After access via WinSCP to the device, use can use a FTP alike window to drag / drop files to the LG01 or Edit the files directly in the windows. Screenshot is as below: 4.3 File System The LG01 has a 16MB flash and a 64MB RAM.
www.dragino.com 4.4 Package maintain system LG01 uses OPKG package maintain system. There are more than 3000+ packages available in our package server for user to install for their applications.
www.dragino.com 5. Bridge Library The bridge library is the most important part of LG01. Bridge library defines a mechanism how the MCU talk to the CPU (ar9331). With the bridge library, the MCU can send data to CPU, get commands result from CPU or call commands in CPU. The bridge Library use UART port to communicate between MCU and ar9331. Below is the block diagram shows the bridge connection between the Mega328P MCU and Linux.
www.dragino.com 5.1 The Use of Console Console Class in Arduino is a good way to output debug info to computer. The Arduino IDE --> Files --> Examples --> Dragino-->Bridge-->ConsoleRead shows how to use this class to print data to Arduino IDE’s Serial Monitor.
www.dragino.com 6. Advance Management 6.1 Reset Network or Reset to Factory Default LG01 provide ways for user to reset the device. When the Linux system is running, user can press the toggle button to reset the device. the pressing time will determine which part is to be reset. Pressing the toggle button, the GLOBAL LED will blink, release the button after 5 seconds, device will reset the network setting and reboot (GLOBAL/LAN/WAN/WiFi blink once), other settings will be kept.
www.dragino.com 7. Upgrade Linux Firmware We keep improving the LG01 Linux side firmware for new features, bug fixes. The latest firmware can be found on IoT Mesh Firmware, and the Change Log can be found here: Firmware Change Log. The file named as dragino2-IoT--xxxxx-squashfs-sysupgrade.bin is the upgrade Image. There are different method to upgrade, as below: 7.
www.dragino.com 8. Upgrade Micro Controller Sketch There are three ways for use to upgrade the sketch to the MCU use LG01. 8.1 Upgrade Sketch via Arduino IDE We have already introduce this method in above, please see from here 8.2 Upgrade Sketch via Web UI Upgrade Sketch via Web UI is a good way to distribute production sketch in hex format. User can get the hex production file and below is the upgrade step: In LG01, Go to page Sensor --> Flash MCU , Select the hex file and upload it to LG01.
www.dragino.com 8.3 Auto update MCU Since Firmware IoT-4.1.1, auto update sketch is supported. With this feature, the Dragino's will connect to a http/https server and get the latest sketch version and upload the sketch with this version. The purpose of this feature is to reduce the tech support cost / time for remote installation. The feature can be configured in the page sensors -> microcontroller. Auto Update On Boot: While this option is enabled.
www.dragino.com Auto Update On Boot:checked Update URL: http://www.dragino.com/downloads/downloads/tmp/autoupdate/ Update Info: update_info Enable MAC Identify: unchecked After reboot, the device will do auto update as below: 1. Download the update information from http://www.dragino.com/downloads/downloads/tmp/autoupdate/update_info 2. Compare the Latest version and the version on the device 3. If server has a higher version, Device will download http://www.dragino.
www.dragino.com 9. Example: Integrate LoRa with RESTFul API 9.1 What is RESTFul API? A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. Many IoT services provide RESTful API as one of the uplink/downlink method for sensor date communication. This example will show how to use LG01 to communicate with IoT server via RESTful API, so to achieve the goal to upload sensor data to IoT server or download commands from IoT server. 9.
www.dragino.com To let the LG01 communicate with the channel, we also need the API keys and API method. In ThingSpeak, we can find API keys and API call method in API Keys page: 9.3 Step by Step Uplink Test In this section, we will try to program LG01 to uplink data to ThingSpeak. The data flow in this example is as below: We have already tried ① and ② in the above simple LoRa example.
www.dragino.com 9.3.1 Try RESTful API call in web We can see the API from ThingSpeak page as below: As above, the API call to update a channel feed is as below: GET https://api.thingspeak.com/update?api_key=B9Z0R25QNVEBKIFY&field1=0 In above API call, there are three variables: api_key: Define on which channel you will upload the data. Field: Each channel have max 8 fields, Field1 , Field2 define which exactly field to be updated Value: Field1=0, means update the Field1 with value 0.
www.dragino.com So we have tested that the RESTful API calls works as the document they provide, next step we will try in LG01 to use this API call. Note: RESTful API is a design style, not a standard. Different servers may have different RESTful call format. Some format can’t be executed in web browser. Developer should follow the documents provided by the IoT server. POSTMAN is very powerful tool for debug the RESTful API.
www.dragino.com 9.3.2 Try RESTful API call with LG01 Linux command First, we need to make sure the LG01 has internet access. We can log in the SSH and ping an Internet address and see if it get through. As below: LG01 has built-in Linux tool curl. It is a very powerful tool for http communication. We can use this tool to handle RESTful API call in LG01. The command to update a feed is as below: curl -k "https://api.thingspeak.
www.dragino.com 9.3.3 Integrate LoRa, Bridge and Curl Here we will provide a complete example for our system. The hardware set up is as below: LoRa End Node: LoRa Shied + UNO + DHT11 Temperature/Humidity sensor. The LoRa End node keeps getting temperature and humidity from the sensor and sends out via LoRa periodically. LoRa Gateway LG01: Listening on the LoRa wireless channel, while there is new LoRa packet arrives, parse it and send out to IoT Server.
www.dragino.com 9.4 Step by Step Downlink Test In this section, we will try to program LG01 to fetch download data from ThingSpeak, then broadcast this data to local LoRa network. The end node will get this message and check if they need to do something. Similar with Uplink Example, we will first try to do it in PC, and then do it in Linux side, and finally integrate it with LoRa.
www.dragino.com 9.4.1 Create Talkback command and try RESTful API call in web To do the downlink test we need to first create a talkback command in ThingSpeak. As below, From this page, we can get the tallback API key and set the command to be sent to the LoRa End Device. Then we add talkback command and click Save TalkBack.
www.dragino.com We can run the talkback API in browser to see if we can get the talkback commands: The API we are going to use is: https://api.thingspeak.com/talkbacks/12095/commands/execute.json?api_key=VJ183E4EG4GYWL4Y (User should replace the 12905 and api_key with what they have in their command.
www.dragino.com 9.4.2 Try RESTful API call with LG01 Linux command The command to be used is Execute the Next TalkBack Command, with curl, it is curl -k "https://api.thingspeak.
www.dragino.com 9.4.3 Integrate LoRa, Bridge and Curl Here we will provide a complete example for our system. The hardware set up is as below: LoRa Gateway LG01: Periodically check if there new commands in IoT Server. If there is new command, broadcast the command string to its LoRa network. . LoRa End Node: LoRa Shied + UNO, listening if there are commands in LoRa network. If there is new command and the node ID match. It will parse and execute the incoming command.
www.dragino.
www.dragino.com 10. Example: Integrate LoRa with MQTT API 10.1 What is MQTT API? 10.2 What does this example shows? How it works? 10.3 Configure IoT Server 10.4 Step by Step Uplink Test 10.5 Step by Step Downlink Test 11. Advance Examples 11.1 Example for Connecting to TTN LoRaWAN server Please check this link for detail: Connect to TTN 11.2 Multiple Nodes examples The example shows how the gateway can handle multiple nodes up to several hundreds.
www.dragino.com a) Gateway require about 1.5 minutes to set up this 100 nodes Network b) Gateway takes about 2 minutes to do polling for these 100 nodes. User can adjust the timing in the sketch from case by case.
www.dragino.com 11.3 How to use the sensor pin of LG01-S? The LG01-S has the external sensor pins from the Mega328P MCU, it can connect to external sensor, below is the pin definition for LG01-S: The program method for these pins are the same as Arduino, what should notice is that the pins are 3.3v I/O base. Here is an example for how to use it with DS18B20 temperature sensor.
www.dragino.
www.dragino.com 11.
www.dragino.com 12. FAQ 12.1 Why there is 433/868/915 version LoRa part? Different country has different rules for the ISM band for using the LoRa. Although the LoRa chip can support a wide range of Frequency, we provide different version for best tune in the LoRa part. That is why we provide different version of LoRa. 12.
www.dragino.
www.dragino.com 12.6 Can I make my own firmware for LG01? Where can I find the source code of LG01? Yes, User can make own firmware for LG01 for branding purpose or add customized application. The LG01 source code and compile instruction can be found at: https://github.com/dragino/openwrt-cc-15.05 12.7 How to get more examples for this device? We keep releasing Arduino Examples in the Dragino examples directory under Arduino IDE. If user install the dragino board earlier and we have release new examples.
www.dragino.com 13. Trouble Shooting 13.1 I can’t download the Dragino profile in Arduino IDE. If IDE quite slowly while downloading the Dragino profile in board manager and stuck somewhere. As show below, it is because your network has slow connection to some packages from Arduino IDE. To solve this, user can manually add Dragino profile. Below is the step: 1/ Download the profile from https://github.
www.dragino.com 13.2 Bridge between MCU and Linux module doesn’t work. Some possibilities: 1/ You have used the Serial class in MCU sketch, like Serial.begin(9600), The bridge library in Mega328P use the same Serial interface. So if you have the Serial code in the sketch. They will conflict and bridge doesn’t work. 2/ The IDE get mess in the serial setting when you compile other sketch . In this case, you can close the IDE and open it again. 13.
www.dragino.com 13.5 How to recover the LG01 if firmware crash LG01 provide user a full control on its Linux system, it is possible that the device will brick and can’t boot after improper modification in some booting files. In this case, user can recover the whole Linux system by uploading a new firmware via Web Failsafe mode. Procedure is as below: Use a RJ45 cable to connect the PC to LG01’s port directly. Set the PC to ip 192.168.255.x, netmask 255.255.255.
www.dragino.com 13.6 I configured LG01 for WiFi access and lost its IP. What to do now? The LG01 has a fall-back ip in its LAN port. This IP is always enabled so user can use fall back ip to access LG01 no matter what the WiFi IP is. The fall back ip is useful for connect and debug the unit. (Note: fallback ip can be disabled in the LAN and DHCP page) Steps to connect via fall back IP: 1. Connect PC’s Ethernet port to LG01’s LAN port 2. Configure PC’s Ethernet port has IP: 172.31.255.253 and netmask: 255.
www.dragino.com 14. Order Info General Version: LG01P-433: LoRa Gateway best tune to 433 MHz. LG01P-868: LoRa Gateway best tuned to 868 MHz. LG01P-915: LoRa Gateway best tuned to 915 MHz Screw Terminal Version: LG01S-433: LoRa Gateway best tune to 433 MHz. LG01S-868: LoRa Gateway best tuned to 868 MHz. LG01S-915: LoRa Gateway best tuned to 915 MHz. Outdoor Version: OLG01-433: LoRa Gateway best tune to 433 MHz. OLG01-868: LoRa Gateway best tuned to 868 MHz.
www.dragino.
www.dragino.com 17. Reference LG01 LoRa Gateway official wiki More examples for LG01 LoRa Gateway Source code for LG01 LoRa Gateway https://github.com/dragino/openwrt-cc-15.05 OpenWrt official Wiki http://www.openwrt.org/ Arduino Official Site: https://www.arduino.cc Arduino bridge examples: https://www.arduino.cc/en/Tutorial/Bridge Hardware Source Code: The LG01 includes two parts of hardware: MS14N Linux Mother Board: https://github.