In this tutorial we will show how to build WiFi door/window sensor connected to EasyIoT Cloud. We will use ESP8266, magnetic switch and Arduino IDE.

Contents

1. Introduction

2. Materials

3. EasyIoT Cloud configuration 

4. Program

5. Hardware

6. Buying guide

 

Introduction

 

Door/window sensor historical chart.

 

Materials

-ESP8266 WiFi module

ESP8266 ESP-01 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-01 Serial WIFI Wireless Transceiver Module
$2.14
$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.95
ESP8266 ESP-05 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-05 Serial WIFI Wireless Transceiver Module
$1.88
$3.92
ESP8266 ESP-07 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-07 Serial WIFI Wireless Transceiver Module
$2.18
$1.99
ESP8266 Lua Nodemcu WIFI Network Development BoardESP8266 Lua Nodemcu WIFI Network Development Board
$7.43
$2.65

 

-Door/window magnetic switch

10 pcs MC-38 Wired Door Window Sensor Magnetic Switch10 pcs MC-38 Wired Door Window Sensor Magnetic Switch
$8.19
$7.00
 

 

-3.3V power supply (battery or regulator)

5pcs 3.3V regulator module 800mA5pcs 3.3V regulator module 800mA
$1.12
$1.56
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.

No EasyIoT Cloud configuration is needed - module is Plug And Play. We need just security token to connect to EasyIoT Cloud. Go to Configure->Tokens and press button Add token. Remember this token - you will need this token later in program. If you remove token from you account later module will stop sending values to EasyIoT Cloud. One token can be used with more than one device.

EasyIoT Cloud token

 

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 V1.0. Instructions how to install EIoTCloud REST V1.0 are here.

In program set access point name and password and security token we generated before. 

#define AP_USERNAME "xxx"
#define AP_PASSWORD "xxx"

#define TOKEN "xxx"

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

Hardware

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

One wire of magnetic switch connect to GPIO5 and other to ground and that's it. 

ESP8266 door/window sensor

 

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

Buying guide

 

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

ESP8266 ESP-01 Serial WIFI Wireless Transceiver Module

ESP8266 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-12 Serial WIFI Wireless Transceiver Module

ESP8266 serial Port WIFI wireless module ESP-12

ESP8266 ESP-03 Serial WIFI Wireless Transceiver Module

ESP8266 serial WIFI model ESP-03

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-07 Serial WIFI Wireless Transceiver Module

ESP8266 with external antenna

ESP8266 Lua Nodemcu WIFI Network Development Board

ESP8266 Lua Nodemcu WIFI Network Development Board

10 pcs MC-38 Wired Door Window Sensor Magnetic Switch

5pcs 3.3V regulator module 800mA

Basic regulator module based on AMS1117.

2xAA 3V Battery Holder Box Case Wire

This 2xAA battery holder puts a nice finishing touch on your battery powered project.

 


Comments   

#1 jarvis 2017-05-04 23:56
any idea about this error:
sketch_apr29b:163: error: invalid conversion from 'const char*' to 'uint8_t {aka unsigned char}' [-fpermissive]

pinMode(INPUT_PIN, INPUT_PULLUP);

^

In file included from sketch\sketch_apr29b.ino.cpp:1:0:

You have no rights to post comments