In this Instructable, we will learn how to make a Solar-powered wireless weather station by using an ESP32 Wifi Module and few common weather sensors available in the market. The weather station is fully solar-powered, so no need to worry about the external power supply. You can install it in a remote place without laying long cables to provide power.
I have earlier posted two Instructables on Weather Stations ( Version -1.0 and Version-2.0) that were based on Wemos ( ESP8266) and are very popular on the internet. Based on the user’s feedback, I tried my best to make a more powerful weather station by including some new features.
This Weather Station is such compact weather station that consists of several meteorological sensors that measure the following parameters:
1. Internal Temperature (BME280)
3. Barometric Pressure (BME280)
4.External Temperature (DS18B20)
5. Wind Speed ( Sparkfun Weather Meter )
6. Wind Direction ( Sparkfun Weather Meter )
7. Rain Gauge ( Sparkfun Weather Meter )
8. UV Index ( SI1145)
9. Lux Level ( BH1750 )
I have designed a customized PCB for this project. It is designed in such a way that you can conveniently integrate different combinations of sensors according to your actual application needs.
Full Video Tutorial:
Why a Weather Station?
Imagine you are residing at a place that is far away from the meteorological department. In such a case, the weather predictions you get may not be the most precise. This is where home weather stations become more advantageous. This small weather station can provide accurate data regarding the weather parameters of where you live.
Today, data on localized weather, known as microclimates, is the new frontier for more precise and accurate weather forecasting. As a result, the collection of weather data is becoming increasingly smaller and gridded.
The applications of this type of small portable weather station are vast in the area of smart agriculture, smart city, solar power plants, construction site, etc.
8. MCP1700-3.3V ( Amazon)
12. TVS Diode – DT1042-04SO ( Amazon ) – Optional
13. RJ11 Connector ( Amazon )
17. Screw Terminal -3P -3.5mm pitch ( Sparkfun )
19. 18650 Battery ( Banggood )
24. PCB ( PCBWay )
Step 1: Selecting the Power Supply
If you are planning to install the weather station at a remote location like your farmhouse, you may not get access to the power grid to run the weather station. To run the station continuously, there must be a continuous power supply otherwise the system will not work. The best way to provide continuous power to the circuit is by using a battery. But in the case of the battery, after some days of run, its juice will run out, and it is a really difficult job to go there and charge it. So a solar charging circuit was proposed to use free energy from the sun to charge the battery and to power the ESP32 board.
Here, I have used a 18650 Li-Ion battery. The battery is charged from a Solar panel through a TP4056 charging module. The TP4056 module comes with a battery protection chip or without the protection chip. I will recommend buying a module that has a battery protection chip included.
The 18650 battery outputs 4.2V when fully charged. The battery voltage is further step down to 3.3V by using a low dropout voltage regulator(MCP1700-3302E).
The output from the voltage regulator will power the ESP32 through the 3.3V pin.
Step 2: Power Supply Circuit
The operating voltage of the ESP32 is 3.3V whereas the fully charged battery voltage is 4.2V. So we have to step down the battery voltage from 4.2V to 3.3V, which can easily be done by a linear voltage regulator but unfortunately, it is not at all recommended for this project. Because all the linear regulators require an input voltage at least some minimum amount higher than the desired output voltage. That minimum amount is called the dropout voltage. Due to this reason when battery voltage drops to around 3.7V, the linear voltage regulator will not able to maintain the voltage required voltage ( 3.3V ).
The solution to the above problem is to use a low-dropout or LDO regulator. A low-dropout or LDO regulator is a DC linear regulator which can regulate the output voltage even when the supply voltage is very close to the output voltage. Here we will use an MCP1700 LDO for efficiently powering the Circuit.
A ceramic capacitor ( 0.1uF) and an electrolytic capacitor (100uF) are connected in parallel to the GND and Vout pin of the LDO ( MCP1700 -3.3V ) to smooth the voltage peaks.
The output of the MCP1700 is connected to the ESP32 3.3V pin through a slide switch.
MCP1700 Data Sheet: Download
Step 3: Wind Vane ( Wind Direction Sensor)
The wind vane indicates the direction that the wind is blowing. It is the most complex of the sensors in the Sparkfun Weather Sensor Kit. It has eight reed switches, each connected to a different resistor. As the wind vane rotates, a magnet closes the reed switches and may close two at a time due to their proximity to each other, allowing up to 16 different positions to be indicated. However, in testing the unit, I never could make the device close two switches at once, so although it might be possible theoretically to measure 16 directions, I only get eight. The software takes 16 directions into account, just in case.
An external resistor can be used to form a voltage divider, producing a voltage output that can be measured with an analog to digital converter, on your the microcontroller allows you to determine the direction of the wind vane pointer.
To measure voltage output, I have used a 10kohm external resistor to form a voltage divider with the wind vane resistor ( Rvane). The 10K resistor is connected to 3.3V as shown in the above figure. Then, I connect the middle of the divider to the ESP32 ADC pin (GPIO 35), measure the voltage, and by referring to the table shown above, convert to the wind direction.
The reed switches and resistors arrangement are shown in the above picture. Resistance values for all 16 possible positions are given in the table.
When the wind vane pointer falls in between two switches, the resistance value is considered as the equivalent resistance between the two adjacent resistances. In this situation, the vane’s magnet activates two switches simultaneously, as result they are connected in parallel.
When the wind vane pointer falls in between the Switches S1 and S2, the equivalent resistance is determined by the following formula:
Rvane = R1x R2 / ( R1+R2 ) = 33 x 8.2 / ( 33 +8.2 ) = 6.57K
Since the values outputted by the wind vane are based on degrees, you can, in theory, have any value represent any direction. However, it is recommend having the value at degree 0 represent North for ease of use.
Step 4: Anemometer ( Wind Speed Sensor)
The wind speed sensor is a cup-type anemometer measure wind speed by closing a contact as a magnet moves past a reed switch. As per the datasheet, a wind speed of 2.4km/h (1.4912 mph) causes the switch to close once per second. The anemometer switch is connected to the inner two conductors of the RJ 11 cable shared by the anemometer and wind vane (pins 2 and 3).
The Anemometer is connected to the ESP32 GPIO pin 14 and GND. After that, all we need to do then is to monitor for button presses which is pretty straightforward. We can use the pin interrupts method to monitor the button press ( tips). When the reed switch closes the circuit (pressing the button), it triggers a software event.
If you want to make your own wind sensor, then read this nice Instructable
These are few more 3D printed Wind Sensors:
Step 5: Rain Gauge ( Rain Fall Sensor )
Here I have used a most common type of Rain Sensor which is called a Tipping Bucket rain gauge. Basically, there’s a little see-saw shape tipper bucket inside the sensor ( see the above picture ). The rain fills up a bucket on one end and it tips over so that it empties and the bucket on the other side starts to fill. Each time the bucket tips it passes a magnet over a reed switch making a momentary electrical connection. The buckets are calibrated to a volume of water, which means if we can count how many times the switch closes we can calculate how much rainfall there’s been.
Much like the wind speed gauge, the rainfall gauge generates ticks to tally the amount of rain that has fallen. Count ticks to determine how much rain has fallen recently. Each tick represents 0.011″ ( 0.28mm ) of rainfall. This sensor is connected to pin 25 of the ESP32.
The rain gauge that I have used here is from Sparkfun. It has an RJ-11 plug on the end, you can directly plug it into the Weather Station V3.0 PCB.
You can make your 3D printed Rain Gauge by following this article
Step 6: Measuring the Rainfall
In the previous step, we have discussed that each time the bucket tips, it passes a magnet over a reed switch making a momentary electrical connection. Here each tip of the bucket in the rain gauge can be assumed as a button press. We can easily then connect the gauge as if it were a button.
The rain gauge is connected to the ESP GPIO pin 25 and GND. After that, all we need to do then is to monitor for button presses which is pretty straight forward. We can use the pin interrupts method to monitor the button press ( tips). When the reed switch closes the circuit (pressing the button, the bucket tipping), it triggers a software event.
Here I am using attachInterrupt()to monitor the number of tips. You can find the details from Arduino Page.
Step 7: Monitoring Pressure ,Temperature and Humidity by BME280
In the earlier days, weather parameters like ambient temperature, humidity, and barometric pressure were measured with separate analog instruments: thermometer, hygrometer, and barometer. But today the market is flooded with cheap and efficient digital sensors that can be used to measure a variety of environmental parameters. The best examples are sensors like DHT11, DHT 22, BMP180, BMP/E280, etc.
In this project, we will use BMP280 / BME280 sensor.
BMP280: BMP280 is a sophisticated sensor that very accurately measures barometric pressure and temperature with reasonable accuracy. The BME280 is the next-generation of sensors from Bosch and is the upgrade to the BMP085/BMP180/BMP183 – with a low altitude noise of 0.25m and the same fast conversion time. The advantage of this sensor is that it can use either I2C or SPI for communication with the microcontroller. For simple easy wiring, I will suggest buying the I2C version board.
BME280: The new BME280 sensor, an environmental sensor with temperature, barometric pressure, and humidity. The BME280 is the next-generation of sensors from Bosch and is the upgrade to the BMP280. This precision sensor from Bosch is the best low-cost sensing solution for measuring humidity with ±3% accuracy, barometric pressure with ±1 hPa absolute accuracy, and temperature with ±1.0°C accuracy. It can be used in both I2C and SPI.
Note:BME280 can measure humidity but BMP280 can’t. In the market, BMP280 is also available by the name of BME280. So be sure whether it is a BMP280 or BME280.
You can read this nice article on BME280 for a better understanding.