当前位置:网站首页>51 single chip microcomputer temperature alarm based on WiFi control
51 single chip microcomputer temperature alarm based on WiFi control
2022-07-04 16:57:00 【Eat meat to solve a thousand worries】
Beginner's notes , There are inevitably many mistakes . Forget that you guys will not hesitate to give advice after finding mistakes
The author is not an electrical major , There is no knowledge support in many places , It is inevitable to make mistakes or explain ambiguities
Links to a full set of materials : Baidu SkyDrive
My applet source code : Click extract
1、 Function is introduced
- Expand the display to show the current temperature and threshold temperature .
- When the temperature exceeds the set threshold, the buzzer will alarm .
- Can pass wifi Use the mobile interface to adjust parameters .
Because there were several experiments before, the mobile phone could not be connected to the MCU , I thought wifi The function of can only change the level of hardware . But after experimental tests ,wifi The function of can directly put statements . So the logic is simple , direct if-else Dafa .
2、 Introduction to logical structure
adopt wifi The incoming characters change the existing program if else Dafa
3、 MCU pre knowledge
3.1 Why choose SCM
SCM can Collect data from reality And through the program to deal with . Make electronic devices more intelligent through program control . It is convenient for people's life .
3.2 What is single chip microcomputer .
- In my eyes, SCM is a microcomputer .
- It has some extended interfaces, such as : display 、 Temperature collector 、 bluetooth 、wifi etc. . These extenders give the single chip microcomputer more powerful functions .
- Strong electrical characteristics . Change the electrical characteristics of a certain position through the program to realize the function .
Roast can only be used C The ancient grammar of language .
3.3 How to use SCM
After the electrical details are encapsulated into a small black box, the program becomes a tone API Write C Language applet .
But if you don't understand the underlying electrical principle, you will overturn ~, For details, see the following “4.3 Show function “
- Software direction requires programming foundation (51 The language of MCU is C)
- Hardware direction requires understanding board principle .( The author said he couldn't understand ( I'm not going to understand ))
4、 The overall development process
Sensor and IO The communication of the mouth is very difficult to understand , This is also one of the ideas that cut me off from learning hardware ~~
But but but Communication can hardly be changed , That is to say, directly transfer what others have written API That's it
4.1 What is in the main function
- Capture the current temperature and display plus to judge whether to alarm
- Capture the interrupt and enter the edit threshold mode
4.2 Realize the capture temperature function
It uses DS18B20 Temperature sensor . Determine the calculation formula according to the hardware characteristics 、 Timing controls the process of temperature reading
4.3 Implement the display function
Used to display prompt information and input information .
use LCD1602 Liquid crystal display (LCD) . Only English can be displayed . Here, the screen is not cleared after the display, and the car overturns .
4.4 Implement the alarm function
if Judge , If the temperature is higher than the threshold, the buzzer will vibrate .
4.5 Realize the modification of threshold function
Pass in the parameter : Letter
- A: Enter editor
- B: Exit the editor
- C: Delete a bit
- D: decimal point
- similar ‘1’: Numbers
Realization way : Array sentry
Show function after each call
4.6 Realization wifi The incoming data enters the modified threshold function
At first, the store sent me wifi Something is wrong with the module , For a day , After the communication failed, he gave a well grounded negative comment , The store owner reissued a good module :happy:.
if - else
Call the modify threshold function . The point is wifi Communication for . The use of wifi The module is ESP8266-WIFI.
Communication needs to be guaranteed wifi The baud rate is the same as that of MCU .
Function by sending AT+CIPSEND=0,7 Instructions , Set the sending data length , Then send the data To WIFI modular .
commonly APP The format of the sent data is :+IPD,ID Number , Send data length : data .
When the mobile phone is successfully connected to the hotspot , among +IPD,ID The number is fixed , Users can send How much data , Then the length can be determined . In this way, the serial port receiving interrupt can follow this format To analyze , Our main concern is “ data ” That piece of .
For example, control in the experiment in the supporting materials LED1 On command :+IPD,0,1:1 Each data is 10 Characters . The data is s[9] 了 .
5、 Summary
The final code still has large and small bug, It can only be said that I can barely run .
Through half a month of single-chip learning , I know more about software control . I also have some knowledge of hardware .
边栏推荐
- 多年锤炼,迈向Kata 3.0 !走进开箱即用的安全容器体验之旅| 龙蜥技术
- Implement graph data construction task based on check point
- Research Report on market supply and demand and strategy of China's Sodium Tetraphenylborate (cas+143-66-8) industry
- 基于wifi控制的51单片机温度报警器
- 对人胜率84%,DeepMind AI首次在西洋陆军棋中达到人类专家水平
- 周大福践行「百周年承诺」,真诚服务推动绿色环保
- System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
- Vscode prompt Please install clang or check configuration 'clang executable‘
- China tall oil fatty acid market trend report, technical dynamic innovation and market forecast
- Sql实现Split
猜你喜欢
S2b2b solution for lighting industry: efficiently enable the industrial supply chain and improve the economic benefits of enterprises
What is torch NN?
Opencv learning -- geometric transformation of image processing
Congratulations to Mr. Zhang Pengfei, chief data scientist of artefact, for winning the campaign Asia tech MVP 2022
Position encoding practice in transformer
周大福践行「百周年承诺」,真诚服务推动绿色环保
Understand asp Net core - Authentication Based on jwtbearer
MFC implementation of ACM basic questions encoded by the number of characters
照明行业S2B2B解决方案:高效赋能产业供应链,提升企业经济效益
Visual Studio 2019 (LocalDB)MSSQLLocalDB SQL Server 2014 数据库版本为852无法打开,此服务器支持782
随机推荐
L1-072 scratch lottery
Accounting regulations and professional ethics [11]
Jump table instance
NoSQL之readis配置与优化(终章)
C implementation defines a set of intermediate SQL statements that can be executed across libraries
Market trend report, technical innovation and market forecast of tetrabromophthalate (pht4 diol) in China
Understand asp Net core - Authentication Based on jwtbearer
ECCV 2022 released: 1629 papers were selected, and the employment rate was less than 20%
Interface fonctionnelle, référence de méthode, Widget de tri de liste implémenté par lambda
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Object.keys()的用法
js中的数组筛选fliter
Market trend report, technical innovation and market forecast of electrochromic glass and devices in China and Indonesia
~89 deformation translation
tp配置多数据库
Accounting regulations and professional ethics [8]
如何实现一个延时队列 ?
Median and order statistics
APOC自定义函数和过程
GO开发:如何利用Go单例模式保障流媒体高并发的安全性?