In this tutorial we will show how to build ESP8266 WiFi PIR sensor with ESP8266 and PIR.

 

Materials

-ESP8266 module

ESP8266 ESP-01 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-01 Serial WIFI Wireless Transceiver Module
$2.11
$17.00
ESP8266 ESP-03 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-03 Serial WIFI Wireless Transceiver Module
$2.07
$2.15
ESP8266 ESP-12 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-12 Serial WIFI Wireless Transceiver Module
$2.06
$1.75
ESP8266 ESP-05 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-05 Serial WIFI Wireless Transceiver Module
$1.88
ESP8266 ESP-07 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-07 Serial WIFI Wireless Transceiver Module
$2.18
$1.88
ESP8266 Lua Nodemcu WIFI Network Development BoardESP8266 Lua Nodemcu WIFI Network Development Board
$7.43
$2.65

 

-PIR sensor module HC-SR501

Pyroelectric Infrared Motion Sensor Detector Module HC-SR501Pyroelectric Infrared Motion Sensor Detector Module HC-SR501
$0.99
$1.05

 

See buying guide at the end of tutorial.

PIR sensor display in EasyIoT server.

ESP8266 PIR HC-SR501 sensor

EasyIoT server

In EasyIoT server web interface add Virtual node. Type for virtual node is Motion (DI). See How to add node to EasyIoT server tutorial for detail. Remember node address because it will be needed later. Add node to one of Groups to display.

Virtual node address.

Virtual node address

 

Program

Program can be found on GitHub. Correct following lines in program (AP username password, server IP address, node address, EasyIoT server username and password):

//AP definitions

#define AP_SSID "your AP SSID"

#define AP_PASSWORD "your AP password"

// EasyIoT server definitions

#define EIOT_USERNAME    "admin"

#define EIOT_PASSWORD    "test"

#define EIOT_IP_ADDRESS  "192.168.1.5"

#define EIOT_PORT        80

#define EIOT_NODE        "N8S0"

 

Compile and load program with ESP8266 Arduino IDE. Read tutorial for direct ESP8266 programming in Arduino IDE.

Connection

Power supply for ESP8266 is max 3.6V and PIR sensor is powered by 5V. If you check datasheet for PIR sensor you will see that internally is powered by 3.3V (see 3.3 regulator).

PIR schematic

Internal logic is 3.3V so output. It can be directly connected to ESP8266 GPIO pin.

PIR

PIR  
VCC VCC 5V
GND GND 
OUT GPIO2 on ESP8266

PIR HC-SR501 pinout

PIR HC-SR501 pinout

 ESP8266 and PIR HC-SR501 connection.

ESP8266 PIR HC-SR501 connection 

Check also EasyIoT Cloud ESP8266 PIR sensor tutorial.

See more tutorials at ​http://iot-playground.com/build​

Buying guide

To support this site and EasyIoT framework development please buy in our store.

Pyroelectric Infrared Motion Sensor Detector Module HC-SR501

New Adjustable Infrared IR PIR Motion Sensor Detector Module Security Motion HC-SR501

5PCS Pyroelectric Infrared Motion Sensor Detector Module HC-SR501

Infrared IR PIR Motion Sensor Detector Module Security Motion HC-SR501

5pcs 3.3V regulator module 800mA

Basic regulator module based on AMS1117.

ESP8266 ESP-01 Serial WIFI Wireless Transceiver Module

ESP8266 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-03 Serial WIFI Wireless Transceiver Module

ESP8266 serial WIFI model ESP-03

ESP8266 ESP-12 Serial WIFI Wireless Transceiver Module

ESP8266 serial Port WIFI wireless module ESP-12

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

ESP8266 Lua Nodemcu WIFI Network Development Board

ESP8266 Lua Nodemcu WIFI Network Development Board


Comments   

+1 #7 DarioCdj 2015-05-13 12:39
Hi guys, It doesn't need to connect PIR to 5v.
But if you connect directly to 3.3v it doesn't work well.
Take a look of http://techgurka.blogspot.it/2013/05/cheap-pyroelectric-infrared-pir-motion.html to easy modify sensor to power at 3.3v !
+1 #6 Super User 2015-05-10 22:57
Quoting Allan Madsen:
Quoting Super User:
Quoting Allan Madsen:
Hi i use Arduino 1.6.1 for ESP8266

I get this error
test1.ino:2:20: fatal error: Base64.h: No such file or directory
compilation terminated.
Fejl i kompilering.

And i cant find the file anyware??


I've updated program with link to library. Hope it helps.


Kan you give a link here, icant findt it :-)


Read comments in program.
#5 Allan Madsen 2015-05-10 14:45
Quoting Super User:
Quoting Allan Madsen:
Hi i use Arduino 1.6.1 for ESP8266

I get this error
test1.ino:2:20: fatal error: Base64.h: No such file or directory
compilation terminated.
Fejl i kompilering.

And i cant find the file anyware??


I've updated program with link to library. Hope it helps.


Kan you give a link here, icant findt it :-)
#4 Super User 2015-05-10 14:12
Quoting Allan Madsen:
Hi i use Arduino 1.6.1 for ESP8266

I get this error
test1.ino:2:20: fatal error: Base64.h: No such file or directory
compilation terminated.
Fejl i kompilering.

And i cant find the file anyware??


I've updated program with link to library. Hope it helps.
#3 Allan Madsen 2015-05-10 13:47
Hi i use Arduino 1.6.1 for ESP8266

I get this error
test1.ino:2:20: fatal error: Base64.h: No such file or directory
compilation terminated.
Fejl i kompilering.

And i cant find the file anyware??
#2 Super User 2015-04-30 00:00
Quoting DarioCdj:
Thank you for example. Could it work also with a reed to make a door/window sensor ? It needs to change code?
thanks
Dario


Program is almost the same - just add pull up command to GPIO pin.
#1 DarioCdj 2015-04-29 22:25
Thank you for example. Could it work also with a reed to make a door/window sensor ? It needs to change code?
thanks
Dario

You have no rights to post comments

Forum latest

  • No posts to display.