Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

Weather Station Ideas


Gina

Recommended Posts

WOW!!  That's brilliant!  It would mean I could load new code into the ESP32 in the wind sensors enclosure without taking everything down.

  • Like 1
Link to comment
Share on other sites

I try and keep my code modular so I can reuse bits elsewhere, so I have a tab called Arduino_OTA with the following code in it:

  void Arduino_OTA()
  {
// Only run 
  
  // Port defaults to 8266
  // ArduinoOTA.setPort(8266);

  // Hostname defaults to esp8266-[ChipID]  DO NOT USE UNDERSCORE IN THE NAME!!!!
  ArduinoOTA.setHostname(WIFIID);

  // No authentication by default
  //ArduinoOTA.setPassword((const char *)"123");

  //DONT FORGET to add  ArduinoOTA.handle(); to main loop

  ArduinoOTA.onStart([]() {
    Serial.println("Start");
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  }

In my Setup I init the OTA server after I have brought up the wifi:

//Start OTA Client
  Arduino_OTA();

In my main loop I have the following:

 ArduinoOTA.handle();

 

Link to comment
Share on other sites

9 minutes ago, Gina said:

Mine hasn't got OTALeds.

2138782901_Screenshotfrom2020-07-2811-59-39.png.6e288b0d69552f2c5eb8a41844fdd40c.png

Yep - no worries, that's just a version of the OTA example, the standard basicOTA is what you want... I was trying to time the capture to get the menu and hadn't noticed the cursor was highlighting the LED version (it's from teh ESP8266 version) - sorry for the confusion :) 

 

  • Thanks 1
Link to comment
Share on other sites

It will appear in the Port settings, if you set 

ArduinoOTA.setHostname(WIFIID);

Where:  const char* WIFIID = "WXSTATION";

Then you will get a name that means sense next to the IP if you have multiple ESP devices in the lan.

image.png.df5ae4784fdbce480fdac61eb9e0dce9.png

Link to comment
Share on other sites

I think I need that explaining maybe with some code.  I presume you need to put that in the ArduinoOTA initial code.  Anyway, I can look into that later, I'll be happy if I can get my weather measurements into the house.

Link to comment
Share on other sites

A stage further...  Uploaded Wim's WebServer sketch having set SSID and PW and also connected BME280.  Testing from serial and pressing EN button I get a good result.  Next to connect ESP32 to 5v Vin and see if it all works.

1038563930_Screenshotfrom2020-07-2816-57-54.thumb.png.c6ca6f473e474fc083dc608145ef7854.png

  • Like 1
Link to comment
Share on other sites

I thought these ESP32s were supposed to be low power!  This one is drawing 0.08A on 4.9v according to my bench PSU.  Probably needs coding to put it into a low power mode if you want to save power.  No problem here as I shall be running it off my main obsy supply via a buck converter.  Goes to 0.09A when accessed from browser.

Edited by Gina
Link to comment
Share on other sites

28 minutes ago, JamesF said:

Blimey!  That's more than 5C warmer than it is here!

James

But are we comparing outdoors with indoors here?  My ESP32 and BME280 are sitting on my living room table (aka work bench).

Link to comment
Share on other sites

I now have a framework I can work in to add other weather measurements.  The ESP for the scope room and outside could be an ESP8266 but it may be easier to use an ESP32 as I already have the code for it and know it works.  I don't know if the ESP8266 can handle a web server.

I shall certainly be using an ESP32 for the wind sensors as I need the number of GPIO pins.  I also will have a fair amount of code to add to process the wind data before making a web page

Link to comment
Share on other sites

I'm wondering if a single ESP32 would be able to handle all the data processing needed for the wind data as well as the web server.  The anemometer will want to use interrupts to count the revolutions (4 counts per revolution to give enough wind speed resolution). 

Link to comment
Share on other sites

45 minutes ago, Gina said:

But are we comparing outdoors with indoors here?  My ESP32 and BME280 are sitting on my living room table (aka work bench).

Ah, that's ok then :)  It has been up to 22C today, but it's a bit chillier than that now.  Which reminds me.  I don't have a wind chill calculation on mine.  I shall have to do that.  Not that it's much of an issue at the moment.

James

Link to comment
Share on other sites

Yesterday I found a "bug" in this solution. When I use Chrome as web client to access the weather info, it stops working after a while. Using IE, the esp keeps working. Most likely Chrome doesn't close connections properly, while IE does. This can lead to instability, and possible memory leaks. So it's not the web server itself that is to blame, but it should be programmed to deal with Google's inability to produce quality products. I've started looking into possible solutions, but need to do more research.

Link to comment
Share on other sites

This implementation (either simple or pretty) reads the weather data when the web page is accessed.  With the wind sensors, the anemometer produces interrupts to count revolutions for wind speed, the count being taken and zeroed each second (or could be more).  The wind speed would be updated at each second (or whatever the interval) and this would be read by the web access part of the code.

Similarly the wind direction would be read at intervals and I propose to add code to effectively "smooth" this fast changing data and have the web access code read this.  I propose to use Consensus Averaging for this.  I expect the internal clock to be accurate enough to provide the interval timing - I don't think it needs an RTC at this stage.  That would only come when I add data logging at a later stage and that would be separate.

Edited by Gina
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.