当前位置:网站首页>Wechat applet + Alibaba IOT platform + Hezhou air724ug build a serverless IOT system (III) -- wechat applet is directly connected to Alibaba IOT platform aliiot
Wechat applet + Alibaba IOT platform + Hezhou air724ug build a serverless IOT system (III) -- wechat applet is directly connected to Alibaba IOT platform aliiot
2022-07-03 03:43:00 【Kong Fangfang】
Some time ago, we concentrated on designing the overall scheme of the system , Internet of things platform construction 、 Applet writing , Hardware circuit design 、SOC Program development of single chip microcomputer , The hole dug by myself is too big , It's really hard to fill in ! The whole annual holiday is used to fill the hole , There is no time to write a blog , Today, I'm busy taking time to concentrate on the development process , Form words , Please forgive me for some incompleteness and thoughtfulness , Please leave me a message if you have any questions , I'll revise it now .
Applet as the front end of the project , As a facade of user interaction , It is the way for users to collect information and control , The front end of this system has more than display and control functions , The focus is on direct connection to Alibaba's Internet of things platform , Avoid the big trouble of the server part , It is very convenient for the project development and development process .
Wechat applet is directly connected to Alibaba IOT platform through Cloud API Realize direct connection control ,
We can use Alibaba cloud IOT platform Official documents In the cloud API A list of . My project mainly applies equipment status query and RRPC Real time synchronous control, etc .
Wechat open documents Wechat Developer Platform documentation https://developers.weixin.qq.com/miniprogram/dev/framework/
The above is the wechat applet development document , The specific basic operations such as applet registration and configuration are not introduced in this article , Direct delivery of dry goods , Directly introduce the link to Alibaba IOT platform AliIoT The process .
First step , Add Alibaba IOT platform information to the applet
The previous article introduced the construction process of Alibaba IOT platform , Wechat applet + Alibaba IOT platform + Hezhou Air724UG Build a server free IOT system ( Two )--- Alibaba IOT platform is built _unforgettable2010 The column -CSDN Blog The platform serves as a middle platform for Internet of things applications , It undertakes the functions of millions of equipment links and load balancing , It solves the problem of multi connection of Internet of things device link 、 Less data 、 Long links and other issues .https://blog.csdn.net/unforgettable2010/article/details/122889742

During the test Devicename It's dead , The actual applet products use QR code , Users scan QR codes to add devices .
Second parts 、 The applet is directly connected to Alibaba IOT platform ALiIoT
The direct connection mode adopts HTTP Way to link Alibaba IOT platform ALiIoT The cloud API.
Applet driver writing , Direct connection IoT platform API Public parameters of are difficult , below SDK Realize public parameter generation and link function ,
The following link introduces the official document of public parameters

The third step 、 Link the platform to query the equipment status and control functions
var data1 = {
adc: 111,
iostate: "1201",
power: "abcd"
};
// Read device attribute status
// const config1 = {
// Action: "QueryDevicePropertyStatus",
// ProductKey: api.productKey,
// DeviceName: api.deviceName
// };
// RRPC Send a request message to the specified device , And return the response synchronously
const config1 = {
Action: "RRpc",
ProductKey: api.productKey,
DeviceName: api.deviceName,
timeout: 6666,
requestBase64Byte: base64.encode(JSON.stringify(data1)),
};
aliSdk.request(config1, {
method: "POST"
},
(res) => {
console.log("success")
console.log(res) // View back response data
if (res.data.Code) {
console.log(res.data.ErrorMessage)
wx.showToast({
title: ' Device connection failed ',
icon: 'none',
duration: 1000,
complete: () => {}
})
// that.setPropertyData(null)
console.log("1111nihao ")
} else {
// console.log("2222nihao ",res);
console.log("2222nihao ",JSON.parse(base64.decode(res.data.PayloadBase64Byte)));
// that.setPropertyData(res.data.Data.List.PropertyStatusInfo)
}
},
(res) => {
console.log("fail")
wx.showToast({
title: ' Network connection failed ',
icon: 'none',
duration: 1000,
complete: () => {}
})
// this.setPropertyData(null)
},
(res) => {
console.log("complete")
})This code realizes the equipment control function and the equipment status query function , After the applet sends data , Through the monitoring and operation of Alibaba IOT platform -> Device simulation Function to receive data .

Applet sends data

Device simulator receives data

Before writing the applet, you can use the monitoring operation and maintenance on Alibaba IOT platform -> Online debugging function , Simulate applet sending data .

Step four 、 Scan add device
The applet adds devices by scanning the code , Add multiple devices under the user name , Users can manage multiple devices , Data such as user information and user added device information are stored in Tencent cloud development -> In cloud database , The next chapter introduces Tencent cloud development . After adding the device, the applet interface is as follows .

The device control page is as follows :

I'll put the QR code of the small program below , Welcome friends to visit and guide , The small program page is rough , The specific page writing process is not detailed , I will open source the small program code after it is written and sorted out , Let all friends help improve this system .

The following is the system delay video , Video for the first time , It's rough to walk , I hope you will forgive me !
边栏推荐
- Summary of determinant knowledge points in Chapter 1 of Linear Algebra (Jeff's self perception)
- ffmpeg之 一张/多张图片合成视频
- Download and install node, NPM and yarn
- [leetcode question brushing day 34] 540 Unique element in array, 384 Disrupt array, 202 Happy number, 149 Maximum number of points on a line
- IPv6过渡技术-6to4手工隧道配置实验--尚文网络奎哥
- Elsevier latex submitted the article pdftex def Error: File `thumbnails/cas-email. jpeg‘ not found: using draf
- 可分离债券与可转债
- C语言HashTable/HashSet库汇总
- [mathematical logic] normal form (conjunctive normal form | disjunctive normal form | major item | minor item | maximal item | minor item | principal conjunctive normal form | principal disjunctive no
- MongoDB主配置文件
猜你喜欢
![C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions](/img/4a/1df03d9f3315debb4c335260ed39f2.jpg)
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions

Download and install node, NPM and yarn

Recursion: one dimensional linked lists and arrays

node,npm以及yarn下载安装

渤、黄海的潮汐特征

ffmpeg录制屏幕和截屏

Use three JS make a simple 3D scene

Table structure of Navicat export database

Some preliminary preparations for QQ applet development: make an appointment for a development account, download and install developer tools, and create QQ applet

leetcode:动态规划模板
随机推荐
释放数据力量的Ceph-尚文网络xUP楠哥
navicat 导出数据库的表结构
Error c2694 "void logger:: log (nvinfer1:: ilogger:: severity, const char *)": rewrite the restrictive exception specification of virtual functions than base class virtual member functions
编译文件时报错:错误: 编码GBK的不可映射字符
[AI practice] Application xgboost Xgbregressor builds air quality prediction model (I)
Ffmpeg one / more pictures synthetic video
Without sxid, suid & sgid will be in danger- Shangwen network xUP Nange
Nce detail of softmax approximation
js中#号的作用
Web session management security issues
[leetcode question brushing day 34] 540 Unique element in array, 384 Disrupt array, 202 Happy number, 149 Maximum number of points on a line
Don't use the new Dede collection without the updated Dede plug-in
2020-01-01t00:00:00.000000z date format conversion
900w+ data, from 17s to 300ms, how to operate
For instruction, uploading pictures and display effect optimization of simple wechat applet development
Download and install captura and configure ffmpeg in captura
8.8.2-PointersOnC-20220214
node,npm以及yarn下载安装
PHP generates PDF tcpdf
docker安装及启动mysql服务