当前位置:网站首页>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 !
边栏推荐
- 2020-01-01t00:00:00.000000z date format conversion
- Ffmpeg one / more pictures synthetic video
- MongoDB简介
- Positioning (relative positioning, absolute positioning, fixed positioning, Z-index) 2022-2-11
- Web会话管理安全问题
- Mongodb replication set [master-slave replication]
- 用Three.js做一个简单的3D场景
- Commands related to the startup of redis under Linux server (installation and configuration)
- 没有sXid,suid&sgid将进入险境!-尚文网络xUP楠哥
- [leetcode question brushing day 34] 540 Unique element in array, 384 Disrupt array, 202 Happy number, 149 Maximum number of points on a line
猜你喜欢
Table structure of Navicat export database
Summary of matrix knowledge points in Chapter 2 of Linear Algebra (Jeff's self perception)
FileZilla Client下载安装
PHP generates PDF tcpdf
机械臂速成小指南(八):运动学建模(标准DH法)
Mongodb installation & Deployment
Ansible简介【暂未完成(半成品)】
Pytorch轻量级可视化工具wandb(local)
Elsevier latex 提交文章 pdftex.def Error: File `thumbnails/cas-email.jpeg‘ not found: using draf
Makefile demo
随机推荐
[national programming] [software programming - Lecture Video] [zero foundation introduction to practical application]
Ffmpeg one / more pictures synthetic video
Pytoch lightweight visualization tool wandb (local)
MongoDB基本操作【增、删、改、查】
Tidal characteristics of the Bohai Sea and the Yellow Sea
Limit of one question per day
Ansible简介【暂未完成(半成品)】
[AI practice] Application xgboost Xgbregressor builds air quality prediction model (I)
C语言HashTable/HashSet库汇总
Ffmpeg download and installation tutorial and introduction
[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
递归:深度优先搜索
【学习笔记】seckill-秒杀项目--(11)项目总结
Don't use the new Dede collection without the updated Dede plug-in
[embedded module] OLED display module
Recursion: depth first search
golang xxx. Go code template
Without sxid, suid & sgid will be in danger- Shangwen network xUP Nange
Basic operations of mongodb [add, delete, modify, query]
403 error displayed when vs cloning