MinhVBryan Bui-Tuong
Published

How to Setup Your Own Remote Weather Station Using LoRaWAN

Measure temperature, humidity, pressure, light intensity, rainfall, particulate matter, wind speed and wind direction on the Helium Network.

IntermediateFull instructions provided4 hours997
How to Setup Your Own Remote Weather Station Using LoRaWAN

Things used in this project

Hardware components

Seeed Studio SenseCAP ONE S900 9-in-1 Compact Weather Sensor
×1
Dragino RS485-LN RS485 / Modbus to LoRaWAN Converter
×1
Seeed Studio Seeed SenseCAP M1 LoRaWAN Gateway (Helium Network)
Only required if there is no existing Helium Network coverage
×1
Preconfigured Weather Station for Helium Network
Pre-configured kits are available as an alternative to the first two required components.
×1

Software apps and online services

Putty
SenseCap One Configuration Tool
Helium Console
TagoIO

Story

Read more

Code

Weather Station Function Decoder

C/C++
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;
}

Credits

MinhV

MinhV

1 project • 2 followers
IOT Engineer at Parley Labs. I love traveling, exploring new places, learning other cultures and trying out all the food.
Bryan Bui-Tuong

Bryan Bui-Tuong

2 projects • 4 followers
I like to build things. Father, Electrical Engineer, Real Estate investor, corporate rentals, Crypto Enthusiast.

Comments