IOT Door Sensor - Wi-Fi Based, Powered on 2xAAA Batteries

by sylwekbala in Circuits > Electronics

1107 Views, 5 Favorites, 0 Comments

IOT Door Sensor - Wi-Fi Based, Powered on 2xAAA Batteries

doors_with_sensor_mobile-cricket.png

In this instructable 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 (or any other services including Home Assistant, MQTT or Webhooks with HTTP POST requests) to send phone notifications. When a door opens the Cricket sends notifications to your phone.

NOTE: this is a project 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

Supplies

Assembly

fritzing.jpg
WhatsApp Image 2020-05-19 at 09.38.01.jpeg
door_sensor.png

We 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 Service

webhooks_doc_uxy8IoMlsN.jpeg
webhooks_cqr6Hq9gZd.jpg

Steps 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 Portal

Open TOE Developer Portal (which comes with the IOT Cricket module) 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)

hotspot-small.png

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.

Fetch the Configuration From Developer Portal

Just 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

Feedback

We 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!