A weather station is a fun project that teaches you a ton about electronics with the added benefit being an actually useful little device. The project requires a bunch of cheap parts and sensors totaling less than $15, and the whole thing ends up fitting in your hand. The station creates a web site that monitors temperature, dew point, humidity, pressure, light index, and rain (Thingspeak channel). It’s a pretty easy set up, and you’ll just need some basic electronics skills to get it going.

There are some other NodeMcu or ESP8266 weather stations published on the web. Nevertheless they do not include the sensors I used and often are programmed in the more difficult language: LUA. This weather channel has got the following (unique) characteristics:

This channel will stream the following sensor data to a Thingspeak channel:

  1. Temperature DHT11/22;
  2. Temperature BMP180;
  3. Humidity DHT11/22;
  4. Pressure BMP180;
  5. Dew point temperature DHT11/22;
  6. Altitude BMP180;
  7. Light intensity LDR;
  8. Rain value.

The specific materials needed for this project are mentioned per step. General materials needed are:

    • Breadboard;
    • Perfboard;
    • NodeMCU V0.9 or 1.0;
    • Some wires;
    • Micro USB to USB cable;
    • 2 '1N4001 1A 50V Diodes'
    • 3 '10K resistors'

    I estimate the costs of the project around 15$. (NodeMCU=4,76$, DHT22=3,10$ OR DHT11=1$, BMP180 = 3,50$, Rain sensor = 0.99$, additional materials such as perfboard, wires, 2 diodes, 2 resistors and 1 LDR, I estimate around 4$)

    Step 1: The NodeMcu Board

    As I am a newby, I bought the NodeMcu board for less than 6$, more or less per exident. I was looking for a board that could connect my projects to the internet. The NodeMcu board did look a lot like an arduino and therefore it felt very familar. At that time I had no idea of the big advantages of the board.

    The NodeMcu board is in fact an arduino with a wifi shield. You can reconise this shield by the metal plate on top of it. This wifi shield is called the esp8266. The shield can be bought and used as an individual controler, a well known version is the esp8266 V1 which has only got 2 digital pins. The later version (one of them is placed on top of the NodeMcu board) do have more digital pins.

    The big advantage of the NodeMcu board is that the board can be programmed in the arduino environment: arduino IDE. Also, the board consists of a 5 volt step down converter. You can safely connect the board by USB to your computer without having to buy a 3.3 volt stepdown module.

    If you want to buy a NodeMcu board you can buy either the 0.9 version or the 1.0 version. The only difference I know is that the 0.9 version is wider than the 1.0 version. Yyou can not use the 0.9 version on a broadboard and plug in wires next to it.

      I found a lot of tutorials on the internet where they programmed the board with LUA software. As I never used this software before I preffered to stay with the arduino IDE software.

      Programming the nodeMCU with arduino is easy!

      Simply open arduino IDE, the latest version (I use 1.6.6). Go to 'file' and click on 'preferences'. Add the following link in the field 'additional board URL':


      After this you can restart the software and you must be able to select the board in the board manager (V1.0 or V0.9).

      Pins of the NodeMcu

      A small note: when you are programming an NodeMCU board, the pin layout is slightly different from an arduino board. Use the image below to compare the pins. If you mention an GPIO pin in the sketch for the NodeMCU, you have to connect the wire to the pin indicated in the picture below. (google: 'NodeMCU pin map')

      For example: If you want to connect some sensor to D5, you have to mention pin 14 in your arduino code. In the code below and the corresponding Fritzing visualisation, the connections are already adjusted.

    Step 2: Connecting to Thingspeak

    As we are going to push our data to Thingspeak we have to make an account. Thingspeak is a cloud service. It is great, easy and looks realy cool! 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, 'humidity' in field 2 and 'dew point' in field 3. If you want to connect other sensors such as the BMP sensor, rain sensor, LDR, simply do the same forthe rest of the fields.

    You can find a key that you have to mention in your arduino sketch under the tap 'API key'. This key is necesarry to connect the arduino to the Thingspeak channel. See step 4 :)

    Step 3: Connecting the Sensors

    I can recomment 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.

    The DHT11/22

    This is a simple sensor to start with! The DHT22 is slightly more accurate compared to the DHT11 but is less costly. I started with the blue DHT11 but get enthusiastic and bought the white DHT22 soon after. As you can see in the image above I add all the sensors in the broadboard next to the NodeMcu.

    Connecting the DHT11 or DHT22 sensor is very easy. Make sure you check the following:

    If your sensor is on a small board, there is already a resistor between pin 1 and 2. The board with the DHT11/DHT22 has only three pins. If not (as presented in the picture), add a 10K resistor between the first and the second pin. Connect the first pin to the 3.2 volts (presented on the board) and the 4th pin to the ground. Connect the second pin to digital pin 4 (D$) of the NodeMcu board.

    If you look closely you will see that the D4, 5V and ground pin on the NodeMcu board are all next to eachother! When you make use of a DHT sensor on a small board you can easily prick the sensor in the broadboard next to the NodeMcu as the pins will match!

    The BMP sensor

    The BMP sensor meassures the temperature and the air pressure. Yes, we already have a temperature sensor added in the previous step but not an air pressure sensor. Connect the power pin to the 3.2 volt line of the NodeMCU and the ground pin to the ground of the NodeMCU. The SCL has to be connected to D1 and the SDA to D2.

    The Rain sensor and Light sensor

    This is a tricky part as the NodeMCU has only one analog pin (see image, buttum left). We can solve this problem by multiplexing the analog pins. With the help of two diodes and two GPIO pins we power both sensors in sequense. I have written a seperate instructable about this. Please click here. The instructable is based on an arduino board. Since the NodeMCU is programmed with arduino IDE this will be no problem.

    As you can see the rain sensor is powered by pin D7 (GPIO13). The LDR is powered by pin D8 (GPIO15).

    A small node on the rain sensor used in this project. The rain sensor was dilivered with a small module. This module is not required for the rain sensor to work as we want to read the analog value. The reason people use these modules is that connection to digital pins of the microcontroler is possible. The onboard potentiometer sets the value in order to pull the digital pin of the microcontroller high or low.

    Step 4: Coding

    As I am not very good in programming I tried several sketches availible on the internet. I found out that most of the sketches where written in LUA language and therefor useless for me. An other thing I found is that when you find a sketch for a seperate esp8266 shield (one of them is on top of the NodeMcu) it is possible to use this sketch on the NodeMCU without any problems. Ok, this should sound stupid to you, but I realy didnt know that!

    I found a good sketch for temperature and humidity on this website. As one can see this sketches is made for the esp8266V1.0 (only the wifi shield with 2GPIO pins) but workes on the NodeMcu board. The library of the ESP8266WiFi.h is automaticly downloaded when you add theNodeMcu board, the DHT library you can simply download by using the inbuild library manager. I found that when using the DHT library (and not the DHT11 library) it doesnt matter which sensor you use, the DHT22 or the DHT11! Simply change everywhere where DHT11 is written in the text into DHT22. Great!

    The sketch from this website served as basis for the sketch I developed and is given below. I simply started with the DHT22 sensor to push the temperature and humidity to thingspeak whereafter I added the BMP sensor, rain sensor and LDR sensor. If you compare the sketch above with the sketch below you will see how to add aditional sensors!

    After I added all the sensors I discoverd that you can derive the dew point from the temperature and the humidity. It is also possible to retreave the alltitude from the temperature and the air pressure, althrough this is from less importance for a weather channel it is fun. I added the formula for the dew point and the alltitude in the arduino sketch.

    1. Change the apiKey with the one of your account of thingspeak
    2. Add the 'ssid name' of your wifi network. This is simply the name you see when you click in the right bottum corner of you screen.
    3. Add the password of this wifi network

    If you uploaded the sketch you can verify in the serial monitor how it works. Simply open the monitor by pressing CNTR + M.

    Step 5: Getting Everything in One Box

    I love to use old screw boxes for project enclosures as they have the perfect size for microcontrollers and are watertight. The rain sensor fitted perfectly on top of the screw box I used. The DHT sensor and the BMP sensor I positioned on the side of the box. I covered both sensors with some multiplex so that rain could not invluence the readings.

    A small update: I see that the temperature (see my thingspeak channel) is a bit on the high side during the day. I think this is the result of the screw boxes that have limited mass and heat up quickly. Mabey a more solid structure (from wood or bricks) will give more accurate readings.

    update: Mabey it is not a good idea to put it in a screw box. I thought that they would be watertight but it appeared to be different. See last picture.

    Step 6: Getting Cool Gauges

    Thingspeak has lots of plugin options. One of them is that it is possible to make gauges and publish them on your website. Thingspeak will automaticaly generate a code for the gauges. It is possible to adjust the gauges (change the colors, numbers, scale etc.) by adjusting the code. Unfortunately viewing the gauges is only possible in the 'private view' tab of Thingspeak. If you link the gauges to your private website (such as I did) by using an iframe you have to be logged in to Thingspeak to be able to view the gauges.

    In my gauges I adjusted the position of the colors. I also added the collor green. Please copy the following code in the HTML section, the CSS section and the Javascript section of Thingspeak. (The code below I use to view the temperature)

    Step 7: Extra Features

    I added a piezo buzzer that indicates when the board is connected to the wifi. The piezo buzzer is not included in the sketch presented above. Please contact be if you have problems connecting a piezo buzzer.

    An other future I added is a flashing led. On the NodeMcu one can find an onboard led that flashes everytime data is send. I demolished the led with a soldering iron and soldered wires on the old connection points of this led before adding a 4mm led. This led tells me when data is send. This extremely easy when the NodeMCU is positioned inside the screw box.

    Step 8: Have Fun

    Have fun building and learning! Please let me know what you think of this instructable. I would love to make some improvements if necesarry.



    <p>Hello! I have used this code for connecting my BMP180 to ESP8266 12. But unfortunately, I am not getting Pressure Value. I am getting following vale. I want to know how will we gonna set D1 and D2 pins to BMP180 sensor. Please help me out.</p><p> &lt;&lt;stack&lt;&lt;&lt;</p><p> ets Jan 8 2013,rst cause:2, boot mode:(3,6)</p><p>load 0x4010f000, len 1384, room 16 </p><p>tail 8</p><p>chksum 0x2d</p><p>csum 0x2d</p><p>v60000318</p><p>~ld</p><p>Failed to read from BMP sensor!!</p>
    <p>Hello !</p><p>Thanks for sharing :)</p><p>Is there a specific reason why you used a BMP280 and a DHTxx instead of a BME280 that includes pressure, temp and humidity ?</p>
    <p>Nice instructable. Easy to follow and great intro to Thingspeak. Just need to put it outside in a suitable enclosure. Thanks.</p>
    <p>Anyone else had a issue where the serial monitor output from Arduino IDE is just garbage ASCII like !%Ǣɸ9▓. I have read it is a power or cable issue. I have tried two different usb cables, Is it possible the usb ports on my laptop don't put out enough power? It runs the blinking example uploaded from Arduino IDE so it seems to be setup correctly. The output from es explorer when running lua scripts looks fine though so I'm stumped. </p>
    <p>I fixed my issue buy reinstalling the driver and rebooting. Anyhow I re-coded to upload the data to weather underground so I can use their mobile app and use their servers to do the logging. Did away with the ldr and rain sensor and plan on adding an anemometer and wind direction in their place.</p>
    <p>can you please post the code? thank you</p>
    <p>I had this same problem and found out that the baud rate in the serial monitor needs to match the upload speed of my board (Tools&gt; Upload Speed).</p>
    <p>I made it! (without a rain sensor and with a DHT11) I must admit that I battled at first with the Arduino IDE part, and had to do some serious research before I was able to connect my NodeMcu (v1.0 12E) to the Arduino IDE.</p><p>As you will notice, I made my weather station mobile by adding a 2000 mAh battery that can be re-charged. The bty life is about 12 hours and provides 3.7V that seems to be sufficient to drive all the sensors.</p><p>TO DO: 1. put weather station in weatherproof housing. 2. Replace DHT11 with DHT22. 3. Add rain sensor. 4. Get 5000 mAh battery.</p><p>Thanks Ingenerare in electronics.</p>
    <p>Hi,</p><p>First of all, congratulations for the project. The maximum voltage supply of the digital inputs of the ESP8266 is 3,3V. And the LDR, LM35, and others sensors need a voltage supply equals 5V.</p><p>How did you fix it? Did your project work well?</p><p>Thank you!</p>
    <p>Forget my precedent message, issue is solved.</p>
    <p>Hi,</p><p>Thanks a Lot for this great project. I'm just trying to make it working here, only with a DHT11 plugged at this time. <br></p><p>The arduino IDE gives me this error code : </p><p><br>compilation terminated.<br><br>exit status 1<br>Error compiling for board NodeMCU 1.0 (ESP-12E Module).</p><p>Have you got an idea of what's going wrong ?</p><p>Thanks</p><p>Laurent</p>
    <p>Buen proyecto!!!</p>
    <p>Great instructions! I made it in about 2 hours thanks to you filling in a lot of the blanks and providing code. </p>
    <p>Nice to see that you made it! how cool is it! Do you have accurate readings? is it comparable with my thingspeak channel?</p>
    Thx. Didn't really compare it to your channel yet but it seems to be accurate based on other sources such as the weather report and other (commercial) sensors I have. I have it monitoring my attic as I'm concerned about heat buildup. If you're curious I've made a public ThingSpeak channel that has the output plus a couple of cool Google gauges. <br>https://thingspeak.com/channels/123447 <br>Bruster
    <p>Hi Bruster,</p><p>I need your help! How did you put the gauges public! I surched everywhere how to do this and even posted a topic on the thingspeak community http://community.thingspeak.com/forum/general/can-not-add-visualisation-to-public-page/ Can you please tell me how you fixed this!?</p>
    <p>Sure. All I did was set the channel to be public in the &quot;Channel Settings&quot; section then in the Apps/Plugins/&lt;myplugin&gt; section (where you modify the code for the plugin) I set the &quot;Make Public&quot; checkbox then just below that I added a check for &quot;Private View&quot; and &quot;Public View&quot; in the &quot;Add this visualization to a Channel&quot;. As far as i know this should work for anyone.</p>
    <p>Mmmm, I tried to figure it out but with no succes. Can I send you a printscreen of my thingspeak section (where i modify the code for the plugin) by email? I think this option is missing or so. I send you a PM</p>
    <p>can you make it public?</p>
    <p>This is a fantastic introduction to home automation and relatively easy to complete. I didnt add the rain sensor as I live in England where it usually rains haha. I will probably add the light sensor at a later date. Very happy with the project! :)</p>
    <p>Thnx! looks good. I think you can plug in the DHT22 sensor without wiring as you use a board that includes the resistor. If I`m right the power, ground and D4 pins are next to eachother on the 1.0 board</p>
    <p>I'm using the V3.0 board so it won't work that way. Also I will eventually put it in some kind of box like yours so its probably better to have the sensors loose for the moment. Thanks for the tip anyway! :)</p>
    <p>I also have the NodeMCU v3.0 board from Lolin producer (it's larger than &quot;original&quot; nodemcu v1.0) but I can't upload any sketch with Arduino. Can you help me? I think it's a problem about baud rate or something... Thank you</p>
    <p>Set the <strong>Upload speed</strong> (baud rate) in Arduino IDE &gt; <strong>Tools</strong> to <strong>115200</strong>, press <strong>and hold</strong> the <strong>Flash</strong> button on the NodeMCU and <strong>then</strong> plug the USB cable or press <strong>and hold</strong> the <strong>Flash</strong> button and press<strong>&amp;release</strong> the <strong>Reset</strong> button while the USB cable has <strong>already</strong> been plugged. Now you can program the board. Change</p><p>Serial.begin(115200);</p><p>to:</p><p>Serial.begin(<strong>74880</strong>);</p><p>and choose <strong>74880</strong> baud for the <strong>Serial Monitor</strong> (drop-down menu in the lower-right corner) so you can see not only the messages sent from the code but even the <strong>error&amp;restart info</strong> messages sent by ESP8266 itself.</p><p>If NodeMCU <strong>disconnects-reconnects-disconnects-reconnects...</strong> from the USB then you can power the board by the phone charger and connect <strong>USB to serial adapter</strong> to TX/RX pins to see the messages or you can just ignore the Serial port. <strong>LoLin</strong> boards seem to have disconnect-connect problem when using serial port, I have 2 of them and both have the same problem but sometimes, after 10-15 resets (by pressing the Reset button) they start to work normally.</p>
    <p>I am trying to read input from switch at pin D8 of node mcu v1, but can not read it for some reason. Any suggestion on it.?</p><p>I already have used other gpio for the projects</p><p>Thank you in advance!</p>
    <p>Thank you so much sir :)</p>
    <p>I used the same code but substituted with my api, ssid and password and now i'm getting connection to thingspeak failed. Any ideas?</p>
    <p>Thanks a lot!!! I followed instructions and had a great experience with my first IoT project.</p><p>Unfortunatelly it did not work as-is, while:</p><p>1. I used the only DHT11 sensor and no other - script was not working at runtime</p><p>2. some libraries were not loadable as per instuction, needed to play around</p><p>Overall was original Instructables are great!!!</p><p>I posted my personal Instructables with missing (or corrected) steps, tested with 2 boards (ESP12E DEVKIT V2, NodeMCU AMICA)</p><p>You can find mine here:</p><p><a href="http://instructables.com/id/Easy-IoT-Weather-Station-With-Multiple-Sensors-enc" rel="nofollow">http://instructables.com/id/Easy-IoT-Weather-Station-With-Multiple-Sensors-enc</a></p>
    <p>how can i change the update interval of each sensor? e.g 1 read per hour,,, ty</p>
    i want to add &quot;soil sensor&quot; in here, how to add soil sensor, can u help me?
    <p>Built with an Adafruit Feather Huzzah with ESP8266 and a LiPoly battery.</p><p>Thanks for tutorial.</p>
    <p>Works really great. My first IoT project. Thanks for tutorial. </p>
    <p>You are welcome!</p>
    <p>I made all the connection for the DHT sensor, firmware and sketch finally working, connected to wifi but..... I have this error (see pictures) and I don't know why. Could someone please help me?</p>
    <p>there must be a mistake in the connections you made. please check double. Also. make sure you set the right DHT pin in the sketch (you use D4)</p>
    <p>A cool project indeed.</p><p>However, I bought a BMP280 in place of the BMP180, and it has a different library (Adafruit_BMP280_Library-master) that I can't connect.</p><p>The constructor is Adafruit_BMP280(int8_t cspin);</p><p>And I can't devise the value cspin.</p>
    <p>Is there any way to power it up with batteries or maybe with a solar panel?I understand wifi consumes alot but you could set up interval to send data each hour? congrats for the project</p>
    Hi, Yes, you could do batteries but I do not expect they will hold for long. There is someting like a powersafe mode on the NodeMCU. Mabey a giant powerbank with a solar panel and the powersafe mode will do the job
    <p>Its called 'deep sleep'</p>
    <p>do you know how i could hook up a battery on it? i didnt find any shield</p>
    <p>I made it!</p><p>I haven't soldered on the BMP portion yet... I have however got the values being sent over MQTT to my Home-Assistant raspberry Pi smarthome hub. Loving it! Just need to work out how to be miserly on power usage, build 10 of them and place them through my house, in aesthetic housings . Also considering adding a PIR to detect if my family member is in a room and shut stuff off if they aren't.</p>
    <p>Nice, looking good. Do you also calculate the dewpoint with the humidity and the temperature data?</p>
    <p>I do! I don't have a real world application for that indoors though. I will make it available on the outdoors unit though!</p>
    Awesome project! use this board with it : <br>http://youtu.be/FMWnU2SNzE0<br>
    <p>Nice work! If you want to power it with battery which will be charged by the solar panel check this project I did<br>http://www.whatimade.today/do-i-have-hot-water-solar-powered-esp8266-with-a-thermistor/</p>
    <p>Is it possible to log and export all the data recorded?? I was thinking about a time range of 1 year, for example.... Thank you!</p>
    <p>Yes, this is possible. Thingspeak however has a maximum on the amount of data stored. So what you have to do is make the time between two readings bigger. I have 20 seconds between each reading, you can do a reading each 2 hours or so. O, and thingspeak allows you to export data yes!</p>
    <p>Great instructions! I made it in about 2 hours thanks to you filling in a lot of the blanks and providing code. </p>

    About This Instructable




    Bio: The term, engineering originates from the Latin word Ingenerare, which means "to create". My name is Vincent and I am a graduating student in the ... More »
    More by Ingenerare:Turn me on, an ATtiny RGB mood lamp Easy IoT weather station with multiple sensors  Multiple analog inputs using one analoge pin   
    Add instructable to: