当前位置:网站首页>DIY a low-cost multi-functional dot matrix clock!
DIY a low-cost multi-functional dot matrix clock!
2022-07-04 16:24:00 【Basketball fans who write code】
Hello everyone , Forward an article of mindfulness classmates
----
Hello everyone , I am a ZhengN.
This time I reprint a nanny grade diy course : be based on Esp8266 Multi function dot matrix clock
.
brief introduction
I have known for a long time ESP8266 了 , At that time, I also used this to make some small demo, I never thought about getting some actual works out , Maybe it's because I compare dishes ! Recently, I'm not so busy at work , Think about building a new one mqtt The server , Do some functions related to the Internet of things .
When browsing the forum, a post attracted me , It's this one :
https://www.arduino.cn/thread-98790-1-1.html
Let me have the idea of making a lattice clock by myself , So I started the production journey of dot matrix clock bit by bit , The process is not difficult , But I also encountered many problems on the way , I encountered many problems on the way , Some have been solved , Some can only be solved simply and roughly , Fortunately, you can finally realize the functions you want .
Sum up experience and lessons and want to share them with people who have the same interests , Writing is not very good , The code is not well written , But still can't stop this sharing heart .
demonstration
picture
video
https://www.bilibili.com/video/BV18i4y1R7ft?spm_id_from=333.999.0.0
idea
Although many people have done or are doing it on the Internet esp8266
Dot matrix clock , I repeat it more like building wheels , As a developer, I also resist the behavior of building wheels repeatedly .
But as a beginner, I want to experience the process of making wheels , And in this process, I hope this wheel has more personal thoughts in it , So I thought about starting this thing from scratch .
My personal idea is to make a simple lattice clock , In addition to having more other functions , To meet its core functions ( The clock , Low error ), The second is to have more functions , Simpler interaction , Moreover, the cost should be low , Hope to think of yourself diy
Of people use the lowest cost to make a beautiful and easy-to-use dot matrix clock .
Simple
To use
Rich in functions
Low cost
Hardware material
Here I will only introduce some necessary hardware , If you know everything, you don't need my little white list . Here I also put a Taobao store I've been shopping in : Xinwei Electronic Technology .
It's not advertising , Mainly because the contents are relatively comprehensive , And the price is about the same , When buying things, you don't need to change between different Taobao stores , And the freight is only 3 element , Generally, the freight of this kind of electronic product store is 5-6 yuan . Please Baidu by yourself for the specific functions of components , I won't repeat them one by one .
NodeMcu(Esp8266)
This is our core hardware , A lot of function , It may be due to the rise in chip prices this year , Such things are becoming more and more expensive .
DS3231
The main function of buying this module is not to reset the power down time , And the time error is small .
Max7219 32x8 Lattice
There seem to be quite a few dot matrix driver chips ,Max7219
One advantage is that it can be cascaded .
There are several DuPont lines
Buying DuPont line is to solve the trouble of welding , We can quickly and easily figure out the circuit we need
Single touch module
It was originally a inching switch , But that kind of cost is not low , The experience is not good , So buy this kind of touch module , Used to realize click , double-click , Long press and other functions , Of course, this is unnecessary , If you don't want any entity interaction , Only small programs interact , You can ignore this module .
Clock function
Hardware functions
NTP Timing
Adjust the brightness
Display time
Show date
Show the temperature
Show B The number of fans standing
Show custom content
OTA to update
Wechat applet function
Synchronize device status
Set the display direction
Set brightness
Set whether to display
Switch display content
Switch display mode
Return to factory
wifi Distribution network
OTA to update
Customize lattice content
Schematic diagram
There is really no talent for drawing , There is no better mapping tool , Only with windows The self-contained drawing tool makes a simple and easy to understand schematic diagram , See forgiveness
PS:
Li Chuang PCB Schematic and PCB Planks are already on the way to production , With subsequent updates
The production process
In fact, the production process is simpler , It is mainly divided into the following steps
1. Purchase components
For purchasing equipment, please refer to some components mentioned above , Many Taobao stores on Taobao sell .
2. Install the corresponding software
The software we mainly use here is arduino
quite a lot diy Fans should have used , Used users can skip , You can also look down
install Arduino
Download via official website Arduino IDE
, Unzip and run arduino.exe
That means the installation is complete . The download address is as follows :
https://downloads.arduino.cc/arduino-1.8.19-windows.zip
If the link fails , Please be there. Official website download , Download options Windows ZIP file
install esp8266 SDK
Here I also carry it directly from the Forum , But for the convenience of reading, it is listed below , You can directly follow the steps I listed , If you have any questions, please go to here See if there are other solutions
open
Arduino IDE
menu > file > Preferences , stay Add development board manager website In the input box , Fill in the following website :https://www.arduino.cn/package_esp8266com_index.json
Download community packaged
esp8266
Installation package , Just run it directly and decompress it
SDK download (44M):
Blue cloud sharing address :https://wwi.lanzouo.com/ij4GEyjcz7c ( This is recommended )
Alicloud disk address :https://www.aliyundrive.com/s/QhgGreFTjJb ( This is recommended )
Double click Run to unzip , After decompression , And on again Arduino IDE
, Can be in menu bar --> Tools --> Development board
Find what you use esp8266
Development board
Tips : If you have installed other versions esp8266sdk, Please delete first. , Reuse this installation package , Delete method : Enter... In the file manager address field %LOCALAPPDATA%/Arduino15/packages, Enter by car , then Delete Drop some of them esp8266 Folder
Install serial driver
NodeMcu There are many specifications , It's common to see CP2102 Serial chip and CH340 Serial chip , Therefore, corresponding drivers are required , Here are the driver download addresses for both :
CP2102 drive
Blue cloud sharing address :https://wwi.lanzouo.com/iU5mcyjdxuj ( This is recommended )
Blog file address :CP210x_Universal_Windows_Driver.zip( I don't recommend this , If the above link fails, you can use )
CH340 drive
Blue cloud sharing address :https://wwi.lanzouo.com/iyFTayjdxsh ( This is recommended )
Blog file address :CH34x_Install_Windows_v3_4.zip ( I don't recommend this , If the above link fails, you can use )
Decompress the corresponding driver package , Then double click the driver of the corresponding system .
After the driver is installed successfully, you need to restart the computer
3. Connect the corresponding wire
Here is a simple connection using DuPont line , If there is a big man willing, you can also weld through the circuit diagram I draw , However, it is recommended to use DuPont cable connection first , Conduct welding treatment after debugging the program .
NodeMcu
and Max7219 Lattice
connection
VCC → 3.3V ( In fact, you can also connect here 5v, If you want the brightness of the lattice to be brighter )
GND → GND
DIN → D7
CS → D6
CLK → D5
NodeMcu
and DS3231 modular
connection
VCC → 3.3V ( Don't answer here 5v, Low voltage is safer )
GND → GND
DIN → D7
SDA → D2
SCL → D1
NodeMcu
and Single touch module
connection
VCC → 3.3V ( Don't answer here 5v, Low voltage is safer )
GND → GND
SIG → D8
4. Write program
Use Arduino
The writing program is actually quite simple , The general steps are divided into the following steps
Check
Simple ESP8266SDK Is the installation successful
Check whether the serial port driver is successfully installed
Install the required dependency packages
Because I'm also a beginner , Many use other people's library files , I didn't go deep into the principle to rewrite the code , So we need to install some library files
The installation steps are as follows :
Tools --> Management of the library --> Search the libraries we need to install --> Click Install
The library files to be installed are as follows
DS3231
DS3231 Clock ready-made library fileLedControl
drive Max7219 Lattice library fileOneButton
Realize key click , double-click , Long press function library
If there is a missing Library , Please read the error message , Press the error prompt to install the Library
Download the source code
github
download https://github.com/Lengff/esp8266-lattice-clock-opengitee
download https://gitee.com/lengff/esp8266-lattice-clock-openDownload our source code through the above address .
Write source code to Esp8266
adopt
Arduino IDE
Open the code we downloaded in the previous stepfile --> open --> Select the folder where the source code is located .ino Postfix file
Choose development board
Tools --> Development board --> ESP8266 --> NodeMcu 1.0
Choose development board Select port
Tools --> port --> Select the port corresponding to our serial port device
Write program
project --> Upload
orPoint left → arrow
( Baud rate is selected 115200, It's going to be faster )
5. test & test
Here are many problems encountered in personal processing :
Program compilation failed
The most likely reason for compilation failure is that the library file does not exist , perhaps esp8266 Of sdk There is a problem with the installation , Just check the compilation error
Program upload failed
Upload failure basically means that the serial port is not selected correctly or the development board is not selected correctly
After uploading successfully, there is no display
Here you need to check whether your wiring is correct .( Please disconnect the power supply before doing this )
One click distribution is unsuccessful
The distribution network requires mobile phones and devices to be in the same wifi, And wifi yes 2.4G Of wifi
Check the dot matrix display :
no wifi
Indicates that... Has not been configured wifi, Need configuration wifi;con wifi
It means that wifi Information. , on connection wifi, If you need to reconfigure wifi You need to press and hold the touch button 6 Seconds to reset the system .It is suggested to press
nodeMcu
Upper reset Key , Then click the distribution network on the mobile phone
The content displayed after the distribution network is successful is 23:59:59
This means your DS3231 There's something wrong with the wiring , It is necessary to check whether the wiring is correct .( Please disconnect the power supply before doing this )
If it doesn't work , Please disconnect the power first , then DS3231 Remove the battery on , Try again after reinstallation .
Interaction
On the hardware, we set up a touch button for human-computer interaction , I implement more interactive logic on small programs .
Touch the button :
single click : Click to switch the display function , At present, it is
Time - date - temperature - B The number of fans standing - Custom display
Five cycle switchingdouble-click : Double click to switch the display mode of the function , for example : There are two display modes of time 1.
when - branch - second
2.when - branch
Two different display modes can be realizedLong press for three seconds : Long press for more than three seconds and less than six seconds will trigger NTP Auto calibration time
Long press for six seconds : Long press for more than six seconds will reset the system ( When the system is abnormal , Or replace wifi The system needs to be reset )
Wechat applet :
I won't go over it here , The functions of wechat applet are relatively simple and clear. You can see it at a glance , All the functions supported by the above keys are supported by wechat applets
Applet
Why do you choose applets to interact with Esp8266 Interaction ?
Small programs are relatively fast to develop , There are many functions supported , Many functions are called directly api that will do
Use app Or visit esp8266 I think the interaction of the pages inside is a little poor , I think the most interaction should be simple , There is no need to have too much learning cost
The applet supports distribution network ,UDP, Bluetooth and many other functions , Other subsequent small works may use small programs
The page display
Code
At present, the applet is not in this open source sharing , In fact, small programs are not difficult , And it can be used directly , Reduce everyone's development work .
Applet entry
Scan the following applet code through wechat or Wechat search applet Lengff
You can find my applet
Communication mode
at present esp8266 The communication with applet is using UDP The way of communication , Use UDP The advantage of the communication method is that there is no connection , Open and use , There is no need for a server .
Just promise esp8266 The same LAN is connected to the mobile phone , And you can find devices by broadcasting , There is no need to establish long links , The disadvantage is instability , Loss of package , But I think it is acceptable , Because mobile phones send more instructions , Every time I send instructions twice, the probability of packet loss will decrease .
Transfer protocol
udp Is to send some hex Data packets esp8266 Data transmission with mobile phones , So I simply defined my own UDP Transfer protocol , Agreement as follows :
Customize a UPD Protocols are used for applets and esp8266 Conduct UDP signal communication
|0 1|2 3 4 5|6 7|0 1 2 3 4 5 6 7|
---------------------------------
|RT |TE |VN | LH |
---------------------------------
Message data (64bit)
---------------------------------
Customize UDP Agreement that :
1. RT: (2bit) Successful return value
2. TE: (4bit)type Message type : 0: reset time ,1: Set brightness ,2: Switch function ,3: Switch function display style ,4: subscribe BIlibiliUID ,5: Whether to enable dot matrix screen ,6: Switch the display direction ,7: Set user data ,8: Set animation speed ,9: OTA upgrade ( There's a flaw here , It only supports 16 Types , So we will expand here later )
3. VN: (2bit)version Protocol version , It's fixed at present as 1
4. LH: (8bit)length Packet length
5. Message data : (64)bit edition 1 The maximum packet length currently supported is 64bit
Optimize ?
Optimization space is natural , In fact, the change is not big , That is the subsequent access to their own MQTT The server is compatible UPD Communication mode , But at present, there is no stable and available server , Blind access and subsequent upgrading will affect the normal function of the device .
Self evaluation
This project ( It's also a small project ) I did it for more than a month , It can't be regarded as from 0 Start , At first, I will be familiar with something , Only the knowledge points are scattered , It's like a messy puzzle , This time it's like a jigsaw puzzle .
Although it's not spelled well, it's also a work spelled out at least , Although many people make this kind of dot matrix clock , But I personally feel that if I really practice, I will find it is not so simple , And you may not be satisfied with what others do , Do it by yourself, and you can inject your soul into it .
Here is my personal feeling : I am not full-time engaged in this kind of hardware development , This is just a personal hobby , Although I usually accumulate some relevant knowledge , But it is far less efficient than systematic learning .
So if you really want to learn this, you should systematically watch some videos to learn , The second is practice , Although I have mastered some scattered skills , But I don't know how to use , So you need to practice constantly to understand your skills .
shortcoming :
Connection required wifi( And it must be 2.4Gwifi) Ability to use -( This will also be optimized in the subsequent procedures )
Continuous power supply is required , Because lattice power consumption is relatively large , So the experience of using battery is very poor
advantage
Support OTA Sustainable renewal system
The interaction is simple and convenient
Support customized display content
ending
Here I offer a 8x8
and 32x8
Dot matrix online mold tool , It's rough , If you need to improve, please leave a message in the comment area .
8x8 Dot matrix online mold tool :http://lengff.com/lengff/lattice2.html 32x8 Dot matrix online mold tool :http://lengff.com/lengff/lattice3.html
reminder
Because the official account of WeChat has changed the push rules recently , If you want to see our articles often , After each reading , Click one at the bottom of the page 「 Fabulous 」 or 「 Looking at 」, In this way, each article will appear in your subscription list for the first time .
边栏推荐
- MySQL index optimization
- What is torch NN?
- Redis shares four cache modes
- odoo数据库主控密码采用什么加密算法?
- Functional interface, method reference, list collection sorting gadget implemented by lambda
- MySQL~MySQL给已有的数据表添加自增ID
- AI has surpassed Dr. CS in question making?
- error: ‘connect‘ was not declared in this scope connect(timer, SIGNAL(timeout()), this, SLOT(up
- 165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
- . Net delay queue
猜你喜欢
Overview of convolutional neural network structure optimization
科研漫画 | 联系到被试后还需要做什么?
Using celery in projects
What is the future of the booming intelligent Internet of things (aiot) in recent years?
Dry goods | fMRI standard reporting guidelines are fresh, come and increase your knowledge
Audio and video technology development weekly | 252
Understand the rate control mode rate control mode CBR, VBR, CRF (x264, x265, VPX)
Redis' optimistic lock and pessimistic lock for solving transaction conflicts
MYSQL索引优化
Ten clothing stores have nine losses. A little change will make you buy every day
随机推荐
Hidden communication tunnel technology: intranet penetration tool NPS
Detailed explanation of MySQL composite index (multi column index) use and optimization cases
Understand the context in go language in an article
Filtered off site request to
Change the mouse pointer on ngclick - change the mouse pointer on ngclick
Book of night sky 53 "stone soup" of Apache open source community
Logstash~Logstash配置(logstash.yml)详解
Object distance measurement of stereo vision
What should ABAP do when it calls a third-party API and encounters garbled code?
Recommend 10 excellent mongodb GUI tools
数据湖治理:优势、挑战和入门
A trap used by combinelatest and a debouncetime based solution
Unity脚本API—Time类
Communication mode based on stm32f1 single chip microcomputer
2022年九大CIO趨勢和優先事項
Live broadcast preview | PostgreSQL kernel Interpretation Series II: PostgreSQL architecture
Data Lake Governance: advantages, challenges and entry
MySQL - MySQL adds self incrementing IDs to existing data tables
Explore mongodb - mongodb compass installation, configuration and usage introduction | mongodb GUI
[book club issue 13] packaging format and coding format of audio files