基于ESP8266的 4 孔插座,接入机智云实现远程控制
4孔插座开源开源内容1. 控制4路插孔,可单控和全控。2. 定时任务创建3. 控制5V2.1A手机充电孔开关4. 硬件接线开源已经参考设计5. 掉电记忆开关状态6. 远程升级硬件参考1. 本次设计采用ESP12F作为主控和WiFi网络通讯芯片。最小系统如下图所示。
2. 本次设计接线方式已经IO控制状态如下:按键 GPIO0 低电平有效 长按softap(热点配置),短按控制全开继电器1GPIO5 低电平有效 插座开关控制继电器2GPIO4 低电平有效 插座开关控制继电器3GPIO13低电平有效 插座开关控制继电器4GPIO12低电平有效 插座开关控制USB GPIO14高电平有效 USB手机充电孔开关LINK GPIO16低电平有效 插座开关状态指示灯USBLED GPIO2 低电平有效 USB开关状态指示灯3. 参考硬件如下https://club.gizwits.com/data/attachment/forum/202103/11/001227iwd6gg4d1fbbgowf.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001227uj6orr111jp3x6co.jpg.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001228mmfmaoewamlefkxf.jpg.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001228ydqyd4mmq9md21mv.jpg.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001229b0j9i0j616cedtr6.jpg.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001229r44w34wf5le448g5.jpg.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001230dcew0wwkdwyzebww.jpg.thumb.jpg4. 没有相关硬件的可以自己购买一个4路继电器的板子,一个5V2.1A电源板,一个内部空间大的插座(有条件的可以自己定制插座),一个ESP12F最小系统板来进行搭建。
云端部署1.进入机智云新版本开发者中心https://developer.gizwits.com/menu/dashboard点击左上角创建。https://club.gizwits.com/data/attachment/forum/202103/11/001230fs9276ri9pd6sgsr.png.thumb.jpg2.由于此处我没有加计量模块,此处选择无计量四路插座。https://club.gizwits.com/data/attachment/forum/202103/11/001230c03rnyz5y80r09kk.png.thumb.jpg3.选择产品开发,编辑数据点,保留以下数据点。https://club.gizwits.com/data/attachment/forum/202103/11/001231outfck9d3k0kun3f.png.thumb.jpg4.点击左侧MCU开发,选择SOC方案32M,生成32M代码。https://club.gizwits.com/data/attachment/forum/202103/11/001231z48ks90ss9kfrr59.png.thumb.jpg5. 点击下载,将生成好的代码下载到电脑备用。https://club.gizwits.com/data/attachment/forum/202103/11/001232tnz9b8i9jtijongb.png.thumb.jpg6. 回到首页,点击右上角创建,创建一个移动应用。https://club.gizwits.com/data/attachment/forum/202103/11/001232yjvdkqvhqkzklhks.png.thumb.jpg7.关联相关产品到应用。https://club.gizwits.com/data/attachment/forum/202103/11/001232r1oyak1pro3dvtxa.png.thumb.jpg7.其他个性主题设计直接点击更换即可。https://club.gizwits.com/data/attachment/forum/202103/11/001233zt8tytza8y5py7yt.png.thumb.jpg8.构建应用,生成对应的手机应用安装包https://club.gizwits.com/data/attachment/forum/202103/11/001233anm5abpnwxhmhae5.png.thumb.jpg9.建好的应用下载到手机进行安装https://club.gizwits.com/data/attachment/forum/202103/11/001234n7xd3tactap754h3.png.thumb.jpg
乐鑫ESP12程序编写1.将前面下载备用的代码进行解压。https://club.gizwits.com/data/attachment/forum/202103/11/001234gugxfsbp0qbp80fo.png.thumb.jpg2.用乐鑫IDE软件导入项目,没有软件的可以去QQ群438373554下载,将文件解压到非中文路径即可使用,不需要安装,一定要是非中文路径。https://club.gizwits.com/data/attachment/forum/202103/11/001234lx9xc5di7dqxdncx.png.thumb.jpg3.按照下图配置导入代码https://club.gizwits.com/data/attachment/forum/202103/11/001234sgonshpv1ee1p022.png.thumb.jpg4.按照如下图修改项目编译信息https://club.gizwits.com/data/attachment/forum/202103/11/001235k8qzsffvyblyv7tg.png.thumb.jpg5.定义全局开关状态变量STATE,https://club.gizwits.com/data/attachment/forum/202103/11/001235onq11xtw55555oqb.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001235jzfz9n630py5198q.png.thumb.jpg6.编写云端下发响应程序https://club.gizwits.com/data/attachment/forum/202103/11/001236u0yqdeqxqx6lbx0i.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001236wtpzpayqygvo88qj.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001236wr21tt16omdthz7m.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001236njoz2fpzspvsscto.png.thumb.jpg7.修改按键程序,此处采用1个按键。https://club.gizwits.com/data/attachment/forum/202103/11/001237pvmgtazztagemhgm.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001237izan265v57ankl5o.png.thumb.jpg8.实时引脚处理函数。https://club.gizwits.com/data/attachment/forum/202103/11/001237n7ve1pa1ppjqoi7v.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001237qroem8f02r2truar.png.thumb.jpg9.掉电记忆程序https://club.gizwits.com/data/attachment/forum/202103/11/001237ozzpkes8rvw8q0k7.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001237fa3epe8c3o83looc.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001238u8gukb9uibz8xhx8.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001238pqnqvmttgue5vq57.png.thumb.jpg10.编译烧录.https://club.gizwits.com/data/attachment/forum/202103/11/001238smz8ywuuzprsssbj.png.thumb.jpg11.远程OTA升级固件https://club.gizwits.com/data/attachment/forum/202103/11/001238wc0zt866k9g96vz2.png.thumb.jpg验证固件https://club.gizwits.com/data/attachment/forum/202103/11/001239see5ijy5zn888rzj.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001239x9fd4o8g44kt9kfd.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001239vgi7r1pd1s8wadi9.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001239afkrtgjkjrya2t4t.png.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001239ig4augzpez4oexza.png.thumb.jpg12.APP相关展示。https://club.gizwits.com/data/attachment/forum/202103/11/001240gn176w7i4pywfoy6.jpg.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001240nwvbwg3vutbpvpoh.jpg.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001240hk3jkx3yigyqqtty.jpg.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001240tzs10srl77lr0zzn.jpg.thumb.jpghttps://club.gizwits.com/data/attachment/forum/202103/11/001240fusqquc9o5xsz9sq.png.thumb.jpg教程到此结束,实际代码以附件开源为准,截图仅供参考,智能控制选机智云,方便快捷完成手中的项目。
页:
[1]