Personal NodeMCU ESP12 WiFi Wireless Weather Station

899

2

26



Project still in process

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

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

NodeMCU (ESP8266) WiFi module will send sensors data to www.wunderground.com and https://weathercloud.net/

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

I will use these sensors:

  • Temperature - Dallas DS18B20
  • Humidity, Pressure - BME280
  • Anenometer and wind direction - Davis 6410
  • Rain gauge - Ventus W174

Step 1: Parts

The parts needed in order to build this project are the following:

1) NodeMCU (ESP12)

2) Dallas DS18B20 temperature sensor

3) BME280 temperature, humidity and pressure sensor (I2C, SPI)

4) Davis 6410 anenometer

5) Rain gauge

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

https://jlcpcb.com

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 0R 1206 jumper ( resistor)
  8. 2x 4.7K 0805 resistor
  9. 1x 10K 0805 resistor
  10. 1x RJ45 socket Ebay
  11. 1x 47uF electrolytic capacitor
  12. 1 x 40pin 2.54mm Female Single Row Breakaway Pin header Ebay

Step 4: Arduino Code

  1. Instal ESP8266 board into Arduino

    http://esp8266.github.io/Arduino/versions/2.0.0/do...

  2. Enter your's Wifi router ssid and password.
  3. Before upload code into your NodeMCU you will need register in wunderground.com 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";

3. Register in weathercloud.net to obtain ID and key.

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

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

5. I'm using 30 second loop time sending data to wunderground.com. And 10 minutes loop time sending data to weathercloud.net

Project still in process

Step 5: Source

  1. BME280 library and Davis 6410 anemometer, wind speed, rain meter Arduino code copyright rights belong to - Cactus.io
  2. Weathercloud.net code copyright rights belong to - Jakub_Nagy
  3. NTP time code copyright rights belong to - ChyneHome

Step 6: Testing Weather Station

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

Step 7: Making Solar Radiation Shield

Step 8: Final Result

Share

    Recommendations

    • Fandom Contest

      Fandom Contest
    • Party Challenge

      Party Challenge
    • Arduino Contest 2019

      Arduino Contest 2019

    26 Discussions

    0
    None
    giano2002

    Question 7 weeks 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
    0
    None
    RimvydasPgiano2002

    Answer 7 weeks ago

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

    rain.pngvane.pngwind.pngwind-direction.png
    0
    None
    giano2002RimvydasP

    Reply 7 weeks 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.



    0
    None
    giano2002giano2002

    Reply 26 days 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.

    0
    None
    giano2002RimvydasP

    Reply 25 days 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!

    0
    None
    RimvydasPgiano2002

    Reply 25 days 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.

    Compass_Rose_English_North.svg.png
    0
    None
    giano2002RimvydasP

    Reply 24 days 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!
    Giuseppe

    0
    None
    RimvydasPgiano2002

    Reply 24 days 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);
    }

    0
    None
    giano2002RimvydasP

    Reply 22 days 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:
    original:
    int windDirections[] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    };
    modified:
    0, 0, 0, 0, 0, 0, 0, 0
    --------------------------------------------------------
    original:
    int index = winddir / 22.5;
    if ((index < 0) or (index > 15))

    modified:
    int index = winddir / 45;
    if ((index < 0) or (index > 7))
    ----------------------------------------------------------
    original:
    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)
    Serial.print("South-East");
    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)
    Serial.print("North-West");
    else if (direction == 337)
    Serial.print("North-West-North ");

    modified:
    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
    Giuseppe



    0
    None
    RimvydasPgiano2002

    Reply 22 days ago

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

    0
    None
    jameslee522

    5 weeks 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
    0
    None
    RimvydasPjameslee522

    Reply 5 weeks ago

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

    0
    None
    giano2002

    7 weeks 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
    0
    None
    RimvydasPgiano2002

    Reply 7 weeks ago

    I didn't understand why you need to change it

    3434343ret5.png
    0
    None
    jameslee522

    Question 7 weeks 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.

    wu.jpg
    1 answer
    0
    None
    RimvydasPjameslee522

    Answer 7 weeks ago

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

    esp8266_12F_1-900x700.jpg
    0
    None
    giano2002

    2 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:
    https://it.aliexpress.com/item/Shipping-Free-for-... - 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. aliexpress.com/item/1-PCS-of-Spare-part-for-weather-station-to-test-the-wind-speed/32790525433.html?spm=a2g0y.10010108.1000013.1.20c853f3OSgW54&pvid=c3ea3654-3350-4517 -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