In this project, we will use NodeMCU boards to connect a light sensor(photoresistor) and a remote LED. When a local photoresistor detects light, NodeMCU will send signal to a remote NodeMCU through MQTT IOT protocol and turn a LED.
Parts and devices:
2 x NodeMCU boards
1 x LED
1 x photoresistor
2 x 1k ohm resistor
Step 1) Install NodeMCU photoresistor project as per following tutorial:
In order to adjust photoresistor sensitivity, you might need to change the value of variable "threhod" in line 26 of nodemcu-Photoresistor Arduino code file
Step 2)Install NodeMCU LED project as per following tutorial
Make sure you have set up correct wifi password and hotspot name in above two projects (line 16 and line 17 in arduino code file)
If your photoresistor detects lights, the remote LED will be turned off. If you put a hand to block light over photoresistor, the LED will turned on.
Related Articles Raspberry pi zero/w 常用套件第5课：Remote Control with VNC 树莓派3.5寸超清屏镜像安装