当前位置:网站首页>Internet of things? Come and see Arduino on the cloud
Internet of things? Come and see Arduino on the cloud
2022-06-24 20:21:00 【u012804784】
High quality resource sharing
| Learning route guidance ( Click unlock ) | Knowledge orientation | Crowd positioning |
|---|---|---|
| 🧡 Python Actual wechat ordering applet 🧡 | Progressive class | This course is python flask+ Perfect combination of wechat applet , From the deployment of Tencent to the launch of the project , Create a full stack ordering system . |
| Python Quantitative trading practice | beginner | Take you hand in hand to create an easy to expand 、 More secure 、 More efficient quantitative trading system |

author :HelloGitHub-Anthony
Here is HelloGitHub Introduction of open source hardware development platform Arduino Series of tutorials for .
- Chapter one :Arduino Introduction and development environment construction
- Second articles : Make temperature and humidity display
Last article , We explained how to install Arduino support library 、DHT 11 Temperature and humidity sensors and OLED Use of screen , And use Arduino A small temperature and humidity display is made .
In this particular, we pay attention to All things connected Era , Let's Arduino Temperature and humidity “ On the cloud ” play , There is a scientific name called the Internet of things .
The Internet of things (IoT) Is a network of physical objects , These physical objects are embedded with sensors 、 Software and other technologies , So that it can establish connections with other devices and systems and exchange data through the Internet .
Do you feel a little taller in an instant , But don't worry about the knowledge in this issue , Because the profound I will not !
Today we're going to talk about : How to put the temperature and humidity equipment made in the last phase into the cloud , Through the Internet of things platform Real time data upload and Remote control equipment . The implementation will Arduino The temperature and humidity data measured by the equipment are uploaded to the Internet of things platform , Then the receiving platform sends instructions to the control equipment LED Light switch .
Have you started to sharpen your fists ? Now let's start “ On the cloud ”!
One 、 Realize networking function
1.1 Module introduction
First , If you want to Arduino Servers connected to the Internet of things platform , It is necessary to enable the device to connect to the network first ( Like at home WiFi), Here we need to use ESP-01(s) modular , To achieve this function .
Its usage is similar to that of the components described above , Just use VCC(3.3v)、GND、TX、RX Four lines , And Arduino communicate . What I use here is ESP-01+ Adapter plate , The adapter board realizes 5v->3.3v And Rx and Tx Leading out of the interface , Convenient for subsequent use .

majority ESP-01(s) The module leaves the factory , It's all built in AT Command firmware , When in use, you only need to send to the module AT Command to connect to the network 、 Data transmission and other operations .
About what is AT Instructions , Simply speaking, it is a kind of equipment room Communication message specification , More specific definitions and application scenarios can be understood by readers themselves .
1.2 Module USES
ESP-01 The module wiring mode is as follows :
- GND -> GND
- VCC -> 3.3v( Separate modules ) 5.5v( With adapter plate )
- Tx -> Rx
- Rx -> TX
Use of AT The instructions are as follows :
- AT+RST: Reset module
- AT+CWMODE=1: Switch mode
- AT+CWQAP: To break off WiFi Connect
- AT+CWJAP=“WiFi name ”,“ password ”: Connect WiFi
- AT+CIPSTART=“TCP”,“IP”, port : Connect to server
- AT+CIPMODE=1: Switch to TCP Passthrough mode
- AT+CIPSEND: Start sending data
1.3 Code
Arduino Connect WiFi Code for :
#include
boolean at\_exec(char *data, char *keyword, unsigned long time\_out)
{
Serial.println(data);
Serial.flush();
delay(100); // Waiting response
unsigned long start = millis();
while (Serial.available() < strlen(keyword))
{
if (millis() - start > time_out)
return false;
}
if (Serial.find(keyword))
return true;
else
return false;
while (Serial.available())
Serial.read(); // Clear the serial buffer
}
void setup()
{
Serial.begin(115200);
while (!at_exec("AT+RST", "OK", 1000));
while (!at_exec("AT+CWMODE=1", "OK", 1000));
while (!at_exec("AT+CWQAP", "OK", 1000));
while (!at_exec("AT+CWJAP=\"HelloGithub\",\"PassWord\"", "WIFI CONNECTED", 2000));
while (!at_exec("AT+CIPSTART=\"TCP\",\"183.230.40.40\",1811", "CONNECT", 1000));
while (!at_exec("AT+CIPMODE=1", "OK", 500));
while (!at_exec("AT+CIPSEND", "OK", 500));
//Serial.println("* product ID# Authentication information # Script name *"); // How to obtain this information is discussed below
}
Be careful :
- Disconnect before downloading Arduino and ESP-01 The connection of , Otherwise, the download may fail
- perform
AT+CIPSENDafter , The module will no longer respond AT Instructions , If you need to modify the configuration, you must power off and restart the module - Remember to change
AT+CWJAPParameters of , Corresponding WiFi User name and password
After burning , The connection module restarts Arduino. In the router management interface “ Connected device ” page , See our WiFi equipment , That means success !

Two 、 Internet of things platform
Here we are using OneNet Internet of things platform , It is the Internet of things created by China Mobile PaaS Open platform , Through this platform, you can easily ( free ) Implement the device ” On the cloud “.

below , It will cover the process from registration to cloud on device , All cloud configuration steps required .
2.1 register
open OneNet Official website , Click on the “ register ” Registered account .

2.2 New product
After completing the login account registration , Click on the “ Console ” Go to the control page .
Click after entering “ All products and services ”->“ Multi protocol access ”:

stay “ Multi protocol access interface ” choice TCP transparent transmission -> Add product :

Fill in the relevant information in the pop-up sidebar ,“ Product industry ” and “ Category ” Just fill it in , Finally, click “ determine ” Complete new product .

2.3 Add equipment
Find the product I just created. Mine is “HelloGitHub”, Then click... In the left column “ The equipment list ”, Click on the new page “ Add equipment ”, After filling in the relevant information, click “ add to ”, Complete the operation of adding equipment .

2.4 Write data parsing script
Next , We configure the cloud data parsing script , Don't write it yourself and download it directly Official script You can use it if you change it locally .

In the extracted and downloaded folder , find sample.lua In the file device_timer_init function ( The first 303 That's ok ), Change to the following :
function device\_timer\_init(dev)
-- Send the light switch command regularly --
dev:timeout(0)
dev:add(10,"open","open")
dev:add(12,"close","close")
end
find device_data_analyze function ( At the end of the file ), Change to the following :
function device\_data\_analyze(dev)
local t={}
local a=0
local s = dev:size()
-- We define One time transmission ten byte , Respectively temperature humidity --
add_val(t,"Temperature",a,dev:bytes(1,5))
add_val(t,"Humidity",a,dev:bytes(6,5))
dev:response()
dev:send("received")
return s,to_json(t)
end
If you are interested in using scripts , You can view code comments and access documents on the official website , There will be no more explanation here .
2.5 Upload script
After saving the file , Go back to the just opened “ The equipment list ” Click on “ Upload parsing script ”.


thus , Cloud configuration is complete .
2.6 Connect to the Internet of things platform
modify 1.3 Code for , take “ How to obtain this information is discussed below ” Change this line of code to :
Serial.println("* product ID#ILoveHelloGitHub#HG*");
After configuring the cloud , To obtain the product ID、 Authentication information 、 Script name Equal parameter , Replace to the corresponding position .(* product ID# Authentication information # Script name *)
Last , Re - burn the code and restart ESP-01 modular . Wait a moment , Refresh in the cloud “ The equipment list ” page , See our equipment , Prove that the device is successfully connected to the Internet of things platform .

3、 ... and 、Arduino On the cloud
Go through the front matting , We “ On the cloud ” The most exciting part of our journey is coming . Upload the temperature and humidity data of the environment where the device is located to the cloud !
3.1 Code
Since it is uploading temperature and humidity data , You need us Last issue Speak of the DHT11 modular ( Temperature and humidity sensor ), Then combine the code of connecting the network in this issue , It can be finished in minutes .
But to make the project more interesting , I added an additional parsing IOT platform to send commands , Remote control switch LED Function of .
The code snippet is as follows :
void setup()
{
// Change to your own cloud parameters
Serial.println("* product ID#ILoveHelloGitHub#HG*");
}
// According to the received from the serial port character string Execute the corresponding instruction
bool command\_parse(String command){
...
if (command == "open")
{
digitalWrite(LED_BUILTIN, HIGH);
} else if (command == "close")
{
digitalWrite(LED_BUILTIN, LOW);
}
}
Complete code :https://github.com/HelloGitHub-Team/Article/blob/master/contents/Other/Arduino/3/code.cpp
Last , Modify... In the complete code WiFi Name and password , as well as product ID after , Re - burn the code .
3.2 Upload temperature and humidity data
Just a moment later , View the Internet of things platform “ Equipment information ”, If you see Arduino Uploaded indoor temperature and humidity information , It proves that our code runs successfully .

3.3 Remote control
The following is a demonstration of how to use the Internet of things platform , Switch of remote control lamp .
Open the Internet of things platform , Click on “ Device interface ” Of “ Give orders ”, Select... On the pop-up form “ character string ” Options , Input “open” or “close” Instructions .

Come here , The remote control is completed Arduino built-in LED Light on / Closing effect !

success ! And the flower
Four 、 summary
This article , combination Arduino、 sensor 、WiFi as well as OneNet Internet of things platform , By doing and talking , It describes the whole process of a device from networking to cloud . Although it is an entry-level tutorial , But this knowledge can already help you accomplish , Such as smart switches 、 Practical and interesting projects such as automatic feeders .
Do not underestimate every small progress , Every step is worth a thousand miles .
If the wave of mobile Internet has passed , Will there be any in the next wave The Internet of things And the shadow of ? Anyway, I don't think it's too much for me , What do you think of that ? Welcome to comment on it .
thus , Whole Arduino Series of tutorials , It's over here . The end ! Sprinkle the flowers again
hope ,HelloGitHub Of Arduino Series of tutorials , It can arouse your interest in the Internet of things , After all, interest is the best teacher .
These are the contents of this issue , Here is HelloGitHub Share GitHub The interesting 、 Entry-level open source projects .
Thank you for reading , If you think the content is good , Do remember to like 、 Leaving a message. 、 Share , See you next time !
边栏推荐
- 对“宁王”边卖边买,高瓴资本“高抛低吸”已套现数十亿
- unity实战之lol技能释放范围
- lol手游之任务进度条精准计算
- JVM tuning
- 【Go语言刷题篇】Go从0到入门4:切片的高级用法、初级复习与Map入门学习
- With its own cells as raw materials, the first 3D printing ear transplantation was successful! More complex organs can be printed in the future
- 【CANN文档速递04期】揭秘昇腾CANN算子开发
- Coinbase will launch the first encryption derivative for individual investors
- Predicate
- Win7 10 tips for installing Office2010 five solutions for installing MSXML components
猜你喜欢

Bytebase 加入阿裏雲 PolarDB 開源數據庫社區

Making startup U disk -- Chinese cabbage U disk startup disk making tool V5.1

Vs2017 setting function Chinese Notes

What is CNN (convolutional neural network)

Behind Tiantian Jianbao storm: tens of millions in arrears, APP shutdown, and the founder's premeditated plan to run away?

Write a positive integer to the node and return a floating-point number multiplied by 0.85 when reading the node

Q1: error in JMeter filename must not be null or empty

Two solutions to the problem of 0xv0000225 unable to start the computer

Drawing DEM with GEE gracefully

物联网?快来看 Arduino 上云啦
随机推荐
Power supply noise analysis
Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?
网络安全审查办公室对知网启动网络安全审查,称其“掌握大量重要数据及敏感信息”
Docker installing Oracle
SaltStack State状态文件配置实例
Install the custom module into the system and use find in the independent project_ Package found
用自身细胞作为原料,首例3D打印耳朵移植成功!未来可打印更复杂器官
Predicate
LCD12864 (ST7565P) Chinese character display (STM32F103)
Openstack actual installation and deployment tutorial, openstack installation tutorial
SQL export CSV data, unlimited number of entries
[suggested collection] time series prediction application and paper summary
Application practice | massive data, second level analysis! Flink+doris build a real-time data warehouse scheme
unity实战之lol技能释放范围
2022年最新四川建筑八大员(电气施工员)模拟题库及答案
UART communication (STM32F103 library function)
用手机摄像头就能捕捉指纹?!准确度堪比签字画押,专家:你们在加剧歧视
Obstacle avoidance sensor module (stm32f103c8t6)
别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!
Cooking business experience of young people: bloggers are busy selling classes and bringing goods, and the organization earns millions a month