Material preparation
STC89c51/52 One
ESP8266-01 One
mobile phone One
First download STC89c51 sample program (keil programming development)
Program download address: cloud.bemfa.com/zip/stc89c51_wechat.zip
Program description, baud rate 9600, crystal oscillator 11.0592
Since the default baud rate of ESP8266-01 is 115200, you need to manually adjust the baud rate of esp8266-01.
Adjustment method: ESP8266-01 is connected to the usb to ttl
five wires
esp8266---------UsbTTL
tx----------rx
rx----------tx
vcc-------3.3v
gnd--------gnd
en----------3.3v
Open the serial port debugging assistant, set the baud rate to 115200, find the com port of esp8266 and open it, send
AT+UART=9600,8,1,0,0
Copy code
A carriage return and line feed should be added at the end, and the serial port will reply ok
If it does not reply OK, the firmware may not support changing the baud rate. You need to flash the official AT firmware. Please refer to my other article Flashing the official firmware
Serial port debugging assistant download tool: www.lanzous.com/iax97ih Password: 1234
Use keil to open the program, you need to modify WIFI and other information
#define Ssid "newhtc" //WIFI name, change it to the WIFI name of your own router, it seems that Chinese is not supported
#define PassWord "qq123456" //WIFI password, change it to your own router
#define Uid "4d9ec352e0376f2110a0c601a2857225" //Bafa Cloud UID key, obtained from the console
#define Device "ewew00232" //Device name, you can name it as you like, in string format
Copy code
The user's private key can be obtained by clicking on the Baffa Cloud Console. After logging in by scanning the WeChat QR code, you can click on the Baffa Maker Cloud Console to obtain it.
Users who registered with an email address need to click "Bind WeChat" in the console to bind, otherwise messages will not be pushed.
After logging in, you can see your private key UID in the console, as shown in the figure:
Second key program explanation
int dataLen;
float postData[150];
char strLen[3];
char Msg[] = "message"; //Message body, customizable, string format
char Msg2[] = "Message 2, Remarks"; //Additional message, customizable, string format
sprintf(postData,"uid=%s&type=1&time=0&device=%s&msg=%s&msg2=%srn",Uid,Device,Msg,Msg2); //Integrate the data that needs to be posted through the & symbol
dataLen = strlen(postData); //Calculate data length
sprintf(strLen,"%d",dataLen); //int type to char
ESP8266_Set("AT+CIPMODE=1"); //Enable transparent transmission mode
ms_delay(1000);
ESP8266_Set("AT+CIPSTART="TCP","api.bemfa.com",80"); // Connect to server and port
ms_delay(1000);
ESP8266_Set("AT+CIPSEND"); //Enter transparent transmission mode, all the following will be transmitted unconditionally
ms_delay(1000);
ESP8266_Set_Only("POST /api/wechat/v1/ HTTP/1.1rnHost: ai.bemfa点comrnContent-Type: application/x-www-form-urlencodedrnConnection:closernContent-Length:");//ţքdeviceۅ ţքsensorۅ
ESP8266_Set(strLen); //Data length (postData data length), must be accurate
ESP8266_Set(""); //Enter (after sending the data length, there is a carriage return, Baidu http post format for those who don’t understand)
ESP8266_Set(postData); //Send data
ms_delay(2000);
ESP8266_Set("+++"); //
memset(strLen,'',3); //Reset array
memset(strLen,'',sizeof postData);//Reset array
Use HTTP POST to push messages to the WeChat API. For specific interfaces, please refer to: Bafa Cloud Official Document
Third Download the program to STC89c51 to
download the tool STC-ISP: Download: www.lanzous.com/iaxa4fc Password: 1234
STC89 and ESP8266 wiring problem
c51 ----------8266
P30----------TX
P31----------RX
3.3v-----------3.3v
Gnd---------Gnd
3.3v-----------EN
Tried 8266 directly connected to 5v and it also worked, but it is not recommended to use
the fourth effect display
Fifth, some minor problems you may encounter
Previous article:mcu-stc12c5404ad MCU brushless dc motor driver
Next article:51 single chip microcomputer three-way answering machine
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- MCU Principles and Interface Technology C51 Programming (Edited by Zhang Yigang)
- Quick Reference Manual for Common Electrical Technical Data
- Principles and Applications of Single Chip Microcomputers (Second Edition) (Wanlong)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- Moto 360 Wireless Charging Base Disassembly
- What is MU-MIMO and why is it important for Wi-Fi 6 and 6E?
- 【Lazy Self-Care Fish Tank Control System】Work Submission
- [Summer benefits to celebrate the Dragon Boat Festival] A large number of technical information is waiting for you to claim, and there are also gifts to help
- Please help me find which resistor in the picture is the 1.1K resistor in the formula?
- Xiaozhi Science Popularization丨How to Correctly Understand Power Supply Ripple and Noise
- Find the maximum voltage stress of the diode when it is working
- About QQ Chat at Work
- Naming method of TMS320 chip
- I am a newbie, please give me detailed answers