IoT Personal NodeMCU ESP12 WiFi Wireless Weather Station

Project still in process

In this Instructable I'm going to show you how to build personal wireless weather station using NodeMCU (ESP12)

One year ago I was create weather station based on Arduino. But always there are ways how to improve things to be better.

NodeMCU (ESP12) WiFi module will send sensors data to and

A Weather station is a device that collects data related to the
weather and environment using many different sensors. We can measure many things like:

  • Temperature
  • Humidity
  • Wind
  • Barometric Pressure
  • UV index
  • Rain

Step 1: Types of Sensors Used for Weather Station

The following is a list of measurement devices that are used in weather stations:

1) NodeMCU (ESP12) main board

2) Thermometer Dallas DS18B20 thermometer measures temperature. You can measure both the temperature indoors and outdoors, record highs and lows, show trend arrows to indicate temperature rising or falling, and even predict short-term future temperature ranges.

3) Hygrometer (BME280)- A hygrometer measures relative humidity. Relative humidity is the quantity or percentage of water vapor (water in gas form) in the air. Humidity influences environmental factors and calculations like precipitation, fog, dew point and heat index.

Barometer (BME280) – A barometer measures atmospheric pressure. A barometer can help to forecast upcoming weather based on the changes it measures in the atmospheric pressure.

4) Davis 6410 anemometer measures how fast the wind is blowing, or wind speed.
ESP8266 weather stations can display wind speed in MPH, KPH or knots, and record current, peak and average wind speed readings.

Wind Vane – A wind vane, or weather vane, is an instrument that determines which direction the wind is blowing.

5) Ventus W174 rain gauge measures rainfall or liquid precipitation

Step 2: Schematic and Wiring Diagram

Step 3: NodeMCU PCB Weather Station Shield

Design printed circuit board (PCB), I was used ,,Sprint-Layout" software. Exported to Gerber files. PCB was made

To create this NodeMCU ESP12 weather station shield you will need:

  1. NodeMcu Lua CH340G/CH340/ ESP8266 Wireless WIFI Internet Devolop Module Ebay
  2. Waterproof Digital Thermal Probe or Sensor DS18B20 Arduino Sensor Ebay
  3. JST-XH Kit 4Pin 2.54mm Terminal Housing PCB Header Wire Connectors Ebay
  4. Atmospheric Pressure Sensor Temperature Humidity Sensor Breakout BME280Ebay
  5. 2x 1K 0805 resistor
  6. 1x 120R 0805 resistor
  7. 2x 4.7K 0805 resistor
  8. 1x 10K 0805 resistor
  9. 1x RJ45 socket Ebay
  10. 1x 47uF electrolytic capacitor
  11. 1 x 40pin 2.54mm Female Single Row Breakaway Pin header Ebay

Step 4: Arduino Code

  1. Instal ESP8266 board into Arduino

  2. Enter your's Wifi router ssid and password.
  3. Before upload code into your NodeMCU you will need register in to obtain a WU station ID and password.
  4. Change this ID and password into your weather station Arduino code.
  • char ID [] = "xxxxxx";

  • char PASSWORD [] = "xxxxxx";

5. Register in to obtain ID and key.

  • char ID2 [] = "xxxxxxxx";
  • char Key [] = "xxxxxxxxxxx";

6. Change altitudepws in meters (m) to get relative pressure.

I'm using 30 second loop time sending data to And 10 minutes loop time sending data to

Project still in process

Last edit: 2019 06 18

Step 5: Testing Weather Station

NodeMCU ESP12 is sending sendors data to and So it looks everything it's working. Job done ;)

Step 6: OTA Over-the-air Programming

OTA (Over the Air) update is the process of loading a new firmware to
ESP8266 module using WiFi connection rather than a serial communication. This type of functionality is extremely useful in case of no physical access to the ESP module.

Uploading a new sketch wirelessly from Arduino IDE is intended for the following typical scenarios:

  • during firmware development – as a quicker alternative to uploading a new sketch over a serial
  • for updating the firmware of multiple ESPs in your network

Prepare for OTA capability

  1. Install Python on Your System
    You need to install python27 on your system in order to program ESP8266 from your system you need to run OTA script. Install python27 on System from where your going to upload firmware.
  2. Download and Install Arduino OTA Library Download The library and tools required for OTA
  3. Install "" in arduino library.
  4. Go to Tools to select your ESP board model. You also have to choose your ESP’s COM port
  5. Open the BasicOTA.ino example: File > Examples > Arduino OTA > BasicOTA.ino

  6. Press the “Upload” button in the Arduino IDE and wait for the “Done uploading” message

Uploading a new sketch OTA (Over the Air)

Now your ESP8266 is ready to receive OTA firmware updates. You can
unplug your ESP8266 from your computer and power it through any power source. If your ESP8266 has a wireless connection to your router, you should be fine to upload new firmware.

  1. Go to your Arduino IDE. Open Tools tab select the Port option and you should see something like this: esp8266-xxxxxx at your_esp_ip_address
  2. Open your modified Nodemcu_weather_station.ino and upload over the air.

Info is taken from (Rui Santos)

Step 7: Making Solar Radiation Shield

Solar Radiation Shield is made from flower pot lower pad

Step 8: Installing Personal Weather Station

The location weather station is the most important part of installation. If weather station is located under a tree or an overhang, the rainfall data measured by the station will not be correct. If you place your weather station in an alley, you could very well get a wind tunnel effect on the anemometer, resulting in erroneous wind data. Weather station should have good "fetch", or distance from any other tall object. The standard wind measurement should be taken at 10 meters above the ground. A roof-top works the best for me. Weather station is powered from solar panel. So it is autonomous.

The most common error in installing a weather station is associated with misplacing the thermometer sensor. Meteorologists define temperature as the temperature in shade with plenty of ventilation. When placing weather station, make sure:

  • The thermometer sensor never receives direct sunlight.
  • The thermometer receives plenty of ventilation and is not blocked from the wind.
  • If the thermometer is placed on a roof-top, make sure it is at least 1.5 meters above the roof-top.
  • If the thermometer is placed above grass, again, it should be at least 1.5 meters above the grass surface.
  • The thermometer is at least 15 meters from the nearest paved surface.

So I'm using weather shelter. Solar Radiation Shield is made from flower pot lower pad. This way, weather station can be placed in direct sunlight, with the thermometer located inside the shelter. More information about installing weather station here

Step 9: Info Is Taken From:



    • Games Contest

      Games Contest
    • Paint Challenge

      Paint Challenge
    • Sew Tough Challenge

      Sew Tough Challenge

    26 Discussions


    Question 3 months ago

    Hello Rimvydas,

    I would ask you how to modify your sketch to use other anemometer and wind direction than Davis 6410 and other Rain gauge, than Ventus W174.

    The anemometer I want to use has this features: a wind speed of 1.492 MPH (2.4 km/h) causes the switch to close once per second;

    The rain gauge is a self-emptying tipping bucket type. Each 0.011” (0.2794 mm) of rain causes one momentary contact closure;

    The wind vane has eight switches, each connected to a different resistor. The vane’s magnet may close two switches at once, allowing up to 16 different positions to be indicated. 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. Resistance values for all 16 possible positions are given in the table. Resistance values for positions between those shown in the diagram are the result of two adjacent resistors connected in parallel when the vane’s magnet activates two switches simultaneously (see the attached document, please).

    Can you help me?

    10 answers

    Answer 3 months ago

    Hi Giuseppe,
    I add photos, so correct code. Wind direction ,,vane_value" you had adjust by yourself. These value it is for example.


    Reply 3 months ago

    Hi Rimvydas,

    I have much appreciated your help! Thank you a lot.
    As soon as I'll receive the wind sensor, I'll test everything and tell you if all work well, as I hope.


    Reply 2 months ago

    Hi RimvydasP,

    I have received the wind and rain sensors from China and tried to modify your program following your suggestions. Unfortunately, I can't get correct wind direction values. I have certainly made mistakes and, therefore, please give me some help.


    Reply 2 months ago

    Hi RimvydasP,

    first of all I want to thank you for your willingness and courtesy in giving me help.

    I made all the changes you suggested, including replacing the 10k resistor with a 100K resistor.

    I got the following vane-values:
    E = 22
    SE = 36
    S = 52
    NE = 93
    SW = 158
    N = 266
    NW = 394
    W = 524

    And I modified the program like this:

    void getWindDirection (void)
    vane_value = analogRead (A0);
    Direction = map (vane_value, 0, 1023, 0, 360);
    CalDirection = Direction + Offset;

    if (CalDirection> 360)
    CalDirection = CalDirection - 360;

    if (CalDirection <0)
    CalDirection = CalDirection + 360;

    DirectionCheck ();

    // getHeading (CalDirection);

    void DirectionCheck ()
    if (vane_value> = 162 && vane_value <270)
    wind_avg = 0;
    else if (vane_value> = 56 && vane_value <96)
    wind_avg = 45;
    else if (vane_value> = 0 && vane_value <24)
    wind_avg = 90;
    else if (vane_value> = 24 && vane_value <38)
    wind_avg = 135;
    else if (vane_value> = 38 && vane_value <56)
    wind_avg = 180;
    else if (vane_value> = 96 && vane_value <162)
    wind_avg = 225;
    else if (vane_value> = 400 && vane_value <525)
    wind_avg = 270;
    else if (vane_value> = 270 && vane_value <400)
    wind_avg = 315;
    if (windSpeed> 0) {
    DirectionAvg ();

    Unfortunately, I continue to get incorrect values on the Serial Monitor concerning the wind direction.

    Sensor in N direction:
    I get
    E 93
    Wind AVG = 0
    Vane value = 259

    Sensor in direction E:
    I get
    N 7
    Wind AVG = 0
    Vane value = 22

    Sensor in S direction:
    I get
    N 18
    Wind AVG = 0
    Vane value = 52

    Sensor in W direction:
    I get
    S 184
    Wind AVG = 0
    Vane value = 524

    Where is my mistake?

    Again thank you!


    Reply 2 months ago

    In your wind sensor manual pdf I see that your wind sensor have 16
    direction ( degrees) At this time you write only 8 wind direction.
    Mine wind direction code didn't work with your wind sensor. So I write
    another code for your wind sensor. You only need to change vane_value.


    Reply 2 months ago

    Hi RimvydasP,

    you are great! I didn't expect you to rewrite the code for me. Thank you very much. I am grateful to you.

    Now I can read the 8 directions of the wind. The only problem that remains is that I do not know the Vane-values of points 22.5 °, 67.5 °, 112.5 °, 157.5 °, 202.5 °, 247.5 °, 292.5 °, 337.5 °, and therefore I will not use these points, but that's fine the same using only 8 points.

    Is there a system to know the Vane-values of the other points?

    Can I suggest you add your new program to the beginning of your project, as an alternative to the original one, for those who want to use sensors like mine instead of Davis?

    Good job!


    Reply 2 months ago

    // Upload this code to know vane-value

    int analogPin = A0;
    int vane_value = 0;

    void setup() {
    Serial.begin(115200); // setup serial

    void loop() {
    vane_value = analogRead(analogPin); // read the input pin
    Serial.println(vane_value); // debug value
    delay (3000);


    Reply 2 months ago

    Hi RimvydasP,

    after I uploaded your sketch to know Vane values, I have discovered that my sensor has only 8 directions not 16, so I have modified some lines of your last program, and precisely:
    int windDirections[] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    0, 0, 0, 0, 0, 0, 0, 0
    int index = winddir / 22.5;
    if ((index < 0) or (index > 15))

    int index = winddir / 45;
    if ((index < 0) or (index > 7))
    void getHeading(int direction) {
    if(direction == 0)
    Serial.print("North ");
    else if (direction == 22)
    Serial.print("North-North-East ");
    else if (direction == 45)
    Serial.print("North-East ");
    else if (direction == 67)
    Serial.print("East-North-East ");
    else if (direction == 90)
    Serial.print("East ");
    else if (direction == 112)
    Serial.print("East-South ");
    else if (direction == 135)
    else if (direction == 157)
    Serial.print("South-South-East ");
    else if (direction == 180)
    Serial.print("South ");
    else if (direction == 202)
    Serial.print("South-South-West ");
    else if (direction == 225)
    Serial.print(" South-West ");
    else if (direction == 247)
    Serial.print("West-South-West ");
    else if (direction == 270)
    Serial.print("West ");
    else if (direction == 292)
    Serial.print("West-North-West ");
    else if (direction == 315)
    else if (direction == 337)
    Serial.print("North-West-North ");

    I have deleted values not used.
    is it correct what I did?

    Last doubt is: I must modify the lines:
    void getWindDirection(void)
    delay (500);
    int average = 0;
    for (int i=0; i < 10; i++) {
    average = average + analogRead(A0);
    vane_value = average/10;

    or leave them?

    Have a good Sunday


    Reply 2 months ago

    1) Yes it is correct.
    2) You don't need to modify this. This function for average analog value.


    3 months ago

    I am having a problem with the wind showing higher speeds than it should. I am using a different wind anemometer. Is there something I need to adjust?

    3 replies

    Reply 3 months ago

    I mean change this value. Try lower to 0.12, 0.10, 0.7, 0.5


    3 months ago

    Hi Rimvydas,

    I hope not to bore you with my questions, but I believe that the clarifications you can give can also help others better understand how your code works.

    Could you explain how to change the time interval to send data to Weather Undergrond, which is now set at 30 seconds? I would like to change it to 2 or 5 minutes, but I do not understand which line of the code I need to change.

    Finally, I noticed that the data that is shown on the Weather underground web page of my weather station is slightly different from those that appear on the App Weather Underground on my smartphone, at the same time.

    It seems that on the App, data of Temperature, Humidity and Pressure arrive late with respect to those on the web page. This difference is wanted by Weather Underground or does it depend on how did you write your Arduino code?

    Thank you very much for the help.

    1 reply

    Reply 3 months ago

    I didn't understand why you need to change it


    Question 3 months ago

    Why does D8 need to be tied to ground? The reason I ask is because I am having problems with my wind anemometer. I do not have the davis 6410. I have one I built with a reed switch. It reads corrected at 1st and slowly starts going up in wind speed.

    1 answer

    Answer 3 months ago

    In ESP12-F example GPIO15 pin (D8) by 1K ohm resistor connected to ground. Maybe it is not necessary but I connected it.


    4 months ago

    Hello Rimvydas,

    I really enjoyed your work and I'm interested in replicating your weather station. But I would like to replace the Davis 6410 and the Ventus W174 with two other components, made by the MI-SOL, and exactly

    as rain gauge this model: - weather-station-to-measure-the-rain-volume-for-the / 32967868920.html? spm = a2g0y.search0104.8.15.5c8355aemPlfmk,

    and as wind direction and speed this:
    https://it. -9897-9b7284780bf3 & gps-scm = & id = pcDetailBottomMoreThisSeller 1007.13339.128551.0 & scm-url = 1007.13339.128551.0 & scm_id = 1007.13339.128551.0.

    The reason is simple: the model of rain gauge used by you is difficult to find in Italy, while the Davis does not convince me because as for wind direction it uses a potentiometer, while the model MI-SOL uses reed sensors (which I consider safer and less subject to wear than a potentiometer).

    But if I replace these two components, it is necessary also to modify the sketch you created, in order to use the digital input of the NodeMcu instead of the analogue one for reading the wind direction (of course I have to modify also the instruction #define Bucket_Size_EU 0.5., but this is not difficult).

    Could you help me edit your sketch, since I'm not good at programming?

    I hope for your help. In the meantime, thank you and greet you