What you're going to do is a simple connected clock that displays, on the MAX7219 LED matrix, the time, picked with NTP from web, and every 30 seconds shows the temperature and the humidity measured by the DTH11 sensor. The display light also changed based on the light that the photoresistor measures so even if it's day or night you can read time and temperature properly.
Required Hardware:
Before getting started, let's see what you'll need.
- ESP8266 NodeMCU board
- LED matrix display
- DHT11 temperature and humidity sensor
- Photoresistor to dim the intensity of the display light
- Breadboard and jumper wires
- Micro-USB cable
- Personal computer with Arduino IDE installed
- Internet connection (WiFi)
1. INSTALL LIBRARIES
Before start writing the code and connect all the components you have to install some libraries to make all work properly.
The libraries that you need to install are:
- ESP8266WiFi.h
- Adafruit_GFX.h
- Max72xxPanel.h
- DHT.h
To install the ESP8266WiFi library you have to install the ESP8266 board in the Arduino IDE.
You can do it by simply doing this steps:
- Open you IDE and click on "File -> Preferences".
- In "Aditional Boards Manager URLs" add this line and click on "OK": "http://arduino.esp8266.com/stable/package_esp8266com_index.json"
- Go to "Tools -> Board -> Boards Manager", type "ESP8266" and install it.
- Go again to "Tools -> Board" and select "Generic ESP8266 Module".
To install the Adafruit_GFX library you only have to:
- Open you IDE and click on "Sketch -> #includelibrary-> Manage Library".
- Search for the Adafruit GFX library in the search bar and click on install.
Do the same thing to install the Max72xxPanel and the DHT-sensor-library.
Once you have installed all the library you are ready to connect all the components and start writing the code!
NOTE: You have to change two things in the code below:
- Wi-Fi credentials: at line 44 you have to insert your SSID and your PASSWORD
- POOL Country: at line 48 you have to change the ntp pool. You can search the right one at https://www.ntppool.org/zone/@
Comments