Use a LoRa gateway and nodes to send data to an IoTool server and display it in the IoTool Dashboard
This guide will show you how to set up an Arduino with a Dragino LoRa shield to transmit sensor data, and a Dragino LoRa-enabled gateway to receive and forward sensor data to an IoTool server using the MQTT protocol.
Skill level: advanced
Knowledge of Arduino IDE, C++, and familiarity with radio signals is recommended. Basic knowledge of OpenWrt and the Linux terminal is also required.
Final set up
Dragino LG01 LoRa Gateway
Arduino + Dragino LoRa Shield
- IoTool Personal or higher account
- IoTool application installed and configured for IoTool Cloud
- Dragino LG01/OLG01 LoRa gateway (or Arduino Yún with LoRa shield – not tested)
- Arduino with Dragino LoRa shield
- An installation of Arduino IDE
Step by step
Preparing your environment
- First we will have to set up a custom source for the Arduino IDE so we can install the board profile for Dragino boards in the next step. Open the Arduino IDE Preferences. Paste this URL to Additional Boards Manager URLs field: http://www.dragino.com/downloads/downloads/YunShield/package_dragino_yun_test_index.json
- Install the board profile for Dragino boards using the Boards Manager.
- Download the RadioHead Arduino library from http://www.airspayce.com/mikem/arduino/RadioHead/ and extract it to your Arduino IDE libraries location which is usually located at C:\Program Files (x86)\Arduino\libraries on Windows.
- Install the SparkFun BME280 library using the Manage Libraries menu.
- Download the zip file containing the example code that is attached at the bottom of this article, and extract it to a location of your choice.
Setting up the Dragino LoRa gateway
- Power up your Dragino gateway with the included AC or PoE adapter and wait for the system to boot.
- If this is the first time the gateway is being used, you will first have to be able to access the web configuration interface.
- Take a look at http://www.dragino.com/downloads/downloads/UserManual/LG01_LoRa_Gateway_User_Manual.pdf to find the best way you wish to connect the gateway to the Internet. The easiest way to start with is just using an Ethernet cable or setting the gateway to connect to your existing WiFi network.
- Install the mosquitto-client package to the OpenWrt side. Make sure to update the package lists first. Alternatively, you can do this via SSH by using the commands opkg update and opkg install mosquitto-client.
- Copy over the script that receives data from the Arduino side and sends it as MQTT messages to /root/. Modify its permission so it is allowed to be executed. The easiest way is to connect to the gateway using something like WinSCP, browsing to the specified location, and dragging and dropping the file inside. Then right click the file, select Properties, and tick all checkboxes next to X to set the permissions.
- Configure the MQTT settings in the OpenWrt web interface.
- When the gateway is connected to the same network it should show up in the Arduino IDE.
- Open the lora_gateway sketch and upload it. If you are asked for a password, type in "dragino".
- Monitor the output with the Serial Monitor. Alternatively you can connect to the gateway via SSH and monitor the output there by using the command telnet localhost 6571.
Setting up the Arduino Uno
- Connect your BME280 sensor to the Arduino. In this tutorial, we're going with an I2C connection, so follow this connetion scheme: sensor GND pin to Arduino GND port, sensor 3.3V pin to Arduino 3.3V port, sensor SCL pin to Arduino SCL port, sensor SDA pin to Arduino SDA port.
- Open the lora_client_bme280 sketch and upload it. If the sensor doesn't seem to be working, try changing the I2C address to 0x77.
- Monitor the output with the Serial Monitor. Alternatively you can connect with any application that can read Serial port output, eg. PuTTY by connecting to the Serial port in use using the specified baud rate.
- The data should have been uploaded to IoTool Cloud. Login with the user account you already set up in the OpenWrt configuration, open the <your_account>_sensors_hrf table, sort it by date, and check if the readings are present there.
- If the readings are there, open the <your_account>_sensors, find the sensors that your Arduino uses, and input the required data so that the readings can be correctly displayed in the IoTool app. You can find more detailed instructions by clicking the Show structure button.
Display the recorded data in the IoTool application
- We will suppose that you have IoTool Cloud already configured in the application settings. If not, follow the guide located at https://iotool.io/support/knowledgebase/connecting-to-iotool-cloud-from-your-device.
- Update the IoTool Cloud sensor list in the settings.
- Set the number of buttons that you want displayed in the dashboard.
- Select the measurements that you want shown for each button. Your sensor readings sent over LoRa are located in the IoTool Cloud Sensors category.
- Check your readings in IoTool Dashboard.