个人创作项目,借鉴了网上一些项目代码
项目微信小程序gitee地址:https://gitee.com/xinfeiy/weixinesp.git
MQTT服务器使用的是emqx;
微信小程序MQTT库使用的是MQTT.js;
ESP8266是使用arduino编写;
1、此项目使用的是自建服务器关于如何创建服务器网上有很多教程就略过
2、EMQX安装看这个博客:https://blog.csdn.net/sinat_29891353/article/details/101470072
3、nginx web搭建:https://www.cnblogs.com/zhoulifeng/p/10236116.html
4、nginx反向代理mqtt 开启https/wss:https://blog.csdn.net/weixin_42306858/article/details/95307967
5、arduino配置教程网上一大堆略过
在配置时:app.js中需要修改
globalData: {
userInfo: null, //用户头像等信息
url:'https://xx.xx.xx/openid.php', //Openid获取网址
devicesupervise_url:'https://xx.xx.xx/weixin_devicesupervise.php',//绑定设备网址
equipment_url:'https://xx.xx.xx/weixin_pages.php', //获取绑定设备网址
getUserInfo_url:'https://xx.xx.xx/weixin_register.php', //登录相关网址
mqtt_host:'wxs://xx.xx.xx/mqtt', //mqtt网址
//json 开语句 全部为:{"applianceId":设备id,,"control": "on","delayed": 0}
open_mes:',"control": "on","delayed": 0}',
shut_mes:',"control": "off","delayed": 0}',
}
openid.php中
$appid = "xx";
$secret = "xx";
arduino程序esp8266.ino
char ssid[] = "xx"; // wifi名
char pass[] = "xx";//wifi密码
const char broker[] = "xx.xx.xx"; //MQTT服务器地址
//const char broker[] = "xxx.xxx.xxx.xxx";
uint16_t port = 1883; //端口
//String topic = "yf596O2LT11"; //订阅主题
//String p_topic = "yf596O2LT10"; //发送主题
String device_ID = "2147483644"; //设备id需和小程序控制消息中的id对应
String applianceId,control,topic,p_topic;
String url = "http://xx.xx.xx/register.php?device_ID=";
微信小程序目前图片,欢迎有意向的童鞋一起完善
首页还没开始做
这是控制界面,上部分准备做温湿度等状态
这是设备添加界面,准备提供语音控制关联接口