The article has been achieved Esp8266 Boards and MQTT achieve control server connected to the LED lamp
Part following article recording function program implements the access control of the micro channel small LED lights
When the micro-channel subscription applet server MQTT a theme, Esp8266 subscribe to the same theme: to understand a concept
Micro-channel message is sent to the applet server MQTT, Esp8266 will receive the same, meaning that transmits commands to the micro-channel applet server lamp on MQTT
MQTT server will be forwarded to the command Esp8266 lamp on (a bit long-winded, huh)
1. First configuration server nginx, code is as follows:
location = /mqtt { # 8083 is websocket our emq port number HTTP proxy_pass: // the WWW domain names .cn:. 8083; proxy_redirect OFF; proxy_set_header Host www domain .cn:. 8083 ; proxy_set_header Sec-WebSocket-Protocol mqtt; # This is your js library client relationship, this post is not required, in order to balance after a small partner, my next comment here! #more_clear_headers Sec-WebSocket-Protocol; # These are websocket must be configured proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
80 ports can be placed, modify the domain name, others do not change, then restart nginx
nginx -s reload or cd to nginx folder ./nginx -s reload
Server release 443 port (may not be needed as a precaution ...)
Here micro letter applet server here ready
2. The micro-channel download applet code, address: https://github.com/daichaodeyu/WeChat_Esp8266
After download open letter with a micro-developer tools, to modify the domain name and theme app.js
Previous article Esp8266 development board subscribed threads is / test / onoff /, app.js also set to / test / onoff /, as shown:
After saving compile small program, first click the link MQTT server, and then click on the subscription will have the appropriate tips
Esp8266 development board through the power, the connection article can be realized with reference to the LED lamp LED lamp opening and closing
Reference Bowen: a half stars heart https://blog.csdn.net/xh870189248/article/details/84070944
Video Reference Station B: https://www.bilibili.com/video/av39598869?from=search&seid=1068408118905110158