当前位置:网站首页>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 .
边栏推荐
- Accounting regulations and professional ethics [6]
- 新的职业已经出现,怎么能够停滞不前 ,人社部公布建筑新职业
- Implement graph data construction task based on check point
- 智慧物流園區供應鏈管理系統解决方案:數智化供應鏈賦能物流運輸行業供應鏈新模式
- 基于check-point机制的任务状态回滚和数据分块任务
- System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
- 话里话外:流程图绘制初级:六大常见错误
- Visual Studio 2019 (LocalDB)MSSQLLocalDB SQL Server 2014 数据库版本为852无法打开,此服务器支持782
- Go语言循环语句(第10课下)
- 时钟轮在 RPC 中的应用
猜你喜欢
D3D11_ Chili_ Tutorial (2): draw a triangle
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
智慧物流园区供应链管理系统解决方案:数智化供应链赋能物流运输行业供应链新模式
基于wifi控制的51单片机温度报警器
How can programmers improve the speed of code writing?
程序员怎么才能提高代码编写速度?
Vscode setting outline shortcut keys to improve efficiency
~89 deformation translation
Can you really use MySQL explain?
Years of training, towards Kata 3.0! Enter the safe container experience out of the box | dragon lizard Technology
随机推荐
Market trend report, technical innovation and market forecast of tetrabromophthalate (pht4 diol) in China
从数数开始
Filtered off site request to
go-micro教程 — 第二章 go-micro v3 使用Gin、Etcd
tp配置多数据库
实战:fabric 用户证书吊销操作流程
How to implicitly pass values when transferring forms
Use and principle of thread pool
Readis configuration and optimization of NoSQL (final chapter)
Go development: how to use go singleton mode to ensure the security of high concurrency of streaming media?
安信证券排名 网上开户安全吗
中位数与次序统计量
Opencv learning -- geometric transformation of image processing
S2b2b solution for lighting industry: efficiently enable the industrial supply chain and improve the economic benefits of enterprises
对人胜率84%,DeepMind AI首次在西洋陆军棋中达到人类专家水平
Final consistency of MESI cache in CPU -- why does CPU need cache
Four point probe Industry Research Report - market status analysis and development prospect prediction
overflow:auto与felx结合的用法
Application and Optimization Practice of redis in vivo push platform
Lv166 turned over