Monday 30 January 2023

Christmas Weather Station - 2

 30 January 2023  I have decided to give up on  getting OpenWeatherMap connected and displaying. 

I am going to get rid of that stuff, and maybe the Thingspeak stuff, and have the devices show the measurements on the displays directly. 

I will also try and set up the ESP8266 as an Access point so that I can browse to it and see my readings. 

On second thought I do not need to do that. All I have to do is set up a web page on it to show the data, so that it can be seen on my own network. 

Here is the link for doing the Access Point thing: 

https://randomnerdtutorials.com/esp8266-nodemcu-access-point-ap-web-server/

Hopefully it will also help to get the web server set up.  It leads to this

https://randomnerdtutorials.com/esp8266-dht11dht22-temperature-and-humidity-web-server-with-arduino-ide/

OK, I have taken out all the stuff relating to Thingspeak and OpenWeatherstation, and it compiles, But when it runs it connects to wifi, then displays nothing and reboots. 

Problem 1: get it to display current date and time. 

On-line monitor shows a bunch of error statements that occur between line 59 and 166. 

I have discovered that the error occurs in this section of code:

/code

int remainingTimeBudget = ui.update();

if (remainingTimeBudget > 0) {
   Serial.println("remaining time budget wait");
   // You can do some work here
   // Don't do stuff if you are below your
   // time budget.
   delay(remainingTimeBudget);
}

/endcode

I don't understand this ui.update, so have found I hope an explanation here to be read later:

https://forum.arduino.cc/t/using-millis-for-timing-a-beginners-guide/483573 - not much help. 

7/2/2023   OK, I have decided that the code for this is too complicated and not that well explained, so am looking elsewhere.

I have found: 

https://www.hackster.io/technuttiez/pocket-weather-station-using-arduino-2e5173

which leads to:

https://www.youtube.com/watch?v=ZhOhBuKC80M&t=460s   which points me to the next instructable for the code for this.

https://www.instructables.com/Pocket-Weather-Station-Your-Self-Care-Weather-Assi/

I had to install one more library - the Adafruit DHT one. and now it compiles. I'll check the pins for the DHT sensor before I try and load it. 

10/2/23 discovered an interesting site or two. 

https://github.com/lexus2k/ssd1306/wiki/Hardware-setup#esp8266-nodemcu 

This one shows the usual pinouts for the NodeMCU and the screen.

It came from here:

https://github.com/lexus2k/ssd1306

12/2/23 I have reverted to the modification of the weatherstation demo because it at least displays data on the screen. It also does set up the wifi and read the sensors.  

Have discovered how to convert an integer to a string so that I can print it to the display

String myString = String(n); 
That works. 
Now displaying Temperature and humidity at the following positions on the screen:
display.drawString(40, 10, "Temperature");  Top third
display.drawString(90, 10, myString);
display.drawString(40, 30, "Humidity");     just under half way down
display.drawString(90, 30, myString2);
I repeated this for the Light and Atmospheric pressure and it worked well. 
the figures in the lines above are (column, row, whatever)
    display.clear();
    display.drawString(40, 5, "Temp");     /line 5
    String myString = String(temp);
    display.drawString(40, 15, myString);  / line 15
    display.drawString(80, 5, "Hum'y");
    String myString2 = String(humi);
    display.drawString(80, 15, myString2);
    display.drawString(40, 30, "Light");    /line 30
    String myString3 = String(tempLight);
    display.drawString(40, 40, myString3);  /line 40
    display.drawString(80, 30, "Atm.Pr");
    String myString4 = String(tempAtom);
    display.drawString(80, 40, myString4);
    display.display();
This weatherstation program does not use the simple setup explained in this
https://randomnerdtutorials.com/guide-for-oled-display-with-arduino/
Tried to set it up using this program, but it uses different libraries and I can't set it up to use the I2C ports that my system currently uses. Guess I'll have to stay with what I have and just tidy it up.

Used the sample program for ESP8266 demo of I2C screen, and it is blue in the top 2/3 and yellow in the bottom 1/3.   When I look at the Amazon reference for the kit in the previous blog, it looks like the display if Blue/Yellow. So I have to live with it. 

I shall knock 2 off each of the row values and see if I get it all on the blue section.
That did it, so I know to write anything else that I want in the yellow section starting at row 40, or maybe 45 allowing for the height of the characters. [ used 46].

change these two lines and similar to:
 String myString4 = String(tempAtom);
 display.drawString(80, 40, myString4);
becomes
 display.drawString(80, 40, String(tempAtom));
Tidier. 
I need something that helps me display the time. 

https://www.circuitbasics.com/using-an-arduino-ethernet-shield-for-timekeeping/
https://randomnerdtutorials.com/esp32-ntp-client-date-time-arduino-ide/
-- looks more useful.
https://RandomNerdTutorials.com/esp8266-nodemcu-date-time-ntp-client-server-arduino/

24/2/2023 This one gave me the essentials, and I put it into my code and deleted a lot of
old time stuff that was interfering with it's compilation, and I got it working.
Changed display from centred to left oriented and some positioning values, and I am happy.



12/5/2023    Link to  a weatherstation using a Raspberry Pi

  https://www.donskytech.com/raspberry-pi-dht22-weather-station-project/