In this project we present how you can easily build a battery powered Wi-Fi Door sensor with IOT Cricket Wi-Fi module. We also show how to integrate Cricket's messages with IFTTT (you can also use Home Assistant, MQTT or any other service supporting HTTP POST requests) to send phone notifications. When a door opens the Cricket sends notifications to your phone.
NOTE: this blog is to showcase how you can easily put together a prototype door sensor in a few minutes. However to make a fully fledged door sensor you might want to spend a bit more time to optimise the design for your needs.
In principle it works like that. When the magnet part is near to the reed sensor part (door closed) it disconnects IO1 from BATT, if the magnet move apart from reed sensor (door opened) it connects BATT voltage to IO1_Wakeup signal and wakes the board up.
We configure Cricket to send HTTP POST requests to the IFFTT where it is converted to push notifications, which are sent to a phone. Additionally all notifications include information about a battery level and an ambient temperature from the Cricket's built-in temperature sensor.
The instructions comprise with the following steps:
- Explaining project using schematics
- IFTTT setup with Pushbullet service
- Configuring IOT Cricket module
- Connecting IOT Cricket to the internet over Wi-Fi
Before you start, please make sure you have the following components:
- Cricket Wi-Fi module (https://www.thingsonedge.com/)
- Door Window Magnetic Switch
- Battery Holder
- 2xAAA batteries
If you are ready let's get started!
AssemblyWe use the NC reed sensor. Follow the schematics below to connect all components together.
Once you assemble, the circuits should work as follow. When a door is opened it wakes-up the Cricket indicated by LED blinking.
Your device is almost ready. Now let's configure IFTTT to send push notification on the door open event.
IFTTT setup with an Pushbullet serviceSteps to follow:
- Go to: https://ifttt.com/
- Login or register
- Click Create from User / Account menu (top right corner)
- Click + to create new source event
- Select Webhooks service
- Click Continue
- Click Receive a web request (on the left hand side)
- Create event name e.g. door_sensor
- The source event should be set-up now, click after Then event
- Search pushbullet service
- Change Event Name to door_sensor
- Change Title accordingly
- Change Message to Door open battery = {{Value1}} temp = {{Value2}}
- Click Finish
Almost there, now you need to get a HTTP address to which we can post events from the IoT module. Search for Webhooks service and click on the document in the right up corner.
Next copy web links under"Make a POST or GET web request to:" you will need it later.
Before we start using the device it needs to be configured in Developer Portal. Please go to the next section.
Configure your device in Developer PortalOpen TOE Developer Portal from any browser either from PC or mobile. You must register/login to Developer Portal to activate and configure the device in your account. Otherwise the device won't work.
After successful login / registration you need to click "Add new" device to activate your device in the system. You need to use the unique serial number printed on a label stick on the back of Cricket.
NOTE: You must keep the serial number for yourself only. Do not share it with anyone else.
Set the following configuration:
RTC: OFF
IO2: OFF
Battery monitor: ON
Temperature Sensor: ON
Force updates on - IO1 Wake Up: Yes
Force updates on - RTC Wake Up: No
Post Events: see below
Copy / paste the link we copied from Webhooks in io1_wakeup:
URL:
- replace https to http
- replace event to door_sensor
the link should look like this below:
http://maker.ifttt.com/trigger/door_sensor/with/key/{key}
Data:
{"value1":"#batt","value2":"#temp"}
Once you set your configuration hit the Save button.
We are almost there! We just need to connect our device to the internet over Wi-Fi network.
Connect to Wi-Fi network (internet)Press the button on the Cricket for 5 seconds until the LED is constantly lit. Then connect from any device with web browser capabilities (smartphone, laptop,...) to toe_device Circket's private Wi-Fi network. Open http://192.168.4.1/index.html page and pass your Wi-Fi credentials. That's it.
More information how to provision Cricket with your Wi-Fi network can be found in Cricket's IOT Developer Guide documentation.
Now our device is live and connected to the internet!
Fetch the configuration from Developer PortalJust one more step. Press the on board button for 1 second to fetch the configuration from Developer Portal. Now you are all set and you should keep receiving notifications on your phone when a door is open.
More information how to integrate with other services such as Home Assistant, MQTT or HTTP POST request see the Cricket's documentation: https://thingsonedge.com/documentation
FeedbackWe hope it was an enjoyable experience for you building a door sensor with Cricket! Please help us improve the the technology if you have any feedback or suggestions. If you liked the project please help us spread the word.
Thank you!
Comments