当前位置:网站首页>Smart cloud IOT platform STM32 esp8266-01s simple wireless light control
Smart cloud IOT platform STM32 esp8266-01s simple wireless light control
2022-07-25 11:19:00 【CoderEnd】
Wit cloud STM32 ESP8266-01S Simple wireless control lamp
Reprint the address of Qingye Murong blog https://blog.csdn.net/weixin_45488643/article/details/106998647
1、 Smart cloud account registration and creation of new products
1.1、 Account registration and its smart cloud usage documents
I won't elaborate on account registration ,http://docs.gizwits.com/zh-cn/overview/overview.html Smart cloud Document Center . You can find some information you need .
1.2、 Product creation

Choose the network access method :
View basic product information :
The data points :
Data points must be writable .
1.3、 Data reading and writing types
Reading and writing types : Define the scope of data points , contains 4 Types , Namely : read-only 、 Can write 、 Call the police 、 fault ,
The following is the official introduction to reading and writing types :
① read-only : Indicates that the data point is non control , Data can only be reported from the device .
② Can write : Indicates that the data point can be controlled . The device can report data points , Cloud / client ( Mobile ) For this number
Control the distribution of site data .
③ Call the police : Indicates that the data point is not controlled , Data only supports slave devices ( Device end ) Report , The data type needs to be Boolean .
④ fault : Indicates that the data point is not controlled , Data only supports slave devices ( Device end ) Report , The data type needs to be Boolean .
The cloud makes statistics on the data point reported by the device , Can be found in “ Running state ” see .
data type : Define data point data types , Contains Boolean values 、 Enumeration type 、 The number 、 And extension , The following is the official introduction to data types :
① Boolean value : Two states : 0 or 1. Such as switch state , It is recommended to use Boolean data type .
② Enumeration type : A finite set of values can be defined . When defining a function ( components and parts ) There are fixed values ,
for example :“ Set up LED Combine colors ” The enumeration definition value of this data point :“ Customize , yellow , violet , Pink ”.
③ The number : Fill in the range of values , The value can be negative / decimal , Smart cloud automatically converts numeric values to positive numbers .
④ Expand : Fill in the data length , The data content is user-defined . For complex functions that cannot be satisfied by the above function points , Smart cloud does not recommend using this type of data , Data report the data of this data point , Smart cloud cannot recognize .
1.4、MCU Development
Product Secret You can see in the basic information above .
Download code :
2、 You can use virtual devices to debug


mobile phone app Download address :
https://download.gizwits.com/zh-cn/p/98/99 The official download address of smart cloud .
Now you can use mobile phones and virtual devices for simple debugging .
3、esp-01s Burning machine smart cloud firmware
3.1、 Firmware download
Firmware download https://download.gizwits.com/zh-cn/p/92/94 Download the firmware of smart cloud directly . because GAgent The firmware will be updated from time to time , Maybe the time you see will be different , Subject to the latest release on the official website , You can also download the old firmware .

Unzipped firmware file :
You can see that there are several types of firmware , The red That's the firmware we need to burn , I burn the packaged firmware directly , I see someone on the Internet publishing firmware that is not packaged , It's a little troublesome to burn .
Burning software download address :http://wiki.ai-thinker.com/esp_download
Download and decompress to see the burning software :
After burning the firmware of Ji Zhi cloud, I still want to restore the firmware of Le Xin , Attached download address .
Lexin firmware download address :http://wiki.ai-thinker.com/esp8266/sdk
3.2、esp-01s brief introduction
A physical picture :
Pin distribution :


3.3、 burn

3.4、esp And STM32 Pin connection
Pin connection :
Other pins can be suspended .
4、 Program migration MCU
My own engineering documents :https://download.csdn.net/download/weixin_45488643/12558122
4.1、 Engineering configuration
I have downloaded the app folder of smart cloud , Decompress and you can see the following files :
Put this 2 Copy folders to your project file .
I use punctual code myself .
Add folder and file path to the project file .

choice C99 Mode Prevent compilation errors .
4.2 The code migration
Project folder directory :
Timer used 3 And serial port 3.
4.2.1、 modify USART3 file
stay usart3.c Add serial port to the file 3 Initialization and interrupt service functions , Write the interrupt received data to gizPutData() function , The code is as follows :
Add header file #include “gizwits_product.h” To USART3 In the document , If you don't add it, you will report an error .

4.2.2、 modify timer.c file
At the timer 3 Add... To the interrupt service function gizTimerMs() function , And add gizwits_product.h The header file , The code is as follows 

Be careful : gizwits_product.h There is no reference to... In the file gizTimerMs() Function declaration , You need to add , Otherwise, an alarm will appear during compilation .
4.2.3、 modify gizwits_product.c file

After adding the serial port sending function , go back to gizwitsEventProcess() Add our user event logic to the user event handling function , Here we are controlling LED1 On and off , stay EVENT_LEDonoff Add its... According to the returned switching value in the event LED1 Switch control of , The code is as follows : You need to add your own definition in advance LED Header files and usart3.h The header file , Otherwise, it will be wrong .
stay mcuRestart() Add soft reset function to function , The code is as follows :
modify **userHandle()** function :
Add data reporting .
In the main function , First press the key 、 LED、 Serial port and Gizwits Timer required by serial port protocol 、 WIF A serial port 、 Data buffer and a series of initialization , The main loop scans the function by pressing the key KEY_Scan Always scan the current key status ,KEY1 Press to make WIFI The device has reached the AirLink Distribution network mode , KEY_UP Press to let WIFI The device enters reset mode ( Clear pairing information 、 disconnect ), and UserHandl Function reads the current LED1 state , Assign the read state value back to the device data structure variable , And then through gizwitsHandle Function to report to the server .
5、 Burning engineering distribution network
Download the project file to the development board .
5.1、 A physical picture

5.2、 Distribution network
Distribution network :


First press... On the development board KEY1 The key in , Click I have completed the above operation .
5.3 、 Physical effect display
Turn on the lights. :

Friends who can see this place are also more patient , The project documents were sent free .
Free download address of engineering documents :https://wwa.lanzous.com/iVf8re42hvi
This is the end of the whole project , I hope you can show mercy , Give me one Fabulous .
main.c
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "usart.h"
#include "timer.h"
#include "usart3.h"
#include "gizwits_product.h"
// Protocol initialization
void Gizwits_Init(void)
{
TIM3_Int_Init(9,7199);//1MS System timing
usart3_init(9600);//WIFI initialization
userInit();// Initialization of device state structure
gizwitsInit();// Buffer initialization
}
// The main function
int main(void)
{
int key;
delay_init(); // Delay function initialization
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); // Set up NVIC Interrupt grouping 2:2 Bit preemption priority ,2 Bit response priority
uart_init(115200); // The serial port is initialized to 115200
LED_Init(); //LED Port initialization
KEY_Init(); // Key initialization
Gizwits_Init(); // Protocol initialization
printf("-------- Wit cloud - Protocol transplant LED Test experiment ----------\r\n");
printf("KEY1:AirLink Connection mode \t KEY_UP: Reset \r\n\r\n");
while(1)
{
userHandle();// User collection
gizwitsHandle((dataPoint_t *)¤tDataPoint);// Agreement processing
key = KEY_Scan(0);
if(key==KEY1_PRES)//KEY1 Key
{
printf("WIFI Get into AirLink Connection mode \r\n");
gizwitsSetMode(WIFI_AIRLINK_MODE);//Air-link Mode access
}
if(key==WKUP_PRES)//KEY_UP Key
{
printf("WIFI Reset , Please reconfigure the connection \r\n");
gizwitsSetMode(WIFI_RESET_MODE);//WIFI Reset
}
delay_ms(200);
LED0 = ~LED0;
}
}
Reference material
- Reprint the address of Qingye Murong blog https://blog.csdn.net/weixin_45488643/article/details/106998647
- Smart cloud official website https://www.gizwits.com/

边栏推荐
- Reinforcement Learning 强化学习(三)
- Reinforcement learning (III)
- Learning Weekly - total issue 63 - an open source local code snippet management tool
- HCIA experiment (09)
- Shell 脚本参数传递时有 \r 换行符问题
- 一文读懂小程序的生命周期和路由跳转
- Learn NLP with Transformer (Chapter 4)
- BGP federal experiment
- Leetcode 560 prefix and + hash table
- Implementation of recommendation system collaborative filtering in spark
猜你喜欢

Code representation learning: introduction to codebert and other related models

NowCoderTOP12-16——持续更新ing

STM32CubeMX学习记录--安装配置与使用

只知道预制体是用来生成物体的?看我如何使用Unity生成UI预制体

Learn NLP with Transformer (Chapter 5)

I, AI doctoral student, online crowdfunding research topic
信息熵的定义

Learn NLP with Transformer (Chapter 1)

Some usages of beautifulsoup

SQL语言(三)
随机推荐
How can you use unity without several plug-ins? Unity various plug-ins and tutorial recommendations
The University of Gottingen proposed clipseg: a model that can perform three segmentation tasks simultaneously using text and image prompts
Signal integrity (SI) power integrity (PI) learning notes (XXXIII) 102 general design rules to minimize signal integrity problems
txt转csv文件,隔行出现空行
只知道预制体是用来生成物体的?看我如何使用Unity生成UI预制体
复习背诵整理版
【Servlet】请求的解析
一篇看懂:IDEA 使用scala 编写wordcount程序 并生成jar包 实测
JS convert pseudo array to array
[flask advanced] combined with the source code, explain the operation mechanism of flask (in and out of the stack)
MLX90640 红外热成像仪测温模块开发笔记(五)
HCIA experiment (06)
MySQL master-slave replication and read-write separation
Learn NLP with Transformer (Chapter 6)
NB-IOT控制液晶屏(日期的设置与读取)
NowCoderTOP12-16——持续更新ing
API supplement of JDBC
Learn NLP with Transformer (Chapter 3)
BGP federal experiment
HCIA experiment (10) nat