Close
0%
0%

Long Range weather station

A cheap but precise weather Station (Lora transmission)

Similar projects worth following
Today, farm-level weather stations are becoming an effective tool for monitoring daily fluctuations in the weather. A variety of weather stations can be used according to the number of parameters to be measured, the working precision, and the range. The parameters measured by this weather station include:

rain
Air and soil temperature
Relative humidity
Soil moisture
Wind speed and direction
Solar radiation
Pressure

This weather station is cheap, accurate and easy to build.
It is versatile (we use it at our RC planes airfield!), it is precise and has a very long range of communication.

Follow this project to learn more.

This weather station was part of the Rezodo project. It has been moved to its own project as the  Rezodo project was becoming too big to be easily readable !

This weather station is intended to be easily "tunable" to your own needs :

  • transmission to the base can be done
    • directly by the station itself if Wifi is available
    • via Lora point to point to get a much greater range (currently working with more than 2.5 km between base and station)
  • sensors can be choosen among the list and two major versions do exist
    • wind only (+ sensors)
    • wind + rain (+sensors)

The design of the two main versions is basically the same but the "mechanical" parts, of course, differ. We will cover the two versions.


"Wind only" weather station

As I do belong to a RC flying club, we need to know the wind conditions at the airfield. These conditions are locally changing quite fast and weather forecast is not accurate enough for our hobby !

So I decided to design a "Wind only" version of the weather station.

Here it is, installed at our airfield

The airfield is far away from electricity network and at 2.5km from the first building where we have installed the Lora receiver.

Everything is working now and we have a public access to these nice gauges!

Building this station is not complex. Read all this description and the logs and you will be able to build yours !

As you can see the wind sensors do work in very low wind conditions. 

Price for this "Wind Only" weather Station including both emitter and receiver boards (GTW0 + GTW1) is less than 50€. Bill of Material is accessible here


Full weather station

This one is the most complete version, including all the sensors. It mainly differs from the previous one by the addition of a rain gauge.

The electronics goes inside the bottom box, wires go to the sensors into the pipes. PCB is protected against rain.

Here is a picture showing "exploded" view of the weather station:

And here it is during tests:


Weather station electronics

This schematics summarizes the electronics embedded into the weather station. The same PCB is used for the various versions of the weather station, and even for the Lora gateway 0 (the one simply equiped with Lora + wifi access + mains power supply).

In a few words, it has the following components:

  • a lora module for long range communication between Gateway 0 and Gateway 1
  • an ESP32 MCU + ESPNow (to be connected to Rezodo FDRS network if needed)
  • a rain gauge equiped with weighing sensor for accurate measurement
  • a wind direction sensor with a Hall encoder delivering 4096 angular postions (contactless... no wear)
  • a wind anemometer with hall effect sensor (contactless... no wear)
  • temperature, humidity, pressure, light sensors

More details into this log please read it as it contains important informations.

Components + mechanical parts for this schematics should cost around 65€. This price is for the "full" Lora weather station and does include the Lora GTW0 and GTW1... 

To build the weather station you will have to add a few 3d printed mechanical components.

All the 3d printed parts are available on thingiverse (links on the left of the main page of this project). 

I printed them with plastic bottle PET filament. See here : Pullstruder project on hackaday.

Never print these parts with PLA... They will melt under the sun. Choose PETG or ABS or PET.


PCB

The PCB have been sponsored by PCBWay. You can order them here : Weather Station PCB @PCBWay

As you can see, this is the V2 version of this board (the latest one).

More details into this log


The rain gauge

There are a few ways to measure rain. The most commun design is "tipping bucket" 

These rain gauges if not "dynamically corrected" may suffer from poor performances. They under estimate high rains and have a poor precision for "small rains". The bucket has to "tip" before counting the water inside...

Please...

Read more »

ESP32_RFM95_full_weatherStation_dual_sided_V2_bom.xlsx

Bill of Material for the "full" weather station (GTW0 + GTW1). Total is 65€

sheet - 2.44 MB - 07/07/2023 at 09:11

Download

ESP32_RFM95_windOnly_weatherStation_dual_sided_V2_bom.xlsx

Bill of Material for WindOnly weather station (GTW0 + GTW1). Total is less than 55€

sheet - 2.01 MB - 07/06/2023 at 19:09

Download

View all 6 components

  • adding Wind Gusts to the weather station

    JP Gleyzes2 days ago 0 comments

    A lot of our RC pilots were more interrested in "strong wind" rather than "averaged wind speed".

    So they asked for Wind Gusts values.

    I made it !

    Gusts are measured every 5s during 30s while I also measure average wind speed.

    Latest commit on my Github page contains all the source code.

    While the thingspeak channel of our Airfield weather station can now proudly show "Gusts" 

  • configuring GTW0

    JP Gleyzes09/09/2023 at 09:47 0 comments

    Your GTW0 is the one which is connected to internet and which synchronizes the weather station (and other GTWs if a wider Rezodo network is in use).

    To configure the GTW0 we have to set up the Wifi credentials and the frequency of sensors measurements.

    This is done by touching the TP1 pad on the PCB and (while touching the pad) resetting the ESP32

    Then a web access point will pop up on which you can connect your smartphone

    Connect to this hotspot then enter

    1. a valid wifi ssid and password
    2. the frequency to wakeup your weather station in minutes

    that's it !

  • Wind Direction and weighing gauge calibration

    JP Gleyzes08/18/2023 at 12:27 0 comments

    Wind direction sensor

    Calibration the wind direction sensor simply consists in telling him where is the north !

    Indeed the magnet can be glued in any position on the shaft so the north pole is totally into a random position!

    To calibrate the "north" we simply align the sensor to the "north" direction, then we press the touch3 pad on the ESP32 and reset the ESP32 (remove your finger from the touchpad after releasing the reset button). 

    This touch pad( named TP1) is also in the bottom right corner of the PCB

    Calibration is done by software and value is stored into the ESP32 flash memory.

    It's straightforward and simple! 

     float angleValue = as5600.rawAngle() * AS5600_RAW_TO_DEGREES;
      if (touch3detected) //calibrate sensors
      {
        Serial.println ("calibrate anemometer");
        calibAngle = angleValue;
        preferences.putFloat("calibAngle", calibAngle);
      }

    You don't even have to physically point the sensor to the north. Just align the sensor with the axis of the PVC pipe (opposite direction of the solar panel).

    But you will have to align the solar panel to the south direction when fixing the weather station on the roof.

    So, wind direction sensor should be calibrated in this position:


    weighing gauge calibration

    Calibration of a load cell is quite easy:

    • determine the zero offset "tare"
    • substract the zero offset from the raw value and then linerly convert this value to weight

    In my Weather station the zero offset is dynamically determined. The logic is simple :

    • once a day empty the bucket --> get the zero offset
    • if weight decreases, abnormal condition then empty the bucket  --> get the zero offset
    • if weight is too big then empty the bucket  --> get the zero offset

    The scle factor needs however a static calibration. It is done by weighing a know weight after having reseted the ESP32 while pressing the TP1 touch pad

     GetRawWeight();       //HX711 will sleep after weight acquisition
      if (touch3detected)
      {
        Serial.print ("calibration HX711... ");
        calib = CurrentRawWeight;
        Serial.println(CurrentRawWeight);
        preferences.putLong("calib", calib);
        emptyBucket();
      }

    The "calib" parameter is stored into the ESP32 flash. This parameter coresponds to the raw value of a know weight which is "calibWeight". Note that this value is in tenth of grams. I do use a steel ball the weight of which being 33.5g...

    Change this value to the weight of your calibration steel ball !

    //scale
    #define PIN_CLOCK  32        //output to generate clock on Hx711
    #define PIN_DOUT   34        //input Dout from Hx711
    
    long calibZero = 0;  //No load sensor Output
    long calib = 130968;          //sensor output - calibZero for Weight calibration --> will be auto calibrated later
    int calibWeight = 335;         //weight at which calibration is done --> expressed in gramsx10. eg 335 means 33.5g

    So the procedure to calibrate the load cell is :

    • insert your steel ball into the bucket
    • press the TP1 touchpad and hold your finger on it
    • reset the ESP32
    • release your finger

    That's it


    You should note that the same touchpad is used to calibrate both the load cell and the wind direction sensor.

    Be sure you are into the calibration conditions of these two sensors while calibrating

  • experience feedback (REX) on power management

    JP Gleyzes08/17/2023 at 14:12 0 comments

    A critical part of my project was power management.

    Here are a few words of "REX" regarding these aspects.

    The wind only weather station has now been operated on a daily basis (24/24) for more than 2 months and has performed sensor acquisition and transfer of data over Lora (2.5km range) every two minutes during day and once every 1 hour during night.

    All this being operated on a single 18650 Li-ion battery charged with a small 2W 6V solar panel.

    Here is the graph of the panel voltage captured during a few days :

    We can clearly see the repeating pattern where the panel outputs 0V during night and boosts up to 7V during full sun.

    If we zoom here is the detail:

    1. during night I automatically perform data sampling once every 1 hour to save power, at sunrize voltage is slowly climbing while at sun set it slowly decreases 
    2. during a few hours the solar charger is lacking efficiciency (it's a linear charger...) and the panel falls down to 5V but charges the battery until full charge where the panel recovers and outputs full power (7V)
    3. but even during full charge when a cloud hides the sun, voltage may drop a little...

    In conclusion, the system seems to be very well "balanced" with good margin to allow operation even during winter time...

    In case of (unexpected) battery depletion I could easily change the sampling rate to 4 min instead of 2 min during winter season!  But we will see this after a few months !

    Currently the fast 2min acquisition is not a concern, even during very cloudy days the battery was charged enough to power the weather station.

  • gauges on ThingSpeak using Matlab

    JP Gleyzes07/18/2023 at 19:13 0 comments

    DIsplaying wind direction needs particular "compass gauges".

    Here is how they look on my "wind Only" Weather Station

    Among these gauges only the second one (wind Speed) is native, the first and third one need a few lines of matlab code.

    Let's start by creating a "Matlab Visualization" on your channel:

    Click on "new visualization" then select the compass one:

    Click on "create" and you will get sample code for this visualization:

    You can save and run this code to get this result:

    Although it's a good starting point, it's far from being perfect to display wind direction:

    • North south Est West are not displayed
    • arrow lines are pointing to the the direction from where the wind is coming
    • 0 is on the right side instead of pointing to north
    • angles are counter clockwise instead of classical ClockWise

    I managed to find Matlab Gurus to help me correct these defects.

    The source code is self explainatory and can be found on my github page: https://github.com/f2knpw/Long_Range_Weather_Station/tree/master/Matlab

    If you change the code by this one you will get the expected result:

    You can of course save this gauge on your channel:

    When reading the source code, you will discover that it is more a less a "hack"... There is no proper way to achieve this result... that's a pity !

  • Adding a biquad antenna to increase Lora range

    JP Gleyzes07/18/2023 at 12:01 0 comments

    To increase range of my Lora network  I decided to try a biquad antenna.

    My lora frequency being 868 MHz I used this online calculator to get the proper design: https://www.changpuak.ch/electronics/bi_quad_antenna_designer.php

    Then I built a jig tp help bending the 2mm copper wire. You can find it on Thingiverse : biquad antenna

    This being done we attached the antenna on the roof.

    Results were impressively good. Eventhough I didn't make a metal reflector for this antenna, I got a lot more power from my "Wind Only" Weather Station located 2.5 km away from the roof.

    The BiQuad antenna is a simple antenna design that offers many advantages. First is the simplicity of the design. 

    The radiating element are two square with the side length equal to 1/4 midband wavelength, 83.8 mm for

    868 MHz in our case. 

    Polarization of the antenna is 90 degrees from the position of orientation of the biquad, i.e. horizontal biquad (as shown on the roof) has vertical polarization.

    The metallic reflector reflects the electromagnetic waves back to the front of the antenna (-Z-axis), hence reducing the radiation to the back and improving the antenna gain and directivity in the forward direction. The obtained gain measures the ability of the antenna to concentrate radio frequency energy in a particular direction. It is typically measured in dB and found equal to 10.5 dB for the studied antenna design.

    Note that the "z axis" is perpendicular to the biquad 

    Without the metal reflector my antenna behaves more or less like a dipole antenna but with better gain and directionnality.

  • Configuring your Weather Station

    JP Gleyzes07/17/2023 at 15:22 2 comments

    Sensors selection

    Depending on the sensors you have soldered to your board you will have to comment/uncomment a few lines of code... Open the GTW1 .ino file

    Full Weather Station

    Here is the sensors selection for my "full weather Station"

    //sensors selection
    #define HAS_HX711       //uncomment for weighing rain gauge
    #define HAS_ANEMOMETER  //uncomment for anemometer
    #define HAS_AS5600      //uncomment for Wind Direction sensor
    #define HAS_BME280      //uncomment for temperature + pressure + humidity BME280 sensor
    #define HAS_DS18B20   //uncomment for DS18B20 temperature sensor
    //#define HAS_DHT22     //uncomment for DTH22 temperature + humidity sensor
    //#define ENABLE_WIFI   //uncomment to enable wifi debugging (avoid this when ESPNow in use)

    As you can see everything is selected but the DHT22 which is useless when you have a more precise BME280 !

     WInd Only Weather Station

    And here is the sensors selection for the Wind Only Weather Station installed at your airfield in Deyme France

    //sensors selection
    //#define HAS_HX711       //uncomment for weighing rain gauge
    #define HAS_ANEMOMETER  //uncomment for anemometer
    #define HAS_AS5600      //uncomment for Wind Direction sensor
    //#define HAS_BME280      //uncomment for temperature + pressure + humidity BME280 sensor
    #define HAS_DS18B20   //uncomment for DS18B20 temperature sensor
    //#define HAS_DHT22     //uncomment for DTH22 temperature + humidity sensor
    //#define ENABLE_WIFI   //uncomment to enable wifi debugging (avoid this when ESPNow in use)

    It has "wind" but also a cheap temperature sensor !

    You can compile GTW1 and values will be sent via Lora to your GTW0 that you shoulmd confiure as well !

    Adding a ThingSpeak Channel to your Weather Station

    Now open the GTW0 .ino file

    Search for "ThingSpeak" and change this line with your API Write key

    // ThingSpeak settings
    char thingserver[] = "api.thingspeak.com";
    String writeAPIKey = "YOUR_API_WRITE_KEY";
    

    You should first create an account and create a new channel.

    Then you can access the "API Keys" tab and fetch the Write key (here in green)

    Verify the fields to be updated by your sensors

     Now you can search for the ThingSpeakPost() function and check the fields updated on ThingSpeak

    It's a simple http post : 

     String data =  "field1=" + String(sensorValues[1][0][0]) 
    + "&field2=" + String(sensorValues[2][0][0]) 
    + "&field3=" + String(scaledValue) 
    + "&field4=" + String(sensorValues[1][1][0]) 
    + "&field5=" + String(sensorValues[1][2][0]) 
    + "&field6=" + String(sensorValues[1][3][0]) 
    + "&field7=" + String(sensorValues[1][4][0]) 
    + "&field8=" + String(sensorValues[1][5][0])  ; 
    //shows how to include additional field data in http post

     You can post what you want  !

    Here is the full procedure

    void ThingSpeakPost(void)
    {
        Serial.print("temperature = ");
          Serial.print(sensorValues[1][0][0]);
          Serial.print(" °C   humidity = ");
          Serial.print(sensorValues[1][1][0]);
          Serial.print(" %   pressure = ");
          Serial.print( sensorValues[1][2][0]);
          Serial.println(" hPa");
    
          Serial.print("rot speed = ");
          Serial.print(sensorValues[1][3][0]);
          Serial.print(" km/h   wind direction = ");
          Serial.println(sensorValues[1][4][0]);
    
          Serial.print("rain weight = ");
          Serial.print(sensorValues[1][5][0]);
          Serial.println(" g");
      WiFiClient client;
      if (!client.connect(thingserver, 80))
      {
        Serial.println("Connection failed");
        client.stop();
        return;
      }
      else
      {
        // Create data string to send to ThingSpeak.
        float scaledValue = mapf(sensorValues[2][0][0], 50, 370, 100, 0); //remap values from 100 to 0
        String data =  "field1=" + String(sensorValues[1][0][0]) + "&field2=" + String(sensorValues[2][0][0]) + "&field3=" + String(scaledValue) + "&field4=" + String(sensorValues[1][1][0]) + "&field5=" + String(sensorValues[1][2][0]) + "&field6=" + String(sensorValues[1][3][0]) + "&field7=" + String(sensorValues[1][4][0]) + "&field8=" + String(sensorValues[1][5][0])  ; //shows how to include additional field data in http post
    
        // POST data to ThingSpeak....
    Read more »

  • Weather Station firmware

    JP Gleyzes07/17/2023 at 14:31 0 comments

    Firmware for the weather station is available on my Github project.

    You will find there everything needed to compile and configure your weather Station.

    Arduino installation

    You will need to install Aduino IDE : https://www.arduino.cc/en/software

    Then you should add a reference to your ESP32 board. Simply open preferences and add this link to the "Additionnal Boards Manager URLs" : https://espressif.github.io/arduino-esp32/package_esp32_index.json

     Then you should see your ESP32 board into the board Manager menu

    For the Lolin32 lite be sure to select version 1.0.6

    Libraires installation

    You will need to install a few libraries before compiling your Weather Station... Most of them are installed via the Libraries Manager.

    But the Farm Data Relay System one has been patched for my own needs. I strongly recommand that you take a while reading these detailled explainations why I made these modifications. Read the Rezodo project log devoted to this topic.

    To facilitate your life I have packaged the modded library into a zip file available on my github project.

    Simply install this library via the "add zip Library" menu.


    Now you will need to install the following libraries via the "Manage libraries" menu

    Radiolib for Lora communications

    WifiManager to configure your Wifi Credentials

    Telnet Stream for (optionnal) Telnet debugging

    Time for NTP time synchro

    DS1302 for RTC chip

    SolarCalculator to know Sun hours for your location

    All this being done you should be able to compile your Weather Station without error !

    But still missing to configure it !

  • Weather station anemometer

    JP Gleyzes06/30/2023 at 09:34 0 comments

    The anemometer is a simple sensor. 

    3 cups are rotating into the wind and a hall sensor counts the turns !

    The cups are fixed with a 4mm screw that you will have to trim a the right dimension for the magnet to fly in front of the hall sensor.

    On this picture the top nut is inserted into the 3D printed part using the now classical "color change" method !

    The hall sensor is kept in place into the 20mm PVC pipe.

  • Anemometer calibration

    JP Gleyzes06/24/2023 at 08:14 0 comments

    Let's start by the anemometer which is probably the most complex to calibrate

    Anemometer calibration

    The anemometer outputs one tick every full rotation of the cup. So it's easy to compute the RPM value if you count the ticks and divide this value by the time of measurement.

    One could find an approximate value of the wind speed by calculating the distance a cup does in a full rotation.

    You can discover the radius of the circle made by the anemometer by measuring the distance from the centre to the edge of one of the cups. Once you know the radius, you can find the circumference with the formula 2 * pi * radius. 

    Speed (m/min ) = RPM * 2 * pi * radius 

    But this would give very unacurate value as you don't take into account the real efficiency of the cup, the drag of the arms, the loss into the bearing etc...

    So I decided to try a "brute force" approach: install the anemometer into a car window, measure the RPM of the cups and measure the speed of the car... Assuming that you choose a no wind day you should get a good relation between rpm and (car/wind) speed.

    So I have coded a small android application which receives from the anemometer the RPM and which reads the GPS speed of the smartphone, (thus of the car, thus of the wind !).

    All the values are recorded and can be exported into a .csv file.

    I tried to drive at constant speed, but this wasn't possible due to trafic... Here is the speed profile of my trip:

    It lasted 15 minutes (x axis in seconds). And I could reach 110 km/h. (y axis)

    Then you can open this file into excel and plot speed as a function of RPM and finally sort the values in ascending rpm. 

    And the magic is there, you almost get a linear behavior. This was expected but seeing it is a pleasure !

    And now you can let Excel help you to fit a linear curve on the values.

    And the result is not that bad! (noise of the speed of my car is pretty much filtered).

    The anemometer has proven to work in the range 5km/h to 110km/h and could for sure sustain higher wind speed... but not tested into my car !

    Speed in km/h can be derived from the RPM of the cup by the formula Speed = 0.105 * RPM

    This formula is now embeded into the firmware and my anemometer is calibrated. If you 3Dprint the cups at the same dimension and use the same ball bearing, then this formula  shouldn't need to be changed for your anemometer !

View all 14 project logs

Enjoy this project?

Share

Discussions

rituparna.sonowal wrote 09/05/2023 at 09:48 point

2.5Km.. Cool

  Are you sure? yes | no

JP Gleyzes wrote 6 days ago point

It could be more !

Tested this lora ESP32 module up to 8km (with SF12, short message and line of sight)

  Are you sure? yes | no

aaaaaa wrote 09/04/2023 at 15:24 point

weather station is ideal for mesh network 

  Are you sure? yes | no

John Lamport wrote 08/30/2023 at 19:49 point

Do you have one 18650 battery? I had a similar system, also solar charging, had the ESP32 going to sleep for 15 minutes, update date for a minute then back to sleep. I could get about 30 hours when the sun didn't come out before the battery died. How long can you get with out the charger? Thanks

  Are you sure? yes | no

JP Gleyzes wrote 08/30/2023 at 20:59 point

This is a very good question !

Have a look to this log : https://hackaday.io/project/191652-long-range-weather-station/log/222325-experience-feedback-rex-on-power-management

To summarize:

- I don't have the direct answer to your question as I didn't made this test  !

- The system has been running now for months (including very cloudy days) without issue

- the trick is : shut down every electronics while sleeping (done with a devoted voltage regulator with a "enable" pin)

- adapt wake up cycle between days and night. I do compute sunrise and sunset. Daytime cycle is every 2 minutes. Night cycle is every hour


- cross fingers that it still works during winter! If not I can delay day time cycle (every 2 minutes is probably too often for my use case ?) Or increase battery size ?

Meanwhile have a look to the panel voltage on this link : https://thingspeak.com/channels/2209680 (field 2 chart)

  Are you sure? yes | no

JP Gleyzes wrote 08/30/2023 at 20:59 point

and yes it's a single 18650

  Are you sure? yes | no

JP Gleyzes wrote 08/11/2023 at 05:56 point

2.5km was got with the 6.5cm wire antenna and with SF7.

But to secure transmission I am now with a biquad antenna for "reception" and a spreading factor of 12.

With this I can send and receive even behind trees at more than 2.5km. 

I tested it in line of sight at more than 8 km. lora is quite impressive !

  Are you sure? yes | no

Elbert wrote 08/10/2023 at 21:45 point

2.5 km is impressive. I was wondering which spreading factor (SF7
till SF12) you are using and if you could even get a longer range by
using a higher SF value (with lower bit rate however).  

  Are you sure? yes | no

JP Gleyzes wrote 2 days ago point

Yes SF12 gives highest range. I tested this device up to 8km in line of sight but with a dipole antenna I built a few years ago :  https://www.thingiverse.com/thing:2789234

For the weather station I added a Biquad antenna (without ground plane) on the "receiver" side : https://www.thingiverse.com/thing:6128519

But a simple piece of wire on the station side!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates