A weather monitoring system is a cool project that helps you learn the basics of electronics and with the added benefit of monitoring the weather conditions. It can be very useful in farms for knowing the local weather and understanding the patterns through stored historical data.
I was fascinated to make this project by seeing this project on the internet:
In this instructable, I am going to show you how to build a weather station using a bunch of cheap and affordable parts and sensors. The total cost for building this project is under $25. The station sends the data to a web app through which we can monitor Temperature, Humidity, Pressure, and Altitude. It's a pretty easy setup and you just need some basic electronic skills to get it going.
The features of this weather station:
- It can measure Temperature, Humidity, Barometric Pressure and Altitude.
- You can monitor the above values using a web app either from a Smartphone or a Laptop.
- The whole circuit along with the power supply is enclosed in an MDF Box.
- You can charge it using a Micro USB cable or even solar power.
Step 1: Parts and Tools Required
- NodeMCU Board V0.9 or 1.0
- DHT-11 for Temperature and Humidity
- BMP-280 for Barometric Pressure
- Rain Sensor (optional)
- LDO S111733PI
- 18650AA Rechargeable Li-ion Battery x1
- TP4056 Charging Board
- Solar Panel (5.5 to 6v/100-120ma)
- 10kohm Resistor x1
Other Materials and Tools:
- Perforated Board (PCB) x1
- AWG wires
- Screw Terminals x2
- Female Header Pins
- MDF sheet
- Soldering Iron
- Duct Tape
- Hot Glue Gun
- A micro USB cable
For Testing (optional):
- Jumper Wires
Step 2: Measuring the Weather Data
The NodeMCU Board:
The NodeMcu board is, in fact, an Arduino with a wifi shield. This wifi shield is called the esp8266. The shield can be bought and used as an individual controller, a well-known version is the esp8266 V1 which has only got 2 digital pins. The later version does have more digital pins.
So we use this wifi shield to transmit our sensor data to our web app using Thingspeak API's.
The DHT-11 has a successor named DHT-22 which is a little more accurate and consumes less power. You can distinguish between DHT-11/DHT-22 based on their color. Most of the DHT-11 sensors in the market are of Blue color where DHT-22 is in White.
The DHT-11 has 4 pins in order from the left:
- Vin (First one from the left)
The BMP-280 sensor is used to measure the Barometric Pressure. 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 used the I2C version board.
The Rain Sensor (optional)
The rain sensor detects water that completes the circuits on its sensor boards' printed leads. The sensor board acts as a variable resistor that will change from 100k ohms when wet to 2M ohms when dry.
I have used the Rain sensor in the testing phase but removed in the final project as Its use is not much effective in this project. You can use it if you need rain sensor in your project (I have written the respective code for the rain sensor too.)
Step 3: Connecting the Sensors
I can recommend you to connect the sensors one after the other, starting with the DHT11/DHT22 sensor. Once a sensor is working properly you can go on and add the next sensor.
Once Successfully connected, move to the Coding Phase.
- Data ------- D4
- Vin ---------- 3.36v
- Gnd --------- Gnd
- Put a 10k ohm resistor between Data and Vin
- SCL ------- D1
- SDA ------- D2
- Vin --------- 3.36v
- Gnd -------- Gnd
- Data ------ A0
- Vin -------- 5v / 3.36v
- Gnd ------- Gnd
Step 4: Coding
First, I tried several sketches available on the internet. I found out that most of the sketches were written in LUA language and therefore useless for me (as I thought to use Arduino IDE).
Then I started writing my own code and got successful.
Before executing the code, download the necessary libraries required for the microcontroller and the sensors. (Scroll down to get download links for the Libraries)
In the code below:
Enter Your Wifi SSID Name and Password.
As we are going to push our data to Thingspeak we have to make an account. Thingspeak is a cloud service. Next, to this, Thingspeak provides several options for interaction with your data such as Thingtweet, Thinghttp etc.
Simply go to thingspeak.com and make an account. Fill in at least the first and second field in the settings. If you connect a temperature and humidity sensor such as described in the next step, fill in 'temperature' in field 1, 'Pressure' in field 2 (check above Picture). If you want to connect other sensors such as the rain sensor simply do the same for the rest of the fields.
Now go to the API's section
Copy the API key and paste it in code.
Step 5: The Power Supply
My plan is to deploy the Weather station wire-free. To run it continuously, there must be a continuous power supply. The best way to provide continuous power to the circuit is by using a battery. But after some days the battery will run out, and it is a really difficult job to go there and charge it. So a solar charging circuit was used to use free energy from the sun to charge the batteries and to power the NodeMCU board. I have used a 18650 Li-Ion battery.
To charge the Battery without any complications (over-charge/over-discharge), I have used TP4056 charging board which perfect for 3.7v/1Amp. It has an inbuilt protection circuit which cuts off the connection with battery if the battery reaches its maximum value while charging or discharging.
In addition to the protection, it provides us the option to charge the battery using the micro USB cable as well as with the Solar Panel (through terminals). Thus we have multiple charging options.
Deep Sleep Mode (optional):
With the above setup, we can run the weather station using a solar panel (100mA) for about 10 hours per day. After that, we need to charge the battery using a charger to use the next day. It is not a big deal if you can turn it off when not needed or if you use the weather station in your home.
But if you want it to run continuously and place it in a remote location where you cannot reach frequently to turn it off, it becomes a problem.
To lower the power consumption of the ESP8266 WiFi chip, we’ll use the Deep Sleep mode which is the most power efficient option for ESP chip. It allows to put the ESP8266 into hibernation and saves the battery. You can wake up it at regular intervals to make measurements and publish them.
NodeMCU (max power consumption) --------------------- 170 mA
NodeMCU (In deep sleep) ------------------------------------ 0.02 mA
Average consumption for this project (based on the sensors used) -------------------------- 120 mA
If we take a 5min cycle (4.5 min deep sleep and 0.5 min for transmission)
4.5 min x 0.02 mA ---------------- 0.09 mA-mins
0.5 min x 120 mA ----------------- 60 mA-mins
5 mins ----------------------------- 60.09 mA-mins
Thus the entire Weather station requires 12.018 mA to run.
To run a day, it requires 12.018 x 24 = 288.432 mA
If we take an average of 3 hrs of sunlight per day. we can harvest 100mA x 3 = 300mA from the solar panel rated 5v/100mA per day.
Therefore, it is enough for running the weather station without any need for external charging.
Before using the deep sleep feature, NodeMCU D0 pin must be connected to the RST pin.
It is a Low-Dropout voltage regulator which gives a constant output of 3.3v for any input voltage. The output from the battery will not be a constant value as a fully charged battery can output 4.2v which fries the NodeMCU board. The NodeMCU board has a (5v and above) Vin slot as well as (3 to 3.36v) input voltage slot. All the sensors used in the project requires 3.36-3.6v and any above voltage will damage them or shows inaccurate data.
Thus the use of LDO is must to run the weather station for a long time.
Step 6: Assembling the PCB
After successful testing, its time for soldering the components to the PCB. For this, you will need a decent Soldering Iron, Solder, Nipper.
First I have cut the straight female header pin for NodeMCU Board, BMP-280, DHT-11, Rain Sensor, and LDO. It is good practice to solder the components according to their height. Solder the lesser height components first.
After assembling the header pins, and screw terminal, it is time to insert the boards into their respective headers.
I have attached the TP4056 board to the PCB using double-sided tape.
Finally, I inserted the 18650 battery into the battery holder.
note: I am Sorry for my Soldering Skills, this is my first time soldering and I am still practising :)
Step 7: Everything in One Box
It is time to build an enclosure for our PCB. I have used an MDF sheet of 3mm thickness to create a box. The Solar panel fitted perfectly on the top of it.
I have made two holes on either side of the box for Charging port and NodeMCU Coding port respectively. I won't be using the weather station in harsh conditions, so I didn't use any leakproof casing. But if your intention is to use the Weather Station effectively outside, then you can use some plastic or metal casing.
Step 8: Visualizing the Data
The Thingspeak Service provides you with a variety of graphs and plots to visualize the sensor data. Else you can even create your own web app and transmit data to it using Thingspeak Read API's.
Have fun building and learning! Please let me know what you think of this instructable. I would love to make some improvements if necessary.
Happy Coding :)
This is an entry in the