You would like to turn on a switch if a movement is detected even it’s dark. You need a motion detector call PIR (Passive infrared sensor). It detect general movement but will not give you information on who or what moved.
You will need:
- Wemos ESP
- Wemos Relay
- Tasmota firmware
Install Tasmota firmware on ESP
- Download the tasmota firmware here and extract the file.
- Plug wemos on your computer’s usb and get the COM port number
- Run the extracted file named as flash_tasmota_8.1.0.bat to flash tasmota
- Once installed, connect your ESP to your wireless network.
For detailed instruction, please visit this link: Installing Tasmota on Wemos ESP
Configure Tasmota for Relay and PIR
- Open your browser and type in the IP address of your ESP
- Click configure >> Configure Module
- On Module type, find Generic 18 at the bottom. Select it and save. It will automatically restart.
- Go back there again by clicking Configuration >> Configure Module
- On D1 GPIO5, select Relay1 (21). This is the pin for the relay.
- On D2 GPIO4, select Switch1 (9). This is the pin for the PIR.
- Click save.
That’s it, it should work. Every time a movement is detected, the relay (switch) should turn on. The manage the duration of the detection, you can manually change the PIR detection duration by turning this to the right.
Connect your light and have fun.