Hot or Cold? Mini Temperature Forecast

by alexpikkert in Circuits > Microcontrollers

111 Views, 3 Favorites, 0 Comments

Hot or Cold? Mini Temperature Forecast

Temperature (2).jpg

If you want to know which temperature is coming to town, take a look at this little device. it shows you the minimum and maximum temperature expected tomorrow in your hometown. Nice!

Supplies

Temperature (1).jpg
  1. Microcontroller Lolin Wemos D1 mini v4
  2. OLED shield 0.66 inch 64x48 for this microcontroller
  3. USB-C cable and USB 5VDC power supply
  4. PC with Arduino IDE to program the Wemos D1 mini.
  5. pair of glasses so you can see the small screen..

Connect!

Temperature (2).jpg

Connect both devices. If you purchased them without connected pins, first solder these pins on both devices.

Female pins on the Wemos D1 (upside) and male pins on the OLED shield (downside).

Nothing more.....

Add Software and Go!

Temperature (3).jpg
Temperature (4).jpg


To program the Wemos D1 mini with the Arduino IDE you must first install this microcontroller in the Arduino IDE board manager. See this Github for details how to do this: GitHub - esp8266/Arduino: ESP8266 core for Arduino

When done, load the attached ino file into your arduino IDE.

You will need a few libraries to make it work:

#include <ESP8266WiFi.h>

#include <Wire.h>

#include <SPI.h>

#include <WiFiClientSecureBearSSL.h>

#include <ArduinoJson.h>

#include <Adafruit_SSD1306.h>

These can be added via the library manager from the IDE, exept the Adafruit_SSD1306 library. The one you need is a special version for the OLED 64x48 shield and can be found here:

https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED

The original library does not work, it will garble your little screen completely.

Now you need to alter these two items in the WiFi settings:

/ ==== WIFI SETTINGS ====

const char* ssid = "YOUR SSID";

const char* password = "YOUR PASSWORD";

add your own WiFi name (the SSID) and your WiFi password.

Finally you must change the String url where the weatherdata is retrieved.

latitude=52.2658&longitude=6.7931: change to your own latitude and longitude of your hometown.

timezone=Europe/Amsterdam";

Change this to your timezone.

This best way to get your correct data is to ask ChatGPT. Send the complete URL line to ChatGPT and ask for a new one with your hometown data included. Past the new url into your ino file and delete the old one.

Save the altered ino file and upload it into your Wemos D1 mini and there you go.

The program first searches to connect to your WiFi, then loads at open-meteo.com the temperature data from tomorrow and sends this to the OLED screen. This will happen every hour. You can also press the reset button on the Wemos d1 mini and the search will start directly.