Cheapest Solar Powered Weather Monitoring System Using NodeMCU

About: I am a student, tech lover, programmer, web developer and a person who is gathering a lot from 'LIFE'

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:
https://www.instructables.com/id/Esay-IoT-Weather-Station-With-Multiple-Sensors/

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

Parts Required:

  1. NodeMCU Board V0.9 or 1.0
  2. DHT-11 for Temperature and Humidity
  3. BMP-280 for Barometric Pressure
  4. Rain Sensor (optional)
  5. LDO S111733PI
  6. 18650AA Rechargeable Li-ion Battery x1
  7. TP4056 Charging Board
  8. Solar Panel (5.5 to 6v/100-120ma)
  9. 10kohm Resistor x1

Other Materials and Tools:

  1. Perforated Board (PCB) x1
  2. AWG wires
  3. Screw Terminals x2
  4. Female Header Pins
  5. MDF sheet
  6. Soldering Iron
  7. Duct Tape
  8. Hot Glue Gun
  9. A micro USB cable

For Testing (optional):

  1. Breadboard
  2. 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

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:

  1. Vin (First one from the left)
  2. Data
  3. NULL
  4. GND


The BMP-280

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 Connections:

DHT-11

  • Data ------- D4
  • Vin ---------- 3.36v
  • Gnd --------- Gnd
  • Put a 10k ohm resistor between Data and Vin

BMP-280

  • SCL ------- D1
  • SDA ------- D2
  • Vin --------- 3.36v
  • Gnd -------- Gnd

Rain Sensor

  • 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.


Thingspeak API's

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.

Links:

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.

LDO S111733PI

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 :)

Remix Contest

This is an entry in the
Remix Contest

Share

    Recommendations

    • Remix Contest

      Remix Contest
    • Tape Contest

      Tape Contest
    • Epilog X Contest

      Epilog X Contest

    6 Discussions

    0
    None
    c2kpierce

    1 day ago

    Great project!

    I'm not getting any data from the module on the ThingSpeak website even though I'm getting data on the serial output. I have the correct API write key. Is there something i'm missing?

    2 replies
    0
    None
    Abhinav Peddic2kpierce

    Reply 1 day ago

    The delay time is 15 seconds (sometimes it takes more than that, depending on the internet speed). Did you check your internet? (Because the code checks only for router connection not the internet) and if possible can you show me the screenshot of thingspeak and serial data? So that it will be easier for me to know the actual problem.

    0
    None
    c2kpierceAbhinav Peddi

    Reply 7 hours ago


    ....
    ets Jan 8 2013,rst cause:4, boot mode:(3,5)
    wdt reset
    load 0x4010f000, len 1384, room 16
    tail 8
    chksum 0x2d
    csum 0x2d
    vbb28d4a3
    ~ld
    Connecting to c2k_air
    ...................................................................................................................................................................................................................................................................................................
    WiFi connected
    Could not find a valid BME280 sensor, check wiring!
    Temperature = 0.00*C ||Pressure = 0.00mmHg ||Altitude = 44330.00mFailed to read from DHT sensor!
    ||rain not detected
    Temperature = 0.00*C ||Pressure = 0.00mmHg ||Altitude = 44330.00mFailed to read from DHT sensor!
    ||rain not detected
    Temperature = 0.00*C ||Pressure = 0.00mmHg ||Altitude = 44330.00m ||Temperature dht: 23.20*C ||Humidity: 41.10 ||rain not detected
    Temperature = 0.00*C ||Pressure = 0.00mmHg ||Altitude = 44330.00m ||Temperature dht: 23.20*C ||Humidity: 40.20 ||rain not detected
    Temperature = 0.00*C ||Pressure = 0.00mmHg ||Altitude = 44330.00m ||Temperature dht: 23.30*C ||Humidity: 39.80 ||rain not detected
    Temperature = 0.00*C ||Pressure = 0.00mmHg ||Altitude = 44330.00m ||Temperature dht: 23.30*C ||Humidity: 39.40 ||rain not detected
    Temperature = 0.00*C ||Pressure = 0.00mmHg ||Altitude = 44330.00m ||Temperature dht: 23.30*C ||Humidity: 39.40 ||rain not detected
    Temperature = 0.00*C ||Pressure = 0.00mmHg ||Altitude = 44330.00m ||Temperature dht: 23.30*C ||Humidity: 39.10 ||rain not detected
    Temperature = 0.00*C ||Pressure = 0.00mmHg ||Altitude = 44330.00m ||Temperature dht: 23.30*C ||Humidity: 39.20 ||rain not detected
    23.10*C ||Humidity: 38

    screenshot.png
    0
    None
    Sanchit2723

    Question 9 days ago

    Could I use a solar panel with output voltage lesser than 6volts for this project?

    1 answer
    0
    None
    Abhinav PeddiSanchit2723

    Answer 9 days ago

    A typical 3.7v battery needs atleast 5.5v of input voltage to start charging. That is the reason, the output voltage rating of chargers (such as mobile chargers...) starts from 5v.