当前位置:网站首页>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 !
边栏推荐
- Leetcode: dynamic planning template
- SAP UI5 应用开发教程之一百零五 - SAP UI5 Master-Detail 布局模式的联动效果实现明细介绍
- Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)
- Mysql Mac版下载安装教程
- VS克隆时显示403错误
- C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions
- 渤、黄海的潮汐特征
- 动态规划:最长回文子串和子序列
- Error in compiled file: error: unmapped character encoding GBK
- Role of JS No
猜你喜欢

FileZilla Client下載安裝

Limit of one question per day

MongoDB复制集【主从复制】

释放数据力量的Ceph-尚文网络xUP楠哥

Don't use the new Dede collection without the updated Dede plug-in

Recursion: quick sort, merge sort and heap sort

Recursion: depth first search

Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)

Role of JS No

用Three.js做一个简单的3D场景
随机推荐
如何迈向IPv6之IPv6过渡技术-尚文网络奎哥
FileZilla Client下載安裝
MongoDB简介
Mongodb installation & Deployment
8.8.2-PointersOnC-20220214
阿洛对自己的思考
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions
Elsevier latex 提交文章 pdftex.def Error: File `thumbnails/cas-email.jpeg‘ not found: using draf
【学习笔记】seckill-秒杀项目--(11)项目总结
navicat 导出数据库的表结构
渤、黄海的潮汐特征
二进制流转换成字节数组
Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)
C# WebRequest POST模式 ,基于“Basic Auth”口令认证模式,使用multipart/form-data方式上传文件及提交其他数据
Filter
Recursion: quick sort, merge sort and heap sort
可分离债券与可转债
Change and access of median value of listening object
Recursion: depth first search
Recursive use and multi-dimensional array object to one-dimensional array object