Gathering weather data for remote location has always been very expensive due to data cost and infrastructure. However, with LoRaWAN long range coverage, we can install LoRaWAN hotspot in a more accessible area and install the weather station far from the hotspot. In this project, I will show you how to use a Seeed SenseCAP S900 weather station along with a Dragino RS485 to LoRaWAN converter to have a remote weather station setup.
Configure SenseCAP S900 All-in-One Weather Station
1. Connect via USB Cable
Remove the protective cap on the S900 bottom side using a quarter as show below. Connect the provided USB-C cable between the S900 and your computer.
2. Configure S900 using SenseCap One Configuration Tool
Download the appropriate version of the SenseCAP One Configuration Tool from GitHub. Once downloaded. open the program and select the correct serial port.
Select "9600" for the Baud Rate and press "Connect" as shown below. Once connected, you will be able to see all current sensor readouts. Ultimately, we want to read these values remotely over the LoRaWAN network without being connected to the weather station!
In order to transmit all these data over the LoRaWAN network, we will use the Dragino RS485 to LoRaWAN Converter. The S900 allows us to change its setting to play nice with the RS-485 converter. To do it, select "Settings" in the configuration tool main page and you will see the page below. Select, "Read from Device" to obtain all the current setting on the weather station. Once all fields are populated, Change the "Main Port Protocol" to "RS-485 Modbus RTU", then set the "Modus Address" to "1" and finally set the "Modbus Baud Rate" to "9600". Leave everything else as default. Select "Write to Device" to save the new setting changes.
Configure the Dragino RS485 to LoRaWAN Converter
1. Setup PUTTY
Download and Start PUTTY. You should see the following screen when PUTTY is started
Select "Terminal" on the left column then select "Force on" for both "Local echo" and "Local line editing". Do NOT press "Open" at this point yet
Select "Session" on the left column. Set "Connection type" to "Serial" and "Speed" to "9600". Fill out the correct COM port under "Serial line" then press "Open".
2. Add Sampling Command
RS485-LN can store up to 15 Modbus sampling commands. In order to request data from the weather station, add the following Modbus commands to RS485-LN. These commands must be entered exactly as shown into PUTTY for it to work correctly with the provided decoder.
Command to obtain ambient temperature
AT+COMMAND1=01 04 00 00 00 02,1
Command to obtain air humidity
AT+COMMAND2=01 04 00 02 00 02,1
Command to obtain barometric pressure
AT+COMMAND3=01 04 00 04 00 02,1
Command to obtain light intensity
AT+COMMAND4=01 04 00 06 00 02,1
Command to obtain minimum wind direction
AT+COMMAND5=01 04 00 08 00 02,1
Command to obtain maximum wind direction
AT+COMMAND6=01 04 00 0a 00 02,1
Command to obtain average wind direction
AT+COMMAND7=01 04 00 0c 00 02,1
Command to obtain minimum wind speed
AT+COMMAND8=01 04 00 0e 00 02,1
Command to obtain maximum wind speed
AT+COMMAND9=01 04 00 10 00 02,1
Command to obtain average wind speed
AT+COMMANDA=01 04 00 12 00 02,1
Command to obtain accumulated rainfall
AT+COMMANDB=01 04 00 14 00 02,1
Command to obtain rainfall duration
AT+COMMANDC=01 04 00 16 00 02,1
Command to obtain rainfall intensity
AT+COMMANDD=01 04 00 18 00 02,1
Command to obtain max rainfall intensity
AT+COMMANDE=01 04 00 1a 00 02,1
3. Add Processing Command
There are 15 “AT+DATACUTx” slots corresponding to 15 “AT+COMMANDx” above. These datacuts provide a mean to filter out the actual data from overhead. RS485-LN also uses datacuts to assemble the payload to send over LoRaWAN.
Send the following datacut commands to the RS-485 converter using PUTTY and send only one line at a time.
AT+DATACUT1=9,2,4~7
AT+DATACUT2=9,2,4~7
AT+DATACUT3=9,2,4~7
AT+DATACUT4=9,2,4~7
AT+DATACUT5=9,2,4~7
AT+DATACUT6=9,2,4~7
AT+DATACUT7=9,2,4~7
AT+DATACUT8=9,2,4~7
AT+DATACUT9=9,2,4~7
AT+DATACUTA=9,2,4~7
AT+DATACUTB=9,2,4~7
AT+DATACUTC=9,2,4~7
AT+DATACUTD=9,2,4~7
AT+DATACUTE=9,2,4~7
4. Split Payload Transmission Configuration
Since there are too many bytes for one transmission to handle, we have to enable split payload using the following command:
AT+DATAUP=1
5. Assembling Payload
The LoRaWAN payload is automatically assembled by the RS485-LN using all returned data from DATACUTx. Since we are using split payload, the payload has the following structure:
PAYVER + PAYLOAD INDEX[0] + DATACUT1 + DATACUT2
…
PAYVER + PAYLOAD INDEX[6] + DATACUTD + DATACUTE
PAYVER has a default value of 0x01 but it can go up to 0x0f to accommodate more RS485-LN on the network.
Adding the Dragino RS485 to LoRaWAN Converter to the Helium Network
1. Register for a Helium Console Account
We will be using the Helium Network as our LoRaWAN network provider because of their large network coverage and low fee. You can check out more about them here.
In order to receive data from the Helium LoRaWAN network, we will create a Helium Console account here. Once you created the account and logged in, you will see the following page:
2. Adding Data Credit
Every new Helium Console account comes with 10, 000 data credit which will provide about 2 months of data for the weather station. However, if you want to add more, hover over the DC balance on the top right of your screen and click on "DC Balance" which will take you to the following screen. The minimum purchase with credit card is $10 which will give you plenty of data credit to use with the weather station.
3. Adding theDragino RS485 to LoRaWAN Converter to the Helium Network
Select "Devices" on the left column, then "Add New Device". Every Dragino RS485 converter comes with a sheet containing the Dev EUI, App EUI, and the App Key. Enter a name for your device and populate the Dev EUI, APP EUI and App Key. Once completed, proceed to "Save Device".
4. Adding Payload Decoder
Select "Functions" on the left column, then "Add New Function". Set all fields the same as seen below.
Copy and paste the following function into the custom script box.
function Decoder(bytes, port) {
var payload_index = bytes[2];
var decoded_frame ={};
//Payload index of 0 contains air temperature (C) and air humidity (%)
if (payload_index == 0)
{
decoded_frame.Air_Temperature = (bytes[3]<<24 | bytes[4]<<16 | bytes[5]<<8 | bytes[6])/1000;
decoded_frame.Air_Humidity = (bytes[7]<<24 | bytes[8]<<16 | bytes[9]<<8 | bytes[10])/1000;
}
//Payload index of 1 contains barometric pressure and light intensity (Lux)
else if (payload_index == 1)
{
decoded_frame.Barometric_Pressure = (bytes[3]<<24 | bytes[4]<<16 | bytes[5]<<8 | bytes[6])/1000;
decoded_frame.Light_Intensity = (bytes[7]<<24 | bytes[8]<<16 | bytes[9]<<8 | bytes[10])/1000;
}
//Payload index of 2 contains minimum wind direction (degree) and maximum wind direction (degree)
else if (payload_index == 2)
{
decoded_frame.Min_Wind_Direction = (bytes[3]<<24 | bytes[4]<<16 | bytes[5]<<8 | bytes[6])/1000;
decoded_frame.Max_Wind_Direction = (bytes[7]<<24 | bytes[8]<<16 | bytes[9]<<8 | bytes[10])/1000;
}
//Payload index of 3 contains average wind direction (degree) and minimum wind speed (m/s)
else if (payload_index == 3)
{
decoded_frame.Avg_Wind_Direction = (bytes[3]<<24 | bytes[4]<<16 | bytes[5]<<8 | bytes[6])/1000;
decoded_frame.Min_Wind_Speed = (bytes[7]<<24 | bytes[8]<<16 | bytes[9]<<8 | bytes[10])/1000;
}
//Payload index of 4 contains maximum wind speed (m/s) and average wind speed (m/s)
else if (payload_index == 4)
{
decoded_frame.Max_Wind_Speed = (bytes[3]<<24 | bytes[4]<<16 | bytes[5]<<8 | bytes[6])/1000;
decoded_frame.Avg_Wind_Speed = (bytes[7]<<24 | bytes[8]<<16 | bytes[9]<<8 | bytes[10])/1000;
}
//Payload index of 5 contains accumulated rainfall and accumulated rainfall duration
else if (payload_index == 5)
{
decoded_frame.Accumulated_Rainfall = (bytes[3]<<24 | bytes[4]<<16 | bytes[5]<<8 | bytes[6])/1000;
decoded_frame.Accumulated_Rainfall_Duration = (bytes[7]<<24 | bytes[8]<<16 | bytes[9]<<8 | bytes[10])/1000;
}
//Payload index of 6 contains rain intensity and maximum rain intensity
else if (payload_index == 6)
{
decoded_frame.Rain_Intensity = (bytes[3]<<24 | bytes[4]<<16 | bytes[5]<<8 | bytes[6])/1000;
decoded_frame.Max_Rain_Intensity = (bytes[7]<<24 | bytes[8]<<16 | bytes[9]<<8 | bytes[10])/1000;
}
//Payload index of 7 contains PM2.5 and PM10 data
else if (payload_index == 7)
{
decoded_frame.Pm2_5 = (bytes[3]<<24 | bytes[4]<<16 | bytes[5]<<8 | bytes[6])/1000;
decoded_frame.Pm10 = (bytes[7]<<24 | bytes[8]<<16 | bytes[9]<<8 | bytes[10])/1000;
}
return decoded_frame;
}
We will continue setting up Helium Console after finishing the next section.
Setting Up Tago.IO for Data Visualization
1. Register for a Tago.IO Account
In this guide, we will use Tago to display all data coming from Helium. Register for a free account with Tago and once you are logged in, you will see the following screen.
2. Add New Device to Tago
Select "Devices" on the top left corner, then select "Add Device".
Select "LoRaWAN Helium", then select "Custom Helium" as shown below.
Once you selected "Custom Helium", the following screen will appear. Give your weather station a name and set the "Data Storage Type" to "Device Data Optimized". For data retention, set your desirable timeframe that you want Tago to retain data. In this example, we will set it to one month. Fill in the EUI field with the Dev EUI that you used when adding the Dragino RS485 converter to Helium Console. Once done, press "Create My Device",
3. Add Weather Station Dashboard to Tago
Use the following link to automatically install the weather station dashboard to your Tago account. Select "Install Template" when prompted as shown below.
Select the device name that you added earlier. In my case, I named the device as "RS485" so I selected that option from the drop-down menu. Select "Confirm associations" once you are done.
4. Adding Tago Authorization to Helium Console
At this point, you will see the newly created dashboard on your homepage. However, the dashboard should be empty since you have not gotten any data yet due to the fact that we have not link the Tago account to our Helium Console account. To do this, select your profile name on the top right corner, then select "My account"
Select your profile name on the left, then click on "Token", set permission to "full", and to never expire, then "Generate Token". In order to copy your token, click on the copy symbol as show below.
Now log back into your Helium Console account, click on "Integrations" on the left column then add TagoIO.
Paste your newly created Tago token in the the Step 2 box below.
5. Flow Diagram
Finally, we are on the last step. This step will tie everything that we did previously together and allow you to see all your weather station output on TagoIO.
While in Helium Console, click on "Flows", then add the following items and connect them together. In our case, we will add the weather station, weather station decoder function and the TagoIO authorization.
TagoIO Dashboard Visualization
Congratulation, you are now done! Go back to your Tago dashboard and see all the data fields getting populated as more data come through!
Comments