Hello! It is Igor with you on the Home Made channel. And today we will be making a cool Internet watch based on the ESP8266 very cool e-Paper display. Go! The basis of everything will be the Node MCU board. I removed some contacts, left only those that I need. You also need a battery, and I took this battery from some old mobile phone. Temperature and humidity sensor. I will use the DHT22 sensor, aka AM2302. To charge the battery, I will use the TP4056 board. I removed the USB connector from the board to reduce the size. And also replaced the current-setting resistor. We also need a 3.3 volt voltage regulator. This is due to the fact that the ams1117 stabilizer built into the board has very poor performance. This is a linear stabilizer, consumes a lot of energy, and requires too much input voltage for itself. Therefore, this board cannot be powered from the battery. To do this, use an external Voltage regulator. I used just such a board, a link to it will be in the description. The minimum input voltage for it needs 3.4 volts, while for ams1117 you need a voltage of more than 4 volts. Therefore, you can’t do without an external stabilizer. Also some more resistors will be needed. The basis of all will be an e-Paper display with dimensions of 4.3 inches with a resolution of 800 x 600 pixels, which was provided by DFrobot. All necessary pictures will be stored on MicroSD. I am using an old 256 megabyte microSD flash drive, and I have enough. Wires to the display. Switch. And we will collect all this in a case printed on a 3d printer. And also small things. Various bolts suddenly come in handy. We now turn to the consideration of the device diagram. First you need to slightly modify the NodeMCU board so that you can switch the power from either usb or the battery. This is necessary so that the power does not go simultaneously from the battery and from USB. Either from one, or from another. To do this, remove this diode. It’s not necessary to completely remove it, you can simply unsolder one side and deploy it. Next, a switch is installed that will switch the power from either USB or battery. When usb is connected, a 5 volt power is generated on the VU pin, which is fed to the step-down converter and is powered by the NodeMCU board from it. If the switch is in different position, then the power is supplied from the battery through the converter and feeds the NodeMCU board. When you connect the usb cable, the battery immediately charges via TP4056. A resistor divider is also installed, which is designed to measure the input voltage. If the power comes from the battery, the voltage on the battery will be measured. Thus, we find out the battery level. If the power comes from USB, it will be determined that the battery is charging. The DHT22 temperature and humidity sensor is powered directly from the power that is supplied to the transmitter, like a battery, or powered by usb. The display is exactly the same. It is powered directly from the main power. This is necessary so as not to load the voltage regulator 3.3 volts, and so that during the display update there will not be a voltage drop, due to which the board may reset and reboot. The display itself is not connected with all pins. I decided not to connect some pins due to their uselessness. For example, I did not connect the rx pin, because it interferes with the flashing of the board. And this is not very convenient – open the box, disconnect the display, reflash, collect everything back… At the same time, I will not read any data from the display, I don’t need it. I will only send data and commands. Therefore, only the tx pin is connected. Pin rx (it has a blue wire) will not be connected. Also, I did not connect the pin that is responsible for the Reset, that is, rebooting the display. This is due to the fact that when the ESP8266 enters deep sleep mode, the pins are reset, which causes the display to reset, and it turns on, although it should go into deep sleep and consume a minimum of energy. Therefore, I did not connect the reset pin either. All other pins can be connected to any pin. There is only one that is responsible for waking up the display, pin tx, that’s all. And two pins of power. That is, the display is connected with only four pins. Two power pins, a tx pin and a wakeup pin to wake up the display. That’s the whole scheme. It is quite simple, and it remains only to collect. We have all the details, now you can start assembling. [music] [music] [music] [music] [music] [music] [music] [music] [music] [music] [music] [music] So, a crucial moment. Everything is assembled here, everything is soldered, not twisted a little, but now we need to check the operability, whether everything will work or not. So, turn it on turn on, the LED lights up! The screen is updated. WiFi connection. Connected! So, we are waiting for the update. Fine! Shows the time 20:22, Tuesday, the 22nd day, temperature 25.5 degrees and humidity 71%. Humidity is very high. The battery is slightly discharged. WiFi connection is. Fine! It remains to collect all this. You can turn it off. Most interesting: I turned it off now, but the image remains. This is the whole bun of e-Paper displays. They show excellent voltage. Very cool display. Now we put it all together and twist. In general, the device is ready, it remains only to check how it will charge via USB. [music] [music] [music] [music] So, everything is assembled, and everything works fine. The housing is assembled. Bolts, of course, are not super, but they are. It is possible without them. Here is a 256 megabyte flash drive. Temperature and humidity sensor. Switch and USB connector. If you turn off and connect USB, the power will automatically be supplied from USB, and the watch will still work, only the battery will not be discharged. Let’s try to connect the charging now, but before that I will say something. Yesterday I collected this watch and charged it. Quite a lot of time has passed, but the battery still shows a full charge, that is, it practically does not discharge. The battery should last a very, very long time. I measured the consumption, this watch in standby mode consumes (that is, between time updates) about 10-20 milliamps. This is very small. So, we connect the power, and we see the light of the LED from TP4056, which charges the battery. By the way, there was a reconnection of power. If I turn it off now, it will update, reconnect to the Internet. And we see the charging icon, that is, now the device is powered by USB, and the battery is charging. These are such cool, cool watches! Now let’s go over the code and see what we have there and how. In the beginning we connect various libraries. Basically, these are libraries for working with WiFi and NTP server, in order to get the current date and time from the Internet. For more information on NTP server and Internet clock, see another video. The link will be in the description. It also connects a library for working with the display, a library for the DHT22 sensor, and also connects a library for timer interruptions. This interrupt is necessary in order to count down one second. We determine the settings of the NTP server, the settings of the DHT22 sensor it is connected to pin 13. We initialize the sensor, initialize the timer. Also settings on the NTP server. Again: a link to the video will be in the description. Define various variables. Here you need to specify the name of your WiFi and its password. Variables for seconds, minutes, and hours. The variable in which the current date value is stored in numerical format. Variables in which temperature and humidity are stored. And also some temporary variables. These variables store the names of the days of the week and months. Unfortunately, fonts that automatically connect to this display do not support Cyrillic. Therefore, all names are in English. In order to display text in Cyrillic, you need to select special fonts, but I did not succeed. Or enter the text in the form of pictures. That is, draw pictures with text in Russian. The variable voltage on the battery, as well as two variables that give permission to display every minute update or updates over WiFi date and time. Pin that is connected to the pin “wakeup” on the display. A temporary buffer. You can leave it empty, but I wrote “hello string” here, but you can leave it completely empty. Here’s a function that is called by a timer interrupt once per second. Increasing the second value, and if reached 60 seconds, the increment minutes and the same and the hours. Once a minute we give permission to refresh the display. Also, a timer ticks every hour, and if the timer value exceeds a certain value, then we give permission to update via WiFi. That is, update the date and time. I bet 1 time in 6 hours, that is, more than five. You can put any other value, at least 48. To be more precise:47, then the clock will be updated every two days. As soon as the value exceeds 23 hours, it has passed the day, then we increase the value of days. Go to the Setup section. I did not initialize Serial, because it is automatically initialized in the library for the display, because the display works through serial, and there serial is automatically initialized at a speed of 115200. Determine the pin to the output pin is connected to the LED, in order to turn it off to save power. Initialize the display. We initialize the pin with which we will wake up the display. We awaken the display and determines which memory it will work. You can work with the internal memory, and can be operated from an external MicroSD. In this case, I work with an external microsd card, onto which I record all the necessary pictures. After that, we clear the display and set the font format. Next is the internet connection. If the connection has occurred, we display a message that there is a connection, and in Serial we display the ip address at which the connection occurred. We initialize the timer, initialize the temperature and humidity sensor, and update the display. Then turn off the LED on the ESP8266 to save energy. something so difficult is not in the main program loop. If there is permission to update the display, then we will make a ban, and we will do all the other functions. Awaken the display. Draw the background. If there is permission to update via WiFi, we update the date and time, draw an hours, and get data from the temperature and humidity sensor. We draw the value of the battery, and update the image on the display, after which we put the display into sleep mode, and make a delay of 10 seconds. So, let’s go over the functions. The “wakeup” function forces the display to wake from sleep mode. It just changes the pin from Low to High. Function of working with the sensor: we get the temperature and humidity. And if the data is not received for some reason, for example, the sensor does not work, or there may be poor contact. Well, if data is not received, then an error message is displayed. If the data is received, then the display shows the value of temperature and humidity. Drawtime function: this function is needed in order to draw the current time on the display. There is no such large print. The largest one is this one – it spelled out “Thursday” and the numbers “24.5”. To get such a large font, I had to draw it, draw individual numbers. If you look into the folder, here you can see what is on the microSD, which is inserted into the display. Here are individual pictures of numbers, the image of the battery, the image of WiFi, as well as some other pictures that are used. So, this function breaks the number into high and low digits. And depending on which digit is in the Hight or Low category, the corresponding picture is drawn. That is, if it’s 10 now, then the unit is drawn in the highest order, in the low-order zero, and so on. The same goes for minutes. Battery function: in this function, the value from the analog input is read 50 times. After that, the resulting value is divided by 50, and thus we find out the average value. Next, through the formula, we find out the current value on the battery. And, depending on the value, we display the corresponding picture – the picture of the charge or discharge of the battery, or the picture that it is connecting via USB and the battery is charging. If the battery is completely discharged and further operation is not possible, the watch will automatically turn off and display the image of the discharged battery on the display. To do this, the display is cleared, a picture is displayed and the time is entered – here at the top in small print it indicates the time at which the clock went off. In order to roughly know how much battery is enough. You can remove these few lines and not use them at all. The display goes into sleep mode for minimal power consumption, and esp also goes into deepsleep mode for minimal power consumption. The WiFiupd function is needed so that you can connect to the Internet and get the date and time, so that the clock itself does not lag, do not rush, and you can get the current date and time. Here are the main two sections: if connected to the Internet, then we perform a certain part; and if there is no connection, then on the display we draw that there is no Internet, and connect to WiFI. Also on the display we display the current date, that is, Thursday, October 24. In the main function, if WiFi is connected, we display images of connected WiFi. Now WiFi is connected. If permission is given to connect to WiFi, and this permission, as we considered earlier, costs me once every 6 hours, then once every 6 hours I connect to the NTP server and get the current date and time. For more information about the NTP server and getting the date and time, see another video. And we update the value of the variables responsible for the date and time. That’s basically it, that’s all the code. There is nothing particularly complicated in it. These are such interesting watches. Of course, in them, in the watch itself, there is nothing special, but this is the first step to creating a weather station. Still, I will do it. The clock will communicate via WiFi with the ESP8266, which will be installed in the weather station, and here the received data from the weather station will be displayed on the display. Therefore, click on the bell, subscribe to the channel, and do not miss new videos. I wish you success, let your projects be cool and interesting! Subscribe to the channel. Bye everyone!