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
3. EasyIoT Cloud configuration
Introduction
Materials
-ESP8266 WiFi module
ESP8266 ESP-01 Serial WIFI Wireless Transceiver Module | |
$2.11 | |
$17.00 |
ESP8266 ESP-03 Serial WIFI Wireless Transceiver Module | |
$2.07 | |
$2.15 |
ESP8266 ESP-12 Serial WIFI Wireless Transceiver Module | |
$2.06 | |
$1.75 |
ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module | |
$1.88 |
ESP8266 ESP-07 Serial WIFI Wireless Transceiver Module | |
$2.18 | |
$1.88 |
ESP8266 Lua Nodemcu WIFI Network Development Board | |
$7.43 | |
$2.65 |
-PIR sensor
Pyroelectric Infrared Motion Sensor Detector Module HC-SR501 | |
$0.99 | |
$1.05 |
-3.3V power supply (battery or regulator)
5pcs 3.3V regulator module 800mA | |
$1.12 | |
$1.56 |
2xAA 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.
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 |
See more tutorials at http://iot-playground.com/build
Buying guide
To support this site and EasyIoT framework development please buy in our store.
Comments
This is a very interesting project!!!
So, I bought ESP8266 Lua and PIR sensor. So now I can make some experiment.
I know Arduino but I'm still not very experienced.
Someone, can upgrade sketch to work with new "EIoTCloudRestApi V1.0" library?
Thanks
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?
log: http://pastebin.com/RWczbqRn
RSS feed for comments to this post