- ESP8266 Wi-Fi module.
- PIR sensor.
- 3.3V power supply (battery or regulator).
EasyIoT Cloud configuration
Register to the EasyIoT Cloud service. If you do not receive a registration email, check your 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) as the 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 the web interface.
Then press the save button. After saving, you will see InstanceId/ParameterId. Make a note of it — you will need it later in program.
Go back to module configuration and add two more parameters (Add parameter button).
The two parameters are to set text in the module. Name the first parameter Settings.StatusText1 and the second one Settings.StatusText2. Set the value for the first as "Motion" and for the second as "Ok".
Next, we will set a picture for the module. We add two more parameters and name them Settings.Icon1 and Settings.Icon2. For the first parameter, set the value to "siren_2.png," and for the second second parameter, set the value as "siren_1.png".
After you add all the parameters, your module configuration should look like this:
The program is written in the Arduino ESP8266 IDE. See the Arduino ESP8266 IDE tutorial to learn how to connect your ESP8266 module to your computer to upload the program. The program is available at our GitHub. You will also need the EIoTCloudRestApi library. In the library, set the access point username and password.
In the program, change EIOT_CLOUD_INSTANCE_PARAM_ID:
// EasyIoT Cloud definitions - change EIOT_CLOUD_INSTANCE_PARAM_ID
#define EIOT_CLOUD_INSTANCE_PARAM_ID "xxxx"
Set the InstanceId/ParameterId in your parameter configuration.
If you change the GPIO pin on the ESP8266, then also change the GPIO pin in the program.
In our case, we use the ESP8266 01, but you can use any other ESP8266 with the FDTI programmer. For your power supply, you can use 2 AA batteries or 3.3V regulator AMS1117 (see buying guide).
The PIR sensor is powered by 5V, but if we look at the schematic, we will see that it's 3.3V internally. Because the ESP8266 is 3.3V, we can bypass the PIR internal regulator.
The Connection after the regulator is available at JP1 pin 3. In our case, we will connect the 3.3V power supply to this point and not to 5V power supply.
You can see it in the following picture:
ESP8266 to PIR sensor connection
|3.3VCC after internal regulator||3.3V VCC|
|OUT||GPIO2 on ESP8266|
And there you have it! Enjoy your motion sensor. See more tutorials at http://iot-playground.com/build.