Creating a Smart IoT Door Sensor with Soracom

IoT door sensor, door opening

IoT projects often begin with a simple concept: ‘How can a smart device address a common problem?’ In my spare time, I enjoy woodworking in my basement. This means there are a lot of power tools, saws, and general storage that I would rather my kids not get into while I’m not around. Now I could always simply lock the door, but my kids are clever enough to get through a lock from time to time, so a better solution may be in some kind of smart IoT door sensor.

As such, I decided to go one step further and utilize smart IoT devices to monitor the door. I wanted to track whenever the door opens and closes, and how often. Fortunately, by using a few simple IoT devices and a Soracom account, I was able to get this project up and running in no time.

Getting Started: Connecting Your Hardware 

To build my IoT-powered door sensor, I will be using the Soracom LTE-M Button and a simple magnetic sensor, paired with Soracom services to monitor and record when the door is opened. Both items can be obtained at our partners Mouser and Digikey.

Soracom LTE-M Button
IoT Door Sensor

Once you’ve received your hardware, the first thing you want to do is to set up your Soracom account. Next, you will need to activate your embedded SIM card. Our Quick Start Guide can help walk you through each of these steps to get you started. 

With the SIM in the LTE-M Button successfully registered, you’ll want to ensure that the onboard LED light glows green, which indicates a successful connection. Push the button to send data to Soracom and ensure that your connection and submission are working appropriately. You’ll want to log into the User Console to confirm that your device has successfully sent that data. You can also view the data by using Soracom Harvest.

Learn more about setting up the LTE-M Button here.

Next Steps: Deploying Your IoT Door Sensor

Once the connectivity is established, our next step is to attach the magnetic sensor to the button. If this had been a professional-grade project I may have soldered a more permanent wired connection between the sensor and the LTE-M Button, but given that this is a proof of concept, I opted to use alligator clips to connect the wires of the sensor to the button.

If you are using a wired connection, be sure you have enough slack to comfortably allow the sensors to rest on the door frame while still reaching wherever you are placing the button. You’ll want to make sure the wires don’t hang anywhere that could be caught by the swinging door. 

However you connect your sensors, you’ll want to be sure to test your newly created connection by opening the door. Be sure the LED on the button is blinking green, and verify that the data has been received within the Soracom User Console. 

IoT Door Sensor, Soracom LTE-M Button, Project

Making Sense of Your IoT Data

Now that we have established connectivity and can see the data arriving when the door is opened, the next step is to set up alerts for this change. Soracom’s developer documentation has a step-by-step process on how to create a webhook that enables email alerts to sensor activity using our proxy service Soracom Beam and automation platform IFTTT

If you follow these instructions, you should have a functioning webhook through IFTTT that sends encrypted requests through Soracom Beam, triggering an email notification whenever the sensor is tripped by opening the door. Once the webhook is created and Beam is configured, we should be ready to do final tests for the process.

After logging into the User Console and selecting the group that the SIM is assigned to, you can select Soracom Beam and enable it. Then set the protocol, host, and port for IFTTT as well as the path of your Webhook that you created.

soracom beam, IoT door sensor project

 Upon triggering the sensor, I received an email like this:

IoT door sensor notification

This notification from the webhook I configured with IFTTT informs me that the door was opened at 5:45 PM on November 15, 2023. Now by enabling alerts on my mobile device, whether that be a smartphone or wearable, I can see whenever the door is opened, wherever I am at the time!

Conclusion 

Though this project may seem fairly simple, the practical applications of this kind of connected sensor can be useful in a number of ways. As designed, this system could be used to track traffic at a retail shop, keep tabs on security doors, or just allow parents to know when their kids are messing around in their woodshop when they aren’t supposed to. It’s just another example of a low-cost and easy solution created with Soracom products and services.

………………

Got a question for Soracom? Whether you’re an existing customer, interested in learning more about our product and services, or want to learn about our Partner program – we’d love to hear from you!