SMS Garage Alert system using an Ultrasonic sensor

ESP8266 SMS Garage Alert system using a RCW-0001 Micro Ultrasonic Sensor and a Webhook ( and IFTTT android app)

Similar projects worth following

Last year burglaries were happening in my rural area and even in my tiny village, where I grew up. Unfortunately burglary is now a common occurence for the last few years in my area where I live at the moment. Burglars also broke into the garage of my family home and stole the old motorbike of my brother:  

It's a real shame. A short while later another burglary happened during the night next to my home. My mother, who slept with her window open and couldn't sleep so well since the first accident, heard the burglars during that night. We called the police and it took them between 45 and 60 minutes to arrive. They came from the Police Station in Straußberg, which is pretty far away from my home. Now you see the dilemma. The new counter measurement against them is to let the street lights burn the whole night, which is of course super energy efficient.... Additionally my father let me know, that people want to create a civil defense against the burglars. They asked my father, if he would like to patrol at night, because he is a pensioner. Both things are unnecessary in the age of IoT.

The goal of my project was to create a cheap home alarm system using a microcontroller with a wifi module, a distance measurement sensor and a webhook notification (SMS to my smartphone, when our garage door gets opened). Not an overly complex project, but a fun one. 

I didn't want to include something in my project, which creates noise  (for instance a sirene), because there is still the chance that the police can appear in a timely manner. In the case the closest police patrol is too far away, we can still use the megaphone I've bought for my mother to scare the burglars away. :P

The project is relatively cheap. Most likely most of the components I've used are lying around in your own Maker Lab already. The components section shows you all the items and tools, which were mandatory for me to complete the project. The components section shows you also were I've bought all my components and tools originally. The following components have to be purchased most likely:

The project costs are approximately 18 Euro, if you don't include the delivery costs.

ino - 7.76 kB - 11/13/2019 at 04:50



header file with your secret data

h - 198.00 bytes - 11/11/2019 at 01:37


View all 15 components

  • Log 4

    Paul G.12/20/2019 at 01:29 0 comments

    I've bought another USB-Charger for my project, because this Wall socket battery charger is unreliable. Twice my project stopped working using 2 of these and one of these chargers even got damaged.

    I've bought this USB Charger instead from a local electronics shop named Conrad. This one seems to be more reliable, because my project is running for at least 3 weeks now without a hitch! I've also updated the components list.

  • Log 3

    Paul G.11/13/2019 at 18:57 0 comments

    And the testing phase is over! I've implemented the code from Log 2 into my sketch. You can also take a look at the code in the section Project code. The new sketch can be downloaded in the files section. The D1 Mini should consume less power now, when the watchdog isn't active. I will measure the actual currents on the weekend, when I'm less tired.  I'm really busy at the moment, because I'm doing an advanced training in the field of geoinformation systems (GIS) so please bear with me. 

  • Log 2

    Paul G.11/11/2019 at 19:10 0 comments

    Currently I'm trying to reduce the power consumption of my project setup by turning the WiFi module off, when it's not needed, thus during the time period were the watchdog isn't active. I'm testing my new code at the moment.

    The following functions are essential for achieving my goal:

    // function for turning the WiFi module off
    void stopWiFiAndSleep() {
      Serial.println("WiFi module disabled...");

    Why delay(1000)? If you want to know why, click on the link. :) I had the same problem and the suggestion of ardyesp fixed it.

    // function for wake up and starting WiFi connection
    void startWiFiAndWake() {
      // Bring up the WiFi connection
      while (WiFi.status() != WL_CONNECTED)
      Serial.print("WiFi Connected, IP address: ");

    Till next time!

  • Log 1

    Paul G.11/11/2019 at 02:59 0 comments

    I've removed the mechanical timer switch from my original project setup to reduce one potential weak point. The downside is, that the Wemos D1 Mini is running all day every day now.  Furthermore I've changed my project code, which was required after removing the timer switch from the setup. With the new code it's also possible now to check out  the sensor measurements in a web browser on your comfy couch! :)

    I've looked for a data sheet for the Wemos D1 Mini, but I couldn't find one. I've found a data sheet for the ESP8266 at least.  Even with a current consumption of 170 mA (in the worst case scenario in regards to the WiFi connection) and an operating Voltage of 3.3 V it seems the project is still financially reasonable (1.47 Euro per year). I will check out the consumption of my project setup in the next few days. 

    Also I've found out about this waterproof ultrasonic sensor, which I wasn't aware of. I just ordered that one. I would definitely recommend this one for areas, which are colder and more humid (like a garage) to guarantee, that your sensor isn't decaying quite so fast. I will test the sensor I'm using right now though to get an idea about how reliable this one is in a harsher environment. I will do updates on this topic in the future. 

View all 4 project logs

  • 1
    Creating the wires to connect the sensor with the D1 Mini

    The D1 mini is a cheap microcontroller with a wifi module. It's possible to connect the board with my home Wifi, if I place it next to one of the windows of my garage. The connected Ultrasonic sensor itself has to be placed in front of the garage door though. I had to bridge the distance between my D1 mini and the sensor by tinkering with some wires. That's why I've ordered Copper Wire with different colored isolations (Red and blue). In the end, I've created 4 wires (Echo wire, Trigger wire, VIN wire and a GND wire). I've soldered one half of a Jumper Wire to every end of the individual wires to connect the finished wires with a PCB header (packaged with the D1 Mini) and with the breadboard the D1 mini was placed on. Before doing so, I've put some shrink tube over the longer wires. For this kind of work I recommend a Third hand. The pictures below illustrate what I did and what I've used. Furthermore I've put a paper name tag on every single wire. Besides using red (VIN) and black Jumper Wires (GND) I also use orange colored Jumper Wires as VIN wires and blue colored wires as GND wires. 

  • 2
    Soldering the PCB and putting everything together

    The next step included soldering both headers to a circuit board. I had to use a PCB to make sure, that the Ultrasonic sensor fits into the distribution box. Originally I've wanted to use a breadboard instead, but that didn't work out. Personally I had problems creating soldering lines on the PCB with the solder alone, which came with my new soldering station. That's the reason I've bought plated copper wire to solder the bottom part of the circuit board in a way, which is easier. The following video illustrates the technique well: 

    There is definitely some room for improvement in regards of my PCB soldering skills, but this did the job. With more practice, I should create better looking soldering jobs. :)

    The upper left part on the circuit board can be ignored. A week earlier I just tried to get a feeling for soldering on a PCB again.

    To make the PCB stand inside my distribution box, I've used the following PCB standoffs. I had to sand off parts of the feet of the standoffs though, so the sensor could fit through the holes I've drilled.

    I've bent one header to stick the Ultrasonic sensor into it later on. Additionally I had to bent the pins on the Ultrasonic sensor to connect the sensor to the bent header. Of course I had to drill some holes too. One hole for the wires and 2 holes in the front for the sensor itself.  Later on, I've used glue from a glue pistol to close the drilled holes in the sensor box and in the D1 Mini box. The following illustrations show the finished sensor box from the side and the finished D1 Mini box:

    I've put the sensor box under a dog house, which is standing unsuspiciously next to our garage door . That way the sensor box is well hidden. The sensor box itself is aiming towards the garage door.

    The usb cable, which is  leading out of the D1 Mini box was plugged into a Wall socket battery charger to power the D1 Mini.

  • 3
    Webhook creation

    The goal of this project was, that the D1 Mini uses a webhook to send an alert SMS to my phone, if somebody enters my garage. I've used the website to create  a webhook, which provides this service. The following steps describe the process (Note: You need the IFTTT android app to use the method I'm decribing in the following steps):

    Step 1: Create an account on the site. Click on your profile picture next to the "Explore" button and then on "Create".

    Step 2: Click on the plus symbol and use the search function afterwards. Search for the word "webhook".  Click on the Webhook symbol and then on "receive a webrequest". Then it's time  to choose an event name. Later on the chosen eventname will be needed in your sketch you will run on your own D1 Mini microcontroller. Create the trigger.

    Step 3: After you created the event name it's time to take care of the sms notification. Remember the plus symbol? Now it should appear next to the word "That". Click on the plus symbol and search for "android sms".  Follow the instructions and enter the phone number, which you want to use for the sms notifications.

    Note: This service requires the IFTTT app for Android.

    Step 4: The D1 Mini needs to make a web request to fire up the webhook, which we just created. That's why you need to make a web request using a certain link with a key at the end, which is connected to your specific event. To get this key follow the following steps: Click on "IFTTT" on the top left corner > Webhooks > Documentation. On this page you find the URL, which you need to make use of the webhook. The following pictures illustrate the process:

    This URL in the last picture is really important. It will be needed in the sketch you will upload to the D1 Mini. Beforehand you can test if everything works though. Just replace YourEventName with your event name and replace YourKey with the real key in the link below:

    A sms will be send to the phone number you've used in step 3.

    Additional information: If you want to change the event name or the sms message, just click on your profile picture. Then click on "My applets" and choose the event you want to edit. Afterwards on the top right corner you should find the settings button. Now you can change the event name or the sms message.  Don't forget to adjust the event name in your header file arduino_secrets.h (For more information take a look at the section named "Project code")!

View all 4 instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates