Recently, both the main and sidelines are very busy , The first father's Day , Will spend in Tianjin , This is also the first time in my life to go out of Guangdong , The work is done 99% 了 , Relatively speaking, I still have a sense of achievement , I learned a lot , It's off this afternoon , Continue to update the official account. ：
ESP8266 It's really playable , The official account was also a lot. ESP8266 Application , Like recently , I improved the car I had done before , Because of the poor assembly process of the car , The four wheels often deviate , So I spent hundreds of oceans again , A tank was rebuilt , I haven't had time to post , Let's show you the effect ：
Okay , Let's get to the point , Use ESP8266 To upload data to the public cloud -
Looking at most of the public clouds , As far as personal contact is concerned , I think China Mobile OneNet The platform is the best to use , below , We're simply based on the official website HTTP How to operate developer documentation , adopt ESP8266 Report data , Finally, the exhibition was carried out through the platform ：
Address of operation guide document ：
According to the operation guidelines , Here's me at OneNet A multi protocol access product has been created on the platform :
here , Let's focus on HTTP The partial , Other parts are used to understand in detail .
This part is also used later HTTP The groundwork for the agreement , There are some parameters that we need to use later , For example, equipment ID,OneNet Registered on the platform APIKey.
About HTTP Learning agreement , You can refer to the article of the boss , This is what I think is the most easy to understand ：
As shown in the figure above , This is the data flow template I created , And here's a simple one HTTP head +HTTP Data packets .
Such a simple data upload template is completed , Next we use ESP8266 Let's measure it ：
About ESP8266 Some of the basics of networking have been written in previous articles , There's no repetition here , Please see below , Of course, I wrote an article before ESP8266 transparent transmission HTTP Server articles , This is for SoapUI Built HTTP The server .
The above serial port terminal has received the reply from the background 200OK Field of , Data has been successfully uploaded to OneNet The server , Next we log in OneNet Cloud platform , You can see that the data has been successfully transmitted ：
Here's a set of data that I randomly simulated , The platform can be successfully received and displayed through the line chart .
So in MCU How to realize it in software ？ It's simple , We send and receive in the serial port terminal process with code to achieve it , In fact, most of Xiaobai is not entangled in how to pass ESP8266 To connect hotspots , Connect to server , Look for wildfire 、 On time atomic and other manufacturers ESP8266 Routines can be easily obtained , What Xiaobai is struggling with is , How to group a program HTTP Data packets , Finally, the data packets are transparently transmitted to the server .
The following tests are run on the bear pie development board , Source code, please see the reply field at the end of the text , The key part of the code is as follows , It only needs WIFI After entering transparent transmission mode , Cycle call
OneNet_SendData This function can continuously receive data in the background , It should be noted that ,
ONENET_DEVICE_ID as well as
ONENET_API_KEY These two macros , Please fill in according to the actual information you registered on the platform .
OneNet Data display after receiving data on the platform :
Official account back office reply ：OneNet You can get the download link of the program case in this section .
reminder ： If you have bear pie development board , Please modify the above red box fields , The rest of the program does not need to be modified , platform , According to the article in the platform to do the corresponding settings , Finally, download it directly to the development board , Open the serial terminal and OneNet Platform to view experimental results .
Last , Official account reader requirements , A recent photo of Mr. Yang ,4 Embedded career veteran , This is my first appearance in official account
Tomorrow is the first father's day of my life , Happy father's Day , Fight hard , Let Xiao Yang live a happy life ！
I think this article is helpful to you , Let's go
[ Looking at ] And forward to share , It's also my support .