Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. How To - Doorbell Automation Hack

How To - Doorbell Automation Hack

Scheduled Pinned Locked Moved My Project
106 Posts 29 Posters 93.5k Views 26 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • petewillP Offline
    petewillP Offline
    petewill
    Admin
    wrote on last edited by
    #1

    Hi Everyone,

    I put together this quick how to video for hacking your doorbell to work with MySensors. It's pretty basic and the code is based on the Relay Actuator sketch. It has two main features: controlling if the doorbell rings with an on/off switch and sending a triggered state whenever it's pressed. The silence feature can be useful if a child (or you) is taking a nap. The triggered state can be used for many different things like starting a security camera, sending an alert or text message, playing custom sounds via Sonos or other device, etc. Another note, the doorbell will still function even if your home automation the controller is down for some reason.

    Here are the additional details:
    https://youtu.be/nMIcalwpstc

    Fritzing Doorbell Wiring_bb.png

    /*
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - PeteWill
     *
     * DESCRIPTION
     * This sketch is used to control a doorbell ring with a relay as well as send an
     * alert when the buttons is pressed.  Connect the button to ground and digital
     * pin 3.  The relay controlling the doorbell is conntected to pin 4.
     * 
     * Watch the How To video here: https://youtu.be/nMIcalwpstc
     */
    
    
    #include <MySensor.h>
    #include <SPI.h>
    #include <Bounce2.h>
    
    #define NODE_ID 16 // or set to AUTO if you want gw to assign a NODE_ID for you.
    
    #define DOORBELL_PIN  3      // Arduino Digital I/O pin number for the doorbell button 
    #define RELAY_PIN  4         // Arduino Digital I/O pin number for the relay 
    #define DOORBELL_CHILD_ID 0  //ID of the doorbell
    #define SWITCH_CHILD_ID 1    // Id of the switch that will control doorbell sound
    #define RELAY_ON 1
    #define RELAY_OFF 0
    
    Bounce debouncer = Bounce();
    
    MySensor gw;
    MyMessage switchMsg(SWITCH_CHILD_ID, V_LIGHT);
    MyMessage doorbellMsg(DOORBELL_CHILD_ID, V_TRIPPED);
    
    unsigned int doorbellDelay = 1000; // interval at which to keep the doorbell button sensor triggered (milliseconds). This is used to stop people (kids) from pressing it too often
    unsigned int ringTime = 700; //How long the doorbell relay is on (in milliseconds)
    unsigned long doorbellMillis;  //Used to keep track of the last doorbell button press
    unsigned long doorbellTimer;  //Used to keep track of doorbell ring time
    byte doorbellPreviousVal;  //Used to keep track of doorbell button pressed state
    boolean ringDoorbell;  //Used to initiate the ring doorbell if statement
    boolean doorbellSound; //Used to keep track if the doorbell should sound or be silent.  Value recieved from doorbell on/off switch
    boolean doorbellOff = true;  //Used to keep track of doorbell ring state
    
    void setup()
    {
      gw.begin(incomingMessage, NODE_ID);
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Doorbell Monitor", "1.0");
    
      // Setup the button and activate internal pull-up
      pinMode(DOORBELL_PIN, INPUT_PULLUP);
    
      // After setting up the button, setup debouncer
      debouncer.attach(DOORBELL_PIN);
      debouncer.interval(5);
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(SWITCH_CHILD_ID, S_LIGHT);
      gw.present(DOORBELL_CHILD_ID, S_MOTION);
    
      // Make sure relays are off when starting up
      digitalWrite(RELAY_PIN, RELAY_OFF);
      // Then set relay pins in output mode
      pinMode(RELAY_PIN, OUTPUT);
    
      // Set doorbellSound to last known state (using eeprom storage)
      doorbellSound = gw.loadState(SWITCH_CHILD_ID);
    }
    
    void loop()
    {
      gw.process();
        unsigned long currentMillis = millis();
      //Check to see if doorbell button was pushed.
      if (currentMillis - doorbellMillis > doorbellDelay) //used to stop doorbell from being pressed too frequently
      {
        debouncer.update();
        // Read doorbell button value
        byte doorbellDetect = !debouncer.read();//read, then reverse the value so it will send correct trigger state to controller
    
        if (doorbellDetect != doorbellPreviousVal)
        {
          //Serial.print("doorbellDetect Value: ");
          //Serial.println(doorbellDetect);
          gw.send(doorbellMsg.set(doorbellDetect)); 
          if (doorbellDetect == 1)
          {
            ringDoorbell = true;
            doorbellTimer = currentMillis;
          }
          doorbellMillis = currentMillis;
          doorbellPreviousVal = doorbellDetect;
        }
      }
    
      if (ringDoorbell)
      {
        if (doorbellSound)
        {
          if (doorbellOff)
          {
            digitalWrite(RELAY_PIN, RELAY_ON);
            //Serial.println("Doorbell sounded.");
            doorbellOff = false;
          }
          else
          {
            if (currentMillis - doorbellTimer > ringTime)
            {
              ringDoorbell = false;
              digitalWrite(RELAY_PIN, RELAY_OFF);
              //Serial.println("Doorbell off.");
              doorbellOff = true;
            }
          }
        }
      }
    }
    
      void incomingMessage(const MyMessage & message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.isAck()) {
          Serial.println("This is an ack from gateway");
        }
    
        if (message.type == V_LIGHT) {
          // Change relay state
          doorbellSound = message.getBool();
          // Store state in eeprom
          gw.saveState(SWITCH_CHILD_ID, doorbellSound);
    
          // Write some debug info
          Serial.print("Incoming change for sensor:");
          Serial.print(message.sensor);
          Serial.print(", New status: ");
          Serial.println(message.getBool());
        }
      }
    

    My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

    barduinoB riochickenR 2 Replies Last reply
    9
    • TheoLT Offline
      TheoLT Offline
      TheoL
      Contest Winner
      wrote on last edited by
      #2

      Well done. I was thinking about the same hack. So that I can have my doorbell in silent mode, if one of the neighbor kids is playing ring-my bell and run away ;)

      I like your relay solution, that's something I'm gonna do as well.

      petewillP 1 Reply Last reply
      0
      • TheoLT TheoL

        Well done. I was thinking about the same hack. So that I can have my doorbell in silent mode, if one of the neighbor kids is playing ring-my bell and run away ;)

        I like your relay solution, that's something I'm gonna do as well.

        petewillP Offline
        petewillP Offline
        petewill
        Admin
        wrote on last edited by
        #3

        @TheoL Thanks! That's a good use case too. Dang kids. ;)

        My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

        1 Reply Last reply
        0
        • DwaltD Offline
          DwaltD Offline
          Dwalt
          wrote on last edited by
          #4

          Great hack! A simple and compact board for this would be the Mini RBoard from itead, 37mm x49mm. Just plug in a nRf.

          Veralite UI5 :: IBoard Ethernet GW :: MyS 1.5

          petewillP 1 Reply Last reply
          0
          • HoffanH Offline
            HoffanH Offline
            Hoffan
            wrote on last edited by
            #5

            That looks like a perfekt board for this Hack

            1 Reply Last reply
            0
            • petewillP petewill

              Hi Everyone,

              I put together this quick how to video for hacking your doorbell to work with MySensors. It's pretty basic and the code is based on the Relay Actuator sketch. It has two main features: controlling if the doorbell rings with an on/off switch and sending a triggered state whenever it's pressed. The silence feature can be useful if a child (or you) is taking a nap. The triggered state can be used for many different things like starting a security camera, sending an alert or text message, playing custom sounds via Sonos or other device, etc. Another note, the doorbell will still function even if your home automation the controller is down for some reason.

              Here are the additional details:
              https://youtu.be/nMIcalwpstc

              Fritzing Doorbell Wiring_bb.png

              /*
               * The MySensors Arduino library handles the wireless radio link and protocol
               * between your home built sensors/actuators and HA controller of choice.
               * The sensors forms a self healing radio network with optional repeaters. Each
               * repeater and gateway builds a routing tables in EEPROM which keeps track of the
               * network topology allowing messages to be routed to nodes.
               *
               * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
               * Copyright (C) 2013-2015 Sensnology AB
               * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
               *
               * Documentation: http://www.mysensors.org
               * Support Forum: http://forum.mysensors.org
               *
               * This program is free software; you can redistribute it and/or
               * modify it under the terms of the GNU General Public License
               * version 2 as published by the Free Software Foundation.
               *
               *******************************
               *
               * REVISION HISTORY
               * Version 1.0 - PeteWill
               *
               * DESCRIPTION
               * This sketch is used to control a doorbell ring with a relay as well as send an
               * alert when the buttons is pressed.  Connect the button to ground and digital
               * pin 3.  The relay controlling the doorbell is conntected to pin 4.
               * 
               * Watch the How To video here: https://youtu.be/nMIcalwpstc
               */
              
              
              #include <MySensor.h>
              #include <SPI.h>
              #include <Bounce2.h>
              
              #define NODE_ID 16 // or set to AUTO if you want gw to assign a NODE_ID for you.
              
              #define DOORBELL_PIN  3      // Arduino Digital I/O pin number for the doorbell button 
              #define RELAY_PIN  4         // Arduino Digital I/O pin number for the relay 
              #define DOORBELL_CHILD_ID 0  //ID of the doorbell
              #define SWITCH_CHILD_ID 1    // Id of the switch that will control doorbell sound
              #define RELAY_ON 1
              #define RELAY_OFF 0
              
              Bounce debouncer = Bounce();
              
              MySensor gw;
              MyMessage switchMsg(SWITCH_CHILD_ID, V_LIGHT);
              MyMessage doorbellMsg(DOORBELL_CHILD_ID, V_TRIPPED);
              
              unsigned int doorbellDelay = 1000; // interval at which to keep the doorbell button sensor triggered (milliseconds). This is used to stop people (kids) from pressing it too often
              unsigned int ringTime = 700; //How long the doorbell relay is on (in milliseconds)
              unsigned long doorbellMillis;  //Used to keep track of the last doorbell button press
              unsigned long doorbellTimer;  //Used to keep track of doorbell ring time
              byte doorbellPreviousVal;  //Used to keep track of doorbell button pressed state
              boolean ringDoorbell;  //Used to initiate the ring doorbell if statement
              boolean doorbellSound; //Used to keep track if the doorbell should sound or be silent.  Value recieved from doorbell on/off switch
              boolean doorbellOff = true;  //Used to keep track of doorbell ring state
              
              void setup()
              {
                gw.begin(incomingMessage, NODE_ID);
              
                // Send the sketch version information to the gateway and Controller
                gw.sendSketchInfo("Doorbell Monitor", "1.0");
              
                // Setup the button and activate internal pull-up
                pinMode(DOORBELL_PIN, INPUT_PULLUP);
              
                // After setting up the button, setup debouncer
                debouncer.attach(DOORBELL_PIN);
                debouncer.interval(5);
              
                // Register all sensors to gw (they will be created as child devices)
                gw.present(SWITCH_CHILD_ID, S_LIGHT);
                gw.present(DOORBELL_CHILD_ID, S_MOTION);
              
                // Make sure relays are off when starting up
                digitalWrite(RELAY_PIN, RELAY_OFF);
                // Then set relay pins in output mode
                pinMode(RELAY_PIN, OUTPUT);
              
                // Set doorbellSound to last known state (using eeprom storage)
                doorbellSound = gw.loadState(SWITCH_CHILD_ID);
              }
              
              void loop()
              {
                gw.process();
                  unsigned long currentMillis = millis();
                //Check to see if doorbell button was pushed.
                if (currentMillis - doorbellMillis > doorbellDelay) //used to stop doorbell from being pressed too frequently
                {
                  debouncer.update();
                  // Read doorbell button value
                  byte doorbellDetect = !debouncer.read();//read, then reverse the value so it will send correct trigger state to controller
              
                  if (doorbellDetect != doorbellPreviousVal)
                  {
                    //Serial.print("doorbellDetect Value: ");
                    //Serial.println(doorbellDetect);
                    gw.send(doorbellMsg.set(doorbellDetect)); 
                    if (doorbellDetect == 1)
                    {
                      ringDoorbell = true;
                      doorbellTimer = currentMillis;
                    }
                    doorbellMillis = currentMillis;
                    doorbellPreviousVal = doorbellDetect;
                  }
                }
              
                if (ringDoorbell)
                {
                  if (doorbellSound)
                  {
                    if (doorbellOff)
                    {
                      digitalWrite(RELAY_PIN, RELAY_ON);
                      //Serial.println("Doorbell sounded.");
                      doorbellOff = false;
                    }
                    else
                    {
                      if (currentMillis - doorbellTimer > ringTime)
                      {
                        ringDoorbell = false;
                        digitalWrite(RELAY_PIN, RELAY_OFF);
                        //Serial.println("Doorbell off.");
                        doorbellOff = true;
                      }
                    }
                  }
                }
              }
              
                void incomingMessage(const MyMessage & message) {
                  // We only expect one type of message from controller. But we better check anyway.
                  if (message.isAck()) {
                    Serial.println("This is an ack from gateway");
                  }
              
                  if (message.type == V_LIGHT) {
                    // Change relay state
                    doorbellSound = message.getBool();
                    // Store state in eeprom
                    gw.saveState(SWITCH_CHILD_ID, doorbellSound);
              
                    // Write some debug info
                    Serial.print("Incoming change for sensor:");
                    Serial.print(message.sensor);
                    Serial.print(", New status: ");
                    Serial.println(message.getBool());
                  }
                }
              
              barduinoB Offline
              barduinoB Offline
              barduino
              wrote on last edited by
              #6

              Great How To @petewill

              1 Reply Last reply
              0
              • DwaltD Dwalt

                Great hack! A simple and compact board for this would be the Mini RBoard from itead, 37mm x49mm. Just plug in a nRf.

                petewillP Offline
                petewillP Offline
                petewill
                Admin
                wrote on last edited by
                #7

                @Dwalt Nice! Thanks for sharing. That looks like a perfect board for something like this.

                My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                1 Reply Last reply
                0
                • TD22057T Offline
                  TD22057T Offline
                  TD22057
                  Hardware Contributor
                  wrote on last edited by
                  #8

                  FYI for anyone who wants to make a more complicated version of this, take a look at LowPowerLabs door bell controller. There is some good docs there (and in the follow up articles) if you want to try and tap the door bell power source to power the arduino. There is also a nice explanation of how to detect when another circuit activates which might be handy for another application.

                  DrJeffD 1 Reply Last reply
                  0
                  • TD22057T TD22057

                    FYI for anyone who wants to make a more complicated version of this, take a look at LowPowerLabs door bell controller. There is some good docs there (and in the follow up articles) if you want to try and tap the door bell power source to power the arduino. There is also a nice explanation of how to detect when another circuit activates which might be handy for another application.

                    DrJeffD Offline
                    DrJeffD Offline
                    DrJeff
                    wrote on last edited by
                    #9

                    @TD22057 This was the route I was heading with adding the doorbell to my HA, but @petewill is awesome in doing this with the video. Me and my daughter where just trying to decide what would be the best way to hack the bell. We added a Ring.com Doorbell (trial period) and trying to decide if we like it or not. The notifications are 2 way so that is nice with video and audio. But they do not have an API. I think I will try to sniff out the Motion detection or use it from my notifications to tie into my HA.

                    1 Reply Last reply
                    0
                    • TD22057T Offline
                      TD22057T Offline
                      TD22057
                      Hardware Contributor
                      wrote on last edited by
                      #10

                      @DrJeff Very cool. I have 2 HikVision cameras covering the front of my house so I think I'm going to try the DIY version of Ring.com. Both of the cameras have "alarm" input and output wires (12V signal) that you can use to start recording video using an external PIR or do something when the camera detects motion. One camera has an external Bosch PIR sensor that works really well. It's a 12 V NC signal wire connected to the camera and it has eliminated virtually all of the false motion alarms. The other camera is above the door and has a built in PIR sensor.

                      Reading this thread made me realize that I should tap into the door bell signal and the alarm output wire on the camera above to the door and send that out as a MySensor message which will send an MQTT message to a script which can grab the camera feed and email me still images (or send me a link to a web page w/ the images) of who is coming up to the house.

                      1 Reply Last reply
                      0
                      • BigDogB Offline
                        BigDogB Offline
                        BigDog
                        wrote on last edited by
                        #11

                        great! i am going to add this to my home domoticz! Thanks

                        1x Raspberry With Domoticz V2.3011 [Linux version 4.1.6+]
                        PiRack With
                        -1X PiFace Digital
                        -1X RaZberry - OpenZWave
                        1X RFXtrx433 USB Firmware: 183
                        5X Arduino: mysensors V1.5(including)

                        • First DoorBel Project -> WORKS! :)
                          6x ESP8266: easy firmware(Testing)
                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          drock1985
                          wrote on last edited by
                          #12

                          Going to install one of these very soon.

                          How hard would it be to modify the sketch for a two door bell system?

                          My Projects
                          2 Door Chime Sensor
                          Washing Machine Monitor

                          petewillP 1 Reply Last reply
                          0
                          • D drock1985

                            Going to install one of these very soon.

                            How hard would it be to modify the sketch for a two door bell system?

                            petewillP Offline
                            petewillP Offline
                            petewill
                            Admin
                            wrote on last edited by
                            #13

                            @drock1985 Sorry for the delayed reply! It shouldn't be too hard. You will just have to create another button input and relay output in the sketch. I haven't looked at the code but you should be able to duplicate what's in there just changing the names and pins where appropriate.

                            My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                            D 1 Reply Last reply
                            0
                            • petewillP petewill

                              @drock1985 Sorry for the delayed reply! It shouldn't be too hard. You will just have to create another button input and relay output in the sketch. I haven't looked at the code but you should be able to duplicate what's in there just changing the names and pins where appropriate.

                              D Offline
                              D Offline
                              drock1985
                              wrote on last edited by
                              #14

                              @petewill

                              Awesome, thanks.I have the parts on order, minus the power supply (will power from AA batteries for now until I get in a DC-DC step down regulator).

                              Just need to find a half decent chime now. lol

                              My Projects
                              2 Door Chime Sensor
                              Washing Machine Monitor

                              1 Reply Last reply
                              0
                              • D Offline
                                D Offline
                                drock1985
                                wrote on last edited by
                                #15

                                Hey @petewill

                                Started working on the project this weekend. Didn't get the parts in this week due to the holiday. Did what I could though, and I have a schematic/drawing made up for the system. This is my first drawing in fritzing, so it's a little crude. I couldn't figure out how to add a 'T' section/junction in the wire, but it all lines up for reference anyways.

                                I'll start working on the Arduino code next.

                                MySensors_2Door_Chime_bb.png

                                My Projects
                                2 Door Chime Sensor
                                Washing Machine Monitor

                                1 Reply Last reply
                                0
                                • hekH Offline
                                  hekH Offline
                                  hek
                                  Admin
                                  wrote on last edited by
                                  #16

                                  Why don't you send over the signal wirelessly between the two doorbells?

                                  1 Reply Last reply
                                  0
                                  • D Offline
                                    D Offline
                                    drock1985
                                    wrote on last edited by
                                    #17

                                    Hi @hek

                                    I'm not too sure I understand what you are referring to. If you are referring to the buttons themselves outside being wireless, I thought about it but wasn't too sure how long a battery would last and didn't want to be changing batteries. The way I plan to do this now, I can use the existing wiring for the doorbells that are already there, and splice into the power for the door bell to power the MySensors node.

                                    Plus, both chimes are in the same spot, one relay sets off one set of the three contacts (Wtih a common ground I believe) and the other will chime the second.

                                    My Projects
                                    2 Door Chime Sensor
                                    Washing Machine Monitor

                                    hekH 1 Reply Last reply
                                    0
                                    • D drock1985

                                      Hi @hek

                                      I'm not too sure I understand what you are referring to. If you are referring to the buttons themselves outside being wireless, I thought about it but wasn't too sure how long a battery would last and didn't want to be changing batteries. The way I plan to do this now, I can use the existing wiring for the doorbells that are already there, and splice into the power for the door bell to power the MySensors node.

                                      Plus, both chimes are in the same spot, one relay sets off one set of the three contacts (Wtih a common ground I believe) and the other will chime the second.

                                      hekH Offline
                                      hekH Offline
                                      hek
                                      Admin
                                      wrote on last edited by
                                      #18

                                      @drock1985

                                      Ahh. nice. Thought you might have to run some new wires around the house.

                                      D 1 Reply Last reply
                                      0
                                      • hekH hek

                                        @drock1985

                                        Ahh. nice. Thought you might have to run some new wires around the house.

                                        D Offline
                                        D Offline
                                        drock1985
                                        wrote on last edited by
                                        #19

                                        @hek lol, no. Just hooking up everything to the internet that I can.

                                        My Projects
                                        2 Door Chime Sensor
                                        Washing Machine Monitor

                                        petewillP 1 Reply Last reply
                                        0
                                        • D drock1985

                                          @hek lol, no. Just hooking up everything to the internet that I can.

                                          petewillP Offline
                                          petewillP Offline
                                          petewill
                                          Admin
                                          wrote on last edited by
                                          #20

                                          @drock1985 Nice! Does your doorbell use DC so you can steal power from it? I wish mine did. That would have made things easier for me. Mine uses 16VAC... :(

                                          My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                                          BulldogLowellB 1 Reply Last reply
                                          1
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          6

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular