ESP Arduino Tutorial

Install Motion Sensor in a esp relay

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:

Install Tasmota firmware on ESP

  1. Download the tasmota firmware here and extract the file.
  2. Plug wemos on your computer’s usb and get the COM port number
  3. Run the extracted file named as flash_tasmota_8.1.0.bat to flash tasmota
  4. 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
motion sensor configure tasmota esp-arduino
  • 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.
esp-arduino motion sensor configure tasmota relay
Wemos Relay module pins
ESP Arduino project Motion sensor wemos relay
PIR attached

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.

ESP Arduino PIR Wemos Tasmota

Leave a Comment

Your email address will not be published. Required fields are marked *