In this tutorial we will show how to build WiFi PIR motion sensor connected to EasyIoT Cloud. We will use ESP8266, PIR module and Arduino IDE.

Contents

1. Introduction

2. Materials

3. EasyIoT Cloud configuration 

4. Program

5. Hardware

6. Buying guide

 

Introduction

 

ESP8266 PIR motion sensor

 

Materials

-ESP8266 WiFi module

ESP8266 ESP-01 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-01 Serial WIFI Wireless Transceiver Module
$2.45
$8.10
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.09
$1.88
ESP8266 ESP-05 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-05 Serial WIFI Wireless Transceiver Module
$1.88
$3.89
ESP8266 ESP-07 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-07 Serial WIFI Wireless Transceiver Module
$2.18
$1.87
ESP8266 Lua Nodemcu WIFI Network Development BoardESP8266 Lua Nodemcu WIFI Network Development Board
$7.43
$3.20

 

-PIR sensor

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

 

-3.3V power supply (battery or regulator)

5pcs 3.3V regulator module 800mA5pcs 3.3V regulator module 800mA
$1.13
$1.59
2xAA 3V Battery Holder Box Case Wire2xAA 3V Battery Holder Box Case Wire
$0.99
$0.99

 

See buying guide at the end of tutorial for details.

EasyIoT Cloud configuration 

Register to EasyIoT Cloud service. If you do not receive registration email check spam folder. If it's not there contact us and we will activate your account.

Then go to Configure->Modules->Add Module. Set Digital Input (DI) module type and name it PIR sensor.

 

Next click on Sensor.Parameter1. Set Description to PIR and check UI notifications to enable real time notification in WEB interface.

 

Then press save button. After Save you will see InstanceId/ParameterId - you will need it later in program.

Go back to module configuration and add two more parameters (Add parameter button).  

Two parameters are to set text in module. Name first parameter Settings.StatusText1 and second Settings.StatusText2. Set value for first "Motion" and for second "Ok".

Next we will set picture for module. We add two more parameters and name it Settings.Icon1 and Settings.Icon2. For first parameter set value to "siren_2.png" and second parameter value "siren_1.png".

After you added all parameters module configuration should look like this:

 

Program

Program is written in Arduino ESP8266 IDE. See Arduino ESP8266 IDE tutorial how to connect ESP8266 module to computer to upload program. Program is available at our GitHub. You will also need EIoTCloudRestApi library. In library set access point username and password. 

In program change EIOT_CLOUD_INSTANCE_PARAM_ID

// EasyIoT Cloud definitions - change EIOT_CLOUD_INSTANCE_PARAM_ID

#define EIOT_CLOUD_INSTANCE_PARAM_ID    "xxxx"

InstanceId/ParameterId in parameter configuration.

 

If you are change GPIO pin on ESP8266 then aslo change GPIO pin in program.

 

Hardware

In our case we use ESP8266 01, but you can use any other ESP8266 with FDTI programmer. For power supply you can use 2 AA batteries or 3.3V regulator AMS1117 (see buying guide).

PIR sensor is power by 5V, but if we look at schematic we will see that is's 3.3V internally. Because ESP8266 is 3.3V, we can bypass PIR internal regulator. 

PIR sensor module

Connection after regulator is available at JP1 pin 3. In our case we will connect 3.3V power supply to this point and not to 5V power supply.

On board this point is shown on following picture.

 

 

ESP8266 to PIR sensor connection. 

PIR  ESP8266
3.3VCC after internal regulator 3.3V VCC
GND GND 
OUT GPIO2 on ESP8266

ESP8266 PIR sensor schematic 

 

 

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 #5 Andreas 2016-03-13 17:14
When i use this setup with a nodeMCU and esp8266-12E on back i have several problems.

in USB-Connected mode over a USB3 port, i can load the sketch and i can see on the serial monitor all running fine. If motion then it sends the expected 1 to IOT Server.

When i power off and power it on with a powersupply ( 5V 1A) it always jump between motion status and ok status.

When i press reset for 3 seconds, it works "sometimes"

I use arduino 1.6.6 with latest nodeMCU Firmware for the 8266-12E
Flashing the FW is not a problem and works well.
current: nodemcu-master-7-modules-2016-03-13-14-30-25-float

i have tried different powersupplys and i also tried GPIO 4 for the PIR Connection.

it must be a problem with the powercycle, but i did not find a solution. Also a 10k resistor between PIR and GPIO do not solve it.

Also give the PIR 5Volt to VCC from other source did not work. :( any users with ideas?
+1 #4 joseph zajdler 2015-12-24 19:56
Please confirm the this works without the LUA firmware, that's its the original firmware.
+1 #3 joseph zajdler 2015-12-24 19:55
Could some post wiring diagrams or maybe pinouts when NOT using the ESP-01. i.e. when using ESP-03,05,12 or NodeMCU ESP8266MOD
#2 joseph zajdler 2015-12-24 19:54
Great catch with the 3.3v on the PIR, whenever I can save on components to lower the cost, save energy, make it smaller or just don't have one on hand, i'm happy.
#1 M0003 2015-11-05 15:10
wtf?
log: http://pastebin.com/RWczbqRn

You have no rights to post comments