-
Configuring your Weather Station
07/17/2023 at 15:22 • 2 commentsSensors 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. if (client.connect(thingserver, 80)) { client.println("POST /update HTTP/1.1"); client.println("Host: api.thingspeak.com"); client.println("Connection: close"); client.println("User-Agent: ESP32WiFi/1.1"); client.println("X-THINGSPEAKAPIKEY: " + writeAPIKey); client.println("Content-Type: application/x-www-form-urlencoded"); client.print("Content-Length: "); client.print(data.length()); client.print("\n\n"); client.print(data); delay(300); #ifdef DEBUG_TELNET TelnetStream.print("temperature = "); TelnetStream.print(sensorValues[1][0][0]); TelnetStream.print(" °C humidity = "); TelnetStream.print(sensorValues[1][1][0]); TelnetStream.print(" % pressure = "); TelnetStream.print( sensorValues[1][2][0]); TelnetStream.println(" hPa"); TelnetStream.print("rot speed = "); TelnetStream.print(sensorValues[1][3][0]); TelnetStream.print(" km/h wind direction = "); TelnetStream.println(sensorValues[1][4][0]); TelnetStream.print("rain weight = "); TelnetStream.print(sensorValues[1][5][0]); TelnetStream.println(" g"); #endif } else { #ifdef DEBUG_THINGSPEAK Serial.println("==> ThingSpeak: failed to connect "); #endif } #ifdef DEBUG_THINGSPEAK // Just for testing, print out the message on serial port Serial.println("==> ThingSpeak POST message "); Serial.println(data); #endif client.stop(); } }
Bear in mind that all the sensors can arrive from the GTW1 but also from other gateways when the GTW0 is connected to a wider Rezodo network...
Values are stored into this array:
float sensorValues[100][100][1]; //sensorValues[GTW, sensorIndex, value];
100 gateways, 100 sensors per gateway and only one value per sensor !
If you want to setup a "big" Rezodo network, please read all the details into this project: https://hackaday.io/project/190577-rezodo-long-range-irrigation-and-weather-station
-
Weather Station firmware
07/17/2023 at 14:31 • 0 commentsFirmware 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
06/30/2023 at 09:34 • 0 commentsThe anemometer is a simple sensor.
3 cups are rotating into the wind and a hall sensor counts the turns !
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
06/24/2023 at 08:14 • 0 commentsLet'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 !
-
the wind direction sensor
06/24/2023 at 08:06 • 0 commentsAn AS5600 hall encoder is used to determine wind direction.
This sensor gives 4096 angular positions which more than enough for a precise sensor
More precisely 2 more M4 nuts are hidden into the head part to help balancing the sensor
Now cut 130 mm long part into a 4 mm leadscrew. And mount the Wind Direction sensor.
Balance the sensor so that it stays horizontal in this position.
You should find the sweet spot at 25 mm from the tail. Adjust for your setup before tightening the axis screw and nuts.
Then you will have to solder 4 wires to the AS5600 breadboard. insert the wires from back side so that they will not touch the rotating magnet.
Only solder VCC, Gnd, SDA and SCL wires.
Then slide the breadboard into the pipe holder.
Trim the 4 mm screw so that the magnet flies 2mm under the AS5600 sensor.
(The orange ribbon on the picture is the hall sensor harnest for the anemometer. It takes the same route into the pipe to reach the weather station main board !).
-
the rain gauge
06/24/2023 at 08:03 • 0 commentsThe principle of operation of a weighing rain gauge is simple:
- collect the rain into a bucket with a calibrated funnel
- weight the bucket
- from time to time empty the bucket
Here is my 3D printed design (stl files available on thingiverse)
The funnel
The inner diameter of this funnel is precisely 112.83mm. Thus its surface is Pi x 112.83² / 4 / 1000000 = 0.01 m²
That is 1 / 100 m²
In countries that use the metric measurement system, meteorologists measure rain volume received in a unit of time which is usually expressed in the form of millimeters (mm) per hour. However, 1 mm of rain refers to the "depth" of rain that would be received in 1 meter² (m²) or a square of one meter in length and width.
Knowing that 1mm of rain corresponds to 1 liter of water, that is 1 kg of mass, our funnel will sample 1/100 of the rain received on 1 m².
Thus if we weight this sample (in kg) we will get 1/100th of the rain level. Simple !
The bucket
This bucket should be as simple and light as possible. It should not touch the servo arm when in idle position. This allows accurate reading of the weight (bucket + rain).
It should have a center of gravity below the axis of rotation to keep a vertical position when empty (or with rain inside).
Its weight is 23g, which should be considered as the "tare" of the load cell. (however tare is automatically done during the measurement process)!
The loadcell
I have choosen a very sensitive loadcell
It has an accuracy of 0.1g and a max load of 100g
Knowing that the bucket weights 23g, when empty, we have a max volume of water of 100-23 = 77g
Let say 50g max before emptying the bucket with the servo.
50g of water into the funnel would represent a rain fall of 0.05 x 100 = 5mm
If we empty the bucket every 2 minutes (that is 30 times per hour) we could measure up to 5*30 = 150mm of water per hour. Which is an enormous rain fall in France... Have a look to national statistics on this site
On the other side, this load cell can measure down to 0.1g that is 0.1 / 1000 x 100 = 0,01 mm of rain (negligible)
To summarize: our Weather Station could measure between 0 and 150mm of rain per hour.
tightness
The 3d printed enclosure takes care of tightness of the system.
The funnel is protecting the servo, but the bucket can drop water on the bottom side of the Weather Station. This is the reason why the electronics is hidden into a waterproof box. Bottom vents are however made into this box to allow cooling of the temperature sensor...
-
Weather Station PCB
06/24/2023 at 07:59 • 0 commentsSoldering this board is fairly easy.
Assembly of the weather station has now started and seems promizing!
As explained in the schematics part I discoverd "power management" issues... These issues have been fixed on the version 2 of this board
Version 2 of this board
This is the latest version. If you order the PCB will get it (previoud version are no longer available)
This PCB has been sponsored by PCBWay. Thanks for this !
You can order them here : WeatherStation @PCBWay
-
Weather Station schematics
06/24/2023 at 07:55 • 0 commentsThe trickiest part of this electronics is the power management...
The first schematics was quite simple:
- As usual a TP4056 chip was used to charge the 18650 Li-ion battery
- Then in order to save battery during ESP32's deepsleep I added a P mosfet to cut power
And here came the first problems... This Mosfet was working rather well and, as expected, allowed to switch off most of the sensors during deepSleep.
But, when switching On, the current flow added to the ESP32's voltage regulator was too high (from time to time) for this weak voltage reg ... VCC and 3.3V dropped and ESP32 started to stall (best case) and even to reboot in worst conditions.
Looking at the ESP32 lolin board schematics I found the culprit : ME6211C33M5G regulator is limited to 500mA output current...
So I had to modify a little the board to add a second voltage regulator which will be used only for powering the sensors.
The idea was to keep a ME6211 to take benefit of the "Enable" pin of this chip. So that it would replace the P-Mosfet of the first schematics and allow to "deepSleep" the sensors.
R7 resistor acts to pull down the enable pin, when PWR signal is floating (ESP32 into deepsleep) then the VREG1 chip is off. When PWR pin is at "high" state then the VREG1 outputs 3.3V --> nice !
This has been tested on the first version of my PCb's after a quick and dirty patch...
This patch has proven to work. But the V1 PCB was now "ugly"... So I asked PCBWay to help me once more !
And here is the final schematics:
The rest of this schematics is self explainatory and is the same between V1 and V2. However you should be careful with the following details:
- V_PANEL can be used to monitor solar panel voltage via the R1/R2 voltage divider. In this configuration you MUST NOT solder R4 resistor
- V-PANEL can be used to monitor battery voltage via the voltage divider R4/R2. In this configuration you MUST NOT solder R1 resistor.
- J1 solder pad is, by default, sending VREG1 output to the Lora RFM95 chip. if you prefer to always power this module then cut J1 "left side" and bridge J1 "right side". RFM95 module would then be powered by ESP32 voltage regulator. (this can be useful for the GTW0 board (see later).