Onboard resources:
1 MAX7219
(DIN-GPIO13; CLK-GPIO14; CS-GPIO15)
1 DHT11
(GPIO2)
1 buzzer
(GPIO4)
1 22 WS2812b colored lights
(GPIO5)
1 photosensitive sensor
(model: GL5528 (10K-20K), connected to the A0 pin of ESP-12F through a two-stage voltage divider circuit
(first-stage photosensor + 10K resistor, second-stage 220K resistor + 100K resistor))
2 buttons
(one MODE/SET "universal" button (all functions are controlled by it, this button is a pull-up input, connected to GPIO12, can be set to INPUT_PULLUP),
one RST reset button)
Master control ESP-12F module
(TTL TX, RX, GND are already brought out, GPIO0 and GND are connected to the "FLASH" jumper, and the power supply pins are also brought out on the back (with SS34 anti-reverse connection)
to solve the problem of difficult soldering of MicroUSB vertical sockets)
The code has been attached and can be downloaded if necessary.
For the method of adding ESP8266 environment to Arduino and burning the module, please search Baidu by yourself. For the burning method, please refer to this article:
https://blog.csdn.net/lyndon_li/article/details/124181888
The following are the program variable definitions:
① Initial state setting at power-on, true means there is sound, false means mute. In the power-on state, press and hold the MODE/SET button and then short press RST. Release the MODE/SET button after the digital tube is fully displayed. Then you can switch to the opposite state of snd (that is, true becomes false, false becomes true. This state is not saved and needs to be reset each time you start the machine).
② Whether there is a DHT11 module. If so, set it to true (temperature and humidity will be displayed in mode 4 and mode 5). If not, set it to false (mode 4 and mode 5 will display FAIL to prevent the system from always detecting a non-existent DHT11).
③Hourly time setting, true represents on and false represents off.
Mode analysis:
m value
Mode name
Screen display content
DIG1 display content
DIG2 display content
WS2812 display content
Remarks
0
Empty
0-EP
Time
sleep Sleep
The
lowest brightness and most power-saving mode
1
Second
1-SE
Time
second
sleep
The upper and lower digital tube second dots flash at the same time
2
Weekday
2-Ed
Time
week
sleep
DIG2 displays "d:x", the corresponding x value from Monday to Saturday is 1~6, and x=0 on Sunday (the program can be modified as needed to let DIG2 display d:7 on Sunday, and the variable storing the week is int type "weekDay")
3
Date
3-dA
Time
date
sleep
The date is sometimes accurate and sometimes not, and the algorithm can be changed or set to other modes as needed
4
Temperature
4-tE
Time
temperature
sleep
DIG2 format: xx℃
5
Humidity
5-HU
Time
humidity
sleep
DIG2 format: xx% (the percentage sign is a bit different)
6
Only LED
6-OL
Sleep
Sleep
Virtual clock dial
Red represents the hour hand, green represents the minute hand, and blue represents the second hand
7
LED Clock
7-LC
Time
second
virtual clock dial
Same as above
8
Night Light
8-NL
Sleep
Sleep
Night Light (Warm Color)
RGB(5,5,2) Color Configuration
9
Colorful Light
9-CL
Sleep
Sleep
Color Light (Circular Running)
(Black)→Red→Green→Blue→Red→Yellow→White→Cyan→Blue (Circular)
-Custom ---- // /
Customizable function (global search "//Undefined", the first one is the display when changing the mode ("----"), the second one is the place to place the custom code (need to delete the existing three lines of code first)) The above is the mode introduction. Put a few pictures: m=0: m=1: m=2: m=3: m=4: m=5: m=6: m=7: m=8:
m=9:
The above is a schematic diagram of 10 modes.
How to use:
1. Solder or SMD components. (DIG1 is a 0.56-inch common cathode clock digital tube, DIG2 is a 0.4-inch common cathode clock digital tube. If a white digital tube is used, R1 should be above 100K instead of 10K, otherwise the brightness will be too high (I use 220K, the effect is good, if used at night, 680K is recommended; when soldering DHT11, please bend the pins 90° downward from the root (with the opening facing up), and then align them with the hole for soldering. If all goes well, DHT11 should cover the rectangle in the figure below))
2. First, use a jumper cap or Dupont wire to short-circuit the 2-pin pin with silkscreen "FLASH" (the new version uses the button with silkscreen "FLASH", press and hold the "FLASH" button and then power on, and release the button after the blue light of ESP-12F flashes; you can also press and hold the "FLASH" button and short-press the "RST" button after powering on, and release it after the blue light of ESP-12F flashes), then power on the clock, the blue light of ESP-12F will flash, indicating that there is no problem with the circuit construction.
3. Plug the USB to TTL module into the computer, and connect the TX, RX, and GND of the TTL module to the R, T, and G (cross connection) of the 3-pin pin with silkscreen "TTL" on the front of the clock (the new version of the TTL pin header is on the back), and open the device manager to record the port number of the current TTL module.
4. Open the Arduino IDE software with the ESP8266 development environment configured, press Ctrl+O to open the program file (MAX7219_PCB_Clock.ino), open the library manager, search and install the following libraries:
AceSegment (0.12.0)
AceSPI (0.4.0)
NTPClient (3.2.1)
DHT sensor library (1.4.3)
Adafruit NeoPixel (1.10.4)
WiFiManager (0.15.0)
5. After installation, first select the port just recorded ("Tools" > "Port"), then click Upload. If it prompts that there is no library file, copy the library in the attachment to the "Project Folder Libraries" folder and replace it, or modify the parameters according to the error message. (Sometimes you will encounter strange problems, such as "Error when compiling for xxx". The solution is to copy all the code, create a new draft, paste the code in, then save and upload)
6. Wait for compilation and upload.
7. After the upload is successful, unplug the Dupont wire or jumper cap that shorts the "FLASH" jumper (the new version uses the "FLASH" button, so you can skip this step), then press the "RST" button, the system should restart, both digital tubes will display "88:88", and all LEDs will light up in white. If any light or digital tube does not light up, check whether the solder joints are cold, especially the pins at the four corners of the MAX7219 (those four are signal pins, namely DIN, DOUT, CLK, and CS. The capacitor next to the WS2812 can be left unsoldered, but C22 next to the MAX7219 chip must be soldered! Due to signal communication reasons, the MAX7219 must have a filter capacitor. I once forgot to solder it, and the screen only flashed once. I thought it was broken at the time, but it was immediately fixed after connecting the capacitor) and the four pins of the WS2812 (the pads are very small, and it is difficult to solder with a soldering iron. The pad size can be changed as needed). Sometimes the digital tube will always be fully displayed when powered on, because the noise in the circuit mistakenly triggers the detection mode of the MAX7219. At this time, just turn off the power and then turn it on again. (The signal line in the PCB is bold)
8. If snd=false, DIG1 will display NS (No Sound) after powering on, and after waiting for a few seconds, all LEDs will go out; if snd=true, the buzzer will sound a prompt. Then LED_STATE lights up red and DIG1 displays "AP". After waiting for a while, you can use your mobile phone or computer (even Kindle) to search for the AP access point named "ESP8266_Clock" in the WiFi settings, connect and wait for the page to jump to 192.168.4.1. If not, manually enter the IP address. After the interface is loaded, click "Configure WiFi", select the name of your WiFi network (SSID) and enter the password, then click "Save". If the password is correct, DIG1 will display "GO" soon, and if the environment is bright enough, LED_STATE will light up green. If snd=true, the buzzer will ring 4 times after the network is successfully connected.
9. If there is sound and you want to mute it, or there is no sound and you want to turn it on, press and hold the MODE/SET key, then short-press the RST key, and release the MODE/SET key after the content displayed on the screen changes. At this time, ESP8266 will reconnect to the network and mute or turn on the sound. In other words, pressing and holding the MODE/SET key when booting can change the current sound settings.
10. If all the above steps are completed, then congratulations, you can now start using the clock. Press and hold the MODE/SET key until the screen displays the mode you want (see the table above for the mode code), then release it immediately (there is a 500ms mode switching interval in the program), ESP8266 will switch to the corresponding mode and write it to the EEPROM. The last mode will be remembered the next time it is started, and there is no need to reset it.
11. If the WiFi is disconnected in the time display mode (mode 0~mode 7), the screen and colored lights will go out, and LED_STATE will flash slowly in red. At this time, the system does not accept the MODE/SET key signal (that is, the key does not respond). After the network connection is restored, it will automatically reconnect and display the time (this clock does not have an RTC real-time clock module). If you want to change the network, press the RST key, the system will restart and display "AP", then you can use your mobile phone to re-configure the network. If the network is disconnected in other modes, LED_STATE will light up light red, which will not affect the current mode. In normal use mode, if the ambient light is bright enough, LED_STATE will light up light green.
12. The program has set the hourly time. If snd=true at the hour, the buzzer will sound 10 times (00 seconds to 09 seconds); if snd=false, the front LED_STATE and the back LED_BACKGROUND will flash blue for about 10 times (the original program will only flash about 7 times, and the video in the attachment is the original program). Note that this clock does not support setting the time range, so if you need to use it at night, please set snd to false to avoid disturbing your sleep, or change the program. (The time function in the program can be set in the variable definition (previous article))
------------------------------PCB has been updated (2022-10-01)------------------------------
1. The updated PCB deleted the original LED_BUZ because this light is useless;
2. The position of the USB_IN vertical socket was changed to facilitate the later reinforcement of the solder joint (it was originally directly behind the digital tube, and it could not be reinforced even if it was loose because the solder joint was covered by the digital tube);
3. Use a four-layer board (the original two-layer board automatic wiring has not been able to be laid, and it is always impossible to connect the MAX7219 chip and the digital tube. After many changes, it was found that two lines could not cross other lines, so I had to use a four-layer board), thicken the lines (JLC can still make boards for free, but it is limited to green).
------------------------------PCB has been updated (2022-11-01)------------------------------
1. Added PWR indicator light, which lights up when powered on, and no soldering is required.
2. Changed the position of the buzzer for easier soldering (please solder the buzzer first and then the digital tube, otherwise the buzzer will be very difficult to install).
3. Bring out the data pins of MAX7219, DHT11, and WS2812. You can only solder the ESP-12F minimum system and connect other modules (such as MAX7219 display module, DHT11 module, WS2812 light ring, etc.), or you can use the clock as a display module (suitable for cases where there is already a development board such as NodeMCU or D1 Mini). The two connection methods are as follows:
① External module:
② Use as a module:
③ Of course, you can also not use this clock board and directly use NodeMCU to connect with display modules, key modules, etc.
To facilitate modification, the GPIO definitions of each button are given:
Button
corresponding pin
resistance
MODE/SET
GPIO12
10K pull-up
RST
RST
10K pull-up
FLASH
GPIO0
10K pull-up You
can use cheap buttons on the Internet (generally pull-up by default, the 3V3 pin of the NodeMCU development board needs to be connected to the GND pin of the button module, the GND pin of the NodeMCU development board needs to be connected to the VCC pin of the button module, and the input pin can be directly connected to the OUT pin of the button module) or a touch module instead (TTP223 touch needs to be set to output low level + inching when touched).
eg button module (the red wire is 3V3 of NodeMCU, the orange wire is GPIO12 of NodeMCU, and the brown wire is GND of NodeMCU. The three wires are connected to GND, OUT, and VCC of the button module respectively)
These are the pins of the other modules:
Module pins
ESP8266 GPIO (please connect NodeMCU according to the pin mapping)
Remarks
DHT11 temperature and humidity sensor --- DAT
2
It is recommended to connect to 3V3 for power supply
BUZZER buzzer module --- I/O
4
The positive pole can be connected to 3V3 or 5V, the enable end is connected to GPIO4, and the negative pole is connected to GND
WS2812 colored lights --- DAT
5
The lamp beads are powered by 5V, and the data line is directly connected to GPIO5
MAX7219 digital tube display module --- DIN
13
MAX7219 module is powered by 5V
MAX7219 digital tube display module --- CLK
14
MAX7219 module is powered by 5V
MAX7219 digital tube display module --- CS
15
MAX7219 module uses 5V power supply
Photoresistor module --- AO
A0
Photoresistor module uses 3.3V power supply
Button MODE/SET --- OUT
12
Connect GPIO12 Pull up 10K resistor input
4. For easy welding, most resistors are packaged in R2512, and a few are packaged in R2010 (R2512 is all 10K resistor, R2010 is the voltage divider circuit of the photoresistor, one 220K, one 100K).
5. Change the FLASH jumper to a button (on the back) for easy burning during debugging, or you can customize its function in the program (GPIO0 can also be used as input).
------------------------------Program updated (2022-11-04)------------------------------
Add new program file: MAX7219_PCB_Clock_Inverted.zip. If you use the MAX7219 module instead of this clock as the time display, the original program MAX7219_PCB_Clock.ino will have the following problems (compare):
Obviously, the display order of the MAX7219 digital tube module below is reversed, "8:57:08" becomes "80:75:8". If you encounter this problem, please burn MAX7219_PCB_Clock_Inverted.ino instead of MAX7219_PCB_Clock.ino*. MAX7219_PCB_Clock.ino is written in the order of Seg7 to Seg0, and MAX7219_PCB_Clock_Inverted.ino is written in the order of Seg0 to Seg7, which can adapt to almost all MAX7219 display modules.
________________________________________________________
*Because the PCB is designed according to the MAX7219CWG chip datasheet, the first to eighth digits correspond to DIG0 to DIG7 of the MAX7219 chip, and most MAX7219 modules on the market connect the digital tubes in the order of DIG7 to DIG0 (even the developers of the "AceSegment" library are written in the order of DIG7 to DIG0), so if you use the PCB as a clock, you need to reverse 0-7, and the first digit (upper left ↖) to the eighth digit (lower right ↘) correspond to Seg7 to Seg0 in the program.
This is the effect of ESP8266 controlling the MAX7219 display module after flashing MAX7219_PCB_Clock_Inverted.ino:
This problem has been fixed. (The displayed seconds are different because of the NTP time update problem. The program is set to calibrate the time once every second, so there will be an error of ±1 second)
------------------------------The program has been updated (2022-12-17)------------------------------
In order to meet some scenarios without WiFi connection, the program has added 2 (Appendix 6 and 7). The firmware with "No_Checking" will not turn off the digital tube and flash the red light due to no WiFi connection.
------------------------------The text has been updated (2023-01-11)-----------------------------
*Fixed some typos and incorrect punctuation.