In this article, we will learn how to make a solar-powered wireless weather station. The build is based on the ESP32 Wifi module and several common weather sensors available on the market. The big plus is that the weather station is completely solar powered, so there is no need to worry about an external power source. In this regard, it can be installed anywhere, the main condition is the presence of communication.
Previously, the master already had experience in the manufacture of such devices, and this is his third such work, in which he tried to correct all the shortcomings of the previous ones, as well as expand the functionality based on user feedback.
Although this is a financially costly project and not everyone will do it, after reading the article, readers will learn a lot about different sensors and how to work with them.
Tools and materials: – ESP32 board; – TP4056 lithium battery charging module; – BME280 barometric pressure sensor; – Waterproof temperature sensor DS1820; – UV index sensor – GY1145; – Light level sensor (luxometer) – BH1750; – Wind and rain sensors ; -Voltage regulator MCP1700-3.3V; -Resistors – 2 x 1 kOhm, 1 x 10 kOhm, 3 x 4.7 kOhm, 1 x 27 kOhm, 1 x 100 kOhm; -Electrolytic capacitor 100 uF; -Ceramic capacitors 0, 1 μF – 4 pcs; – Diode array of electrostatic discharge suppressor (option); – RJ1 connector; – Pin connectors; – Jumper 2.54 mm; – Screw clamp 2 terminals; – Solar panel – 5 V/1.2 W (110 x 69 mm); – Battery 18650; -Battery holder 18650; -Wires; -Connecting wires; -Slide switch; -Printing board; -Soldering accessories; -Nippers; -Wire stripper; -3D-printer;
Step one: about the weather station
This meteorological station is a device that consists of several meteorological sensors. The sensors measure the following parameters :
1. Internal temperature (BME280)
2. Humidity (BME280)
3. Barometric pressure (BME280)
4. Outside temperature (DS18B20)
5. Wind speed (Sparkfun meteometer)
6. Wind direction (Sparkfun meteometer)
7. Rain gauge (Sparkfun meteometer)
8. UV Index (SI1145)
9. Lux Level (BH1750)
The craftsman designed a custom PCB for this project. It is designed in such a way that the user can easily integrate various combinations of sensors according to actual needs.
This type of small portable weather station can be widely applied in the fields of agriculture, smart city, solar power plants, construction sites, etc.
Step two: power supply
If you plan to install the weather station in a remote location, you may not have access to an electrical outlet to power it. For continuous operation of the station, a constant power supply is required, otherwise the system will not work. The best way to provide continuous power to the circuit is to use a battery. But in the case of the battery, after a few days of operation, it will be discharged. The wizard proposes a solar charging scheme that would use free energy from the sun to charge the battery and power the ESP32 board.
The master uses a lithium-ion 18650 battery for power supply. The battery is charged from the solar panel through the TP4056 charging module. TP4056 module must be used with battery protection circuit when charging.
The 18650 battery supplies 4.2V when fully charged. The battery voltage is lowered to 3.3V using the voltage regulator.
The voltage regulator output will power the ESP32 via the 3.3V pin.
Using a typical linear voltage regulator to pull the voltage down from 4.2V to 3.3V is not a good idea. When the battery is discharged to, for example, 3.7V, the voltage regulator will stop working because it has a high cut-off voltage. To effectively reduce the voltage, it is necessary to use a low dropout regulator that can regulate the output voltage.
Ceramic capacitor (0.1uF) and electrolytic capacitor (100uF) are connected in parallel to the GND and Vout pins of the LDO (MCP1700 -3.3V) to smooth out voltage peaks.
The output of the MCP1700 is connected to the ESP32 3.3V pin via a slide switch .
Step three: weather vane (wind direction sensor)
The weather vane shows the direction of the wind. This is the most complex of the sensors in this device. It has eight reed switches, each connected to a different resistor. When the weather vane rotates, the magnet closes the reed switches and can close the two at the same time due to their close proximity to each other. This expands the accuracy of readings to 16 positions and the program (code) takes this into account.
An external resistor is used for a voltage divider that allows you to determine the direction of the vane pointer.
The master used an external 10 kΩ resistor to measure the output voltage. The 10k ohm resistor connects to 3.3V as shown in the figure below. It then connects the middle of the divider to the ESP32 ADC pin (GPIO 35). Measures voltage and, according to the table, converts to wind direction readings.
The location of the reed switches and resistors is shown in the figure below. Resistance values for all 16 possible positions are shown in the table.
When the pointer of the vane falls between two contacts, the resistance value is considered to be the equivalent resistance between two adjacent resistances. In this situation, two switches are activated at the same time, with the result that they are connected in parallel.
When the vane pointer falls between switches S1 and S2, the equivalent resistance is determined by the following formula:
Direction = R1x R2/(R1 + R2) = 33 x 8.2/(33 +8.2) = 6.57 K
Since the values given by the weather vane are in degrees, it is recommended that the value in degrees 0 indicates to the north.
Weather vane calculation.rar
Step four: anemometer (wind speed sensor)
The wind speed sensor is a cup anemometer that measures wind speed by making contact when a magnet moves past a reed switch. According to the datasheet, a wind speed of 2.4 km/h (1.4912 mph) causes the switch to close once per second.
Anemometer connected to GPIO pin 14 of ESP32 and GND. When the reed switch closes the circuit (pressing the button), a program event is triggered.
Step five: rain sensor
The technician used the most common type of rain gauge called a tipping bucket rain gauge. Essentially, there is a small swing-shaped tipping bucket inside the sensor. Water (rain) fills the container (swing) from one side, it goes down and the water is poured out. Then the bucket is filled from the other side. Each time the bucket tilts, a reed switch is activated. The buckets are calibrated by volume, which means that by counting the number of times the switch has been triggered, you can calculate how much rainfall has occurred.
Each mark represents 0.011 inches (0.28 mm) of rainfall. This sensor connects to pin 25 of ESP32.
The wizard uses attachInterrupt () to track rainfall. Details can be found on the Arduino page.
Step Six: Monitoring Pressure, Temperature and Humidity with BME280
This project will use a BMP280/BME280 sensor.
BMP280: The BMP280 is a sophisticated sensor that measures atmospheric pressure and temperature very accurately with reasonable accuracy. The BME280 is a new generation of sensors from Bosch. The advantage of this sensor is that it can use either I2C or SPI to communicate with the microcontroller. For ease of connection, the wizard suggests buying a board of the I2C version.
BME280: New BME280 sensor, an environmental sensor that measures temperature, atmospheric pressure and humidity. BME280 is a new generation of sensors from Bosch, updated to BMP280. This precision sensor from Bosch is the best low-cost solution for measuring humidity with ± 3% accuracy, atmospheric pressure with ± 1 hPa absolute accuracy, and temperature with ± 1.0 ° C accuracy. It can be used with both I2C and SPI. < br> Note. BME280 can measure moisture, but BMP280 cannot.
Step Seven: UV Index Monitoring – SI1145 Sensor
The Si1145 is a calibrated UV sensor that can calculate the UV Index. It can communicate using the I2C protocol (address 0x60). It is possible to connect this sensor to the I2C port on the board, which is located in the lower left corner of the ESP board.
The SI1145 sensor does not actually have a real UV sensor. Instead, it measures the flux of visible and infrared light, and uses a formula to calculate the UV Index to two decimal places.
If a more accurate UV index measurement is required, the VEML6070 sensor can be used.
Step eight: control of the light level – sensor BH1750
The BH1750 ambient light sensor module is based on the BH1750FVI light sensor chip. This is a digital IC with a built-in 16-bit light-to-digital converter.
The output of this sensor is expressed in lux, so no further calculations are required. Lux is a unit of measure for luminous intensity. It measures intensity based on the amount of light falling on a specific area. One lux equals one lumen per square meter.
The BH1750 Ambient Light Sensor IC uses the I2C bus interface to communicate with external devices such as the ESP32.
VCC – 3 , 3V
GND – VCC
SCL – SCL
SDA – SCL
ADD – I2C Device Address (open)
Step nine : external temperature sensor
If required, an external temperature sensor, eg DS18B20, can be connected to monitor the ambient temperature. DS18B20 comes in TO92 package. It uses a single-wire protocol to communicate with the ESP32. It can be connected to a 3-pin screw terminal on the PCB.
To interface with a DS18B20 temperature sensor, you need to install the One Wire library and the Dallas temperature library.
Step ten: battery voltage monitoring
The weather station is powered by a 18650 lithium-ion battery, therefore it is very important to monitor the battery condition One way to do this is to read the battery output voltage using the ESP32 analog pin.
However, the battery used here gives a maximum of 4.2 V when fully charged, and the ESP32 GPIOs run at 3.3 V. So you need to add a voltage divider so that you can read the voltage from the battery.
The voltage divider formula looks like as follows :
Vout = (Vbat * R2)/(R1 + R2)
So, if you use R1 = 27 kΩ, and R2 = 100 kΩ,
We get: 1 Vout = (4.2 * 100k)/(27k + 100k) = 3.307V
You can use this online calculator to select voltage divider resistance values.
Step Eleven: ESP32 – Power Saving
The heart of the weather station is the energy-intensive ESP8266 SOC chip. To run the ESP32 on battery power, you need to reduce power consumption. To do this, the wizard will use deep sleep mode, which is the most energy efficient option for the ESP chip. This allows the ESP32 to go into sleep mode and conserve battery power. ESP can be activated regularly to take measurements.
Battery life calculation:
The ESP32 draws about 75mA during normal operation and about 150mA when transferring data over Wi-Fi. The data transfer time takes about 30 seconds. In deep sleep mode, the power consumption is about 10uA.
Battery life calculation:
Battery used: 3400mAh/3.7V 18650 Li-ion
Transfer interval = 10 minutes (On time: 30 seconds, Standby time: 9 minutes 30 seconds)
Total transmissions/hour = 60/10 = 6
Power consumption per hour (on time) = 6 x 150 mA * 30/3600 = 7.5 mA
Sleep time = 6 x 10 μA * 570/3600 = 0.0095 mA
Total battery run time in hours = 3400/(7.5 + 0.0095) = 452.76 hours
Total device battery life = 452.76/24 = 18.86 days
The wizard has prepared an Excel spreadsheet for calculating battery life .
Battery life calculator.rar
Step twelve : choosing a solar panel
The amount of solar insolation (exposure of surfaces to sunlight) depends on where the user is in the world. To find out the amount of solar exposure in your area, you can use
“Global Solar Atlas”. Taking into account a minimum of 1 hour of full sunlight, the wizard makes calculations for choosing a solar panel.
From the previous step, it was concluded that the average current consumption is 7.5 mA. The charge required to run the device throughout the day = 7.5 mA x 24 hours = 180 mAh
The goal is to produce 180 mAh in 1 hour.
To charge the 3.7 V lithium-ion battery, a solar panel with 5 to 6 V.
Required solar panel rating = 180 mA at 5 to 6 volts.
Solar panel rated power = 180mA x 5V = 0.9W. Considering some losses, the master chose the solar panel with some margin.
Selected solar panel: 5 V, 250 mA (110 x 69 mm)
Step thirteenth : board
The master has developed a board for his device. You can order it by following this link.
Prepare pin connectors for mounting.
1. ESP board – 2 x 15 pins
2. BME280 – 1 x 4 pins
3. UV sensor – 1 x 4 pins
4. Lux level sensor – 1 x 4 pins
5. Spare I2C port – 1 x 4 pins
4. Jumper JP1 – 1 x 2 pins
Throughout the PCB, the smallest component is the TVS diode, which is the only SMD component used in this project. When mounting, make sure the dot on the PCB and the TVS diode match. The dot symbol represents pin number -1. This TVS diode does not affect the functionality of the weather station, it provides additional protection for the circuit.
Then he solders the resistors and ceramic capacitors.
Solders the regulator.
Then he prepares ESP for installation, installs pin headers.
Mounts two RJ11 connector, 18650 battery holder and screw connectors.
Installs the rest boards and sensors.
Step fourteenth : housing
The ideal housing for weather sensors is the Stevenson housing. This housing is a housing for weather sensors from rain and direct thermal radiation, while allowing air to circulate freely around them.
Housing consists of 6 parts:
2. Bottom plate
3. Bottom mount
4. Medium rings x 12
5. The top cover of the screen.
6. top cover for attaching the solar panel
7. Rod M6 x 4 pcs
It has a simple wall mount and a two-piece cover to insulate the heat transfer from the solar panel. V3.0 is designed with a top mounted UV index sensor. In addition, the top cover for installing the solar panel is further away from the main body to avoid transferring heat from the solar panel to the inside of the body.
Master used 1.75mm white PLA filament to print the parts.
Files for printing can be downloaded here.
Step fifteen: assembly
Now you can start assembling the device.
The assembly process is very simple, you just first need to fold the rings and install on the rods.
Framed fixes the board and installs it inside the case.
Connects rain and wind sensors. Connects two cables to the RJ11 (wind and rain sensor) connectors on the PCB. The connector is labeled Wind Sensor “and” Rain Sensor “.
Installs the solar panel.
The solar panel connector in the top cover is designed to install a solar panel size 110 x 69 mm.
You need to solder wires to the contact pads and connect them according to the diagram. Then he glues the panel to the body.
Sets UV -sensor. When installing the sensor, it is necessary to orient it correctly. The sensor is glued to the lid from the inside, and the hole must match the sensor of the sensor.
Connects the solar panel and UV sensor.
Solders 4 jumpers to the module contacts (VIN , GND, SDA and SCL). Puts wires through holes and seals with silicone.
Connects the red wire of the solar panel to the positive and the black wire to the negative terminal of the Solar In screw terminal on the PCB.
Then connect the wires from the UV sensor to the UV sensor connector (P2) on the PCB.
Step Sixteen: Software
The Arduino IDE needs to install support for the ESP32 board.
Before downloading the code, you need to install the following libraries:
An earlier version has two separate codes for Blynk and Thinspeak, but in this version the wizard wrote one piece of code. The user only needs to comment out one line of code for Blynk or Thingspeak. For example, if you are using it for Blynk app, the code should be as follows:
& lt; font face = & # 34; Monaco, Menlo, Consolas, Courier New, monospace & # 34; & gt; //configuration control constant for use of either Blynk or Thingspeak //const String App = & # 34; BLYNK & # 34; ; //alternative is line below const String App = & # 34; Thingspeak & # 34 ;; //alternative is line above & lt; br & gt; & lt;/font & gt;
Step seventeen : Uploading Sensor Data to ThingSpeak
First you need to create an account with ThingSpeak. Then you need to create a new channel in your ThingSpeak account.
Next you need to fill in field 1 – temperature, field 2 – humidity, field 3 – pressure, field 4 – UV index, field 5 – wind speed, field 6 – wind direction , field 7 for rain and field 8 for battery voltage.
In your ThingSpeak account, select “Channel” and then “My Channel”.
Click the name of your channel.
Then go to the “API Keys” tab and copy the “Write API Key”.
Open the Solar_Weather_Station_ThingSpeak code and replace the “WRITE API” with the copied “Write API Key”.
Step Eighteenth: Using Blynk
Blynk is the most popular IoT platform for connecting any hardware to the cloud, developing applications to manage it, and managing products at scale. More than 400 hardware models can be connected with Blynk Library, including ESP8266, ESP32, NodeMCU and Arduino.
Step 1 . Download the Blynk app.
1. For Android
2. For iPhone
To connect the Blynk app to the hardware, you need an authentication token.
1. Create a new account in the Blynk app.
2. Click the QR icon on the top menu bar. Create a copy of this project by scanning the QR code shown below. After successful discovery, the entire project will immediately be on your phone.
The wizard made the Sol Weather Station application.
To start using it:
1. Download Blynk App.
2. Tap the QR code icon and point the camera at the code below.
3. After the project is created, an authentication token will be sent by email.
To upload the Arduino code to the Wemos board, follow these instructions.
After installing the above libraries, paste the Arduino code shown below. Enter the authorization code from step 1, ssid and password of your router. Then upload the code.
Step nineteen: installing the weather station
Next, you need to install the weather station in a suitable place.
The location of the weather station is the most important part of the installation. If the weather station is located under a tree or canopy, the rainfall data measured by the station will be incorrect. Placing a weather station in an alley can create a wind tunnel effect on the anemometer, leading to erroneous wind readings. If you want to measure sunlight, you cannot place the sensor in the shade. Therefore, you need to make sure that there is enough free space around and above the weather station.
Everything is ready.
< a href = "https://usamodelkina.ru/uploads/posts/2021-04/1617227680_1-3.jpg" rel = "prettyPhoto">