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.6k 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.
  • 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.

    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
      • petewillP petewill

        @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... :(

        BulldogLowellB Offline
        BulldogLowellB Offline
        BulldogLowell
        Contest Winner
        wrote on last edited by
        #21

        @petewill

        Convert it!!!

        you have the power

        you have the technology

        diode bridge

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

          Hey @petewill

          They vary. Some of the more expensive ones I've noticed use DC (ex play custom songs/tones), while the cheaper ones use AC.

          I built the project around the idea the wife would want something more elaborate than a simple ding sound, but I was wrong lol. So I picked up one that she looked last night, and I believe it uses AC, so I will be making a slight change to my design.

          I'll end up putting in one of these I figure, just haven't quite figured out what size smoothing capacitor I will need.

          Also, I'm not 100% sure yet (at work, hard to do research) but I may be able to get away with a simple 5v regulator once the power is converted to DC, in lieu of a variable buck converter.

          http://m.wikihow.com/Make-an-AC-DC-Converter

          DrJeffD 1 Reply Last reply
          0
          • BulldogLowellB BulldogLowell

            @petewill

            Convert it!!!

            you have the power

            you have the technology

            diode bridge

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

            @BulldogLowell Haha, I just took the easy way out and ran a 5V line :)

            @drock1985

            I built the project around the idea the wife would want something more elaborate than a simple ding sound, but I was wrong lol.

            Yeah, that's happened to me as well on other projects :)

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

            BulldogLowellB 1 Reply Last reply
            0
            • D drock1985

              Hey @petewill

              They vary. Some of the more expensive ones I've noticed use DC (ex play custom songs/tones), while the cheaper ones use AC.

              I built the project around the idea the wife would want something more elaborate than a simple ding sound, but I was wrong lol. So I picked up one that she looked last night, and I believe it uses AC, so I will be making a slight change to my design.

              I'll end up putting in one of these I figure, just haven't quite figured out what size smoothing capacitor I will need.

              Also, I'm not 100% sure yet (at work, hard to do research) but I may be able to get away with a simple 5v regulator once the power is converted to DC, in lieu of a variable buck converter.

              http://m.wikihow.com/Make-an-AC-DC-Converter

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

              @drock1985 said:

              I'll end up putting in one of these I figure, just haven't quite figured out what size smoothing capacitor I will need.

              Add a cap .1uf input side of the 5V regulator and a 47-220uf on the regulated 5V . High freq and a low freq ripple.

              That should do the trick same thing I was planning on doing. I bought the Ring Doorbell but still want to be notified of the actual ring into HA.

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

                Hi @petewill

                I finally got the parts in to do the project. I've been working on the code, but I seem to be running into an issue. I have the four devices show up in Domoticz, but I'm not getting any feedback from the sensor. Would you mind looking at the code for me please? This is the first program I have ever worked on, and not much of a programmer mentality yet.

                /*
                 * 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
                 * 
                 * 2 Door Chime
                 * Version 1.0 - ResentedPoet
                 * DESCRIPTION
                 * Original idea/concept by PeteWill. Modified code to add second actuator (relay)
                 * door chimes with 2 doors. This will allow your home automation system to differentiate
                 * between front and back door. As well, this allows current 2 door chimes to still have
                 * their individual chimes. Pins 3 and 4 are used for door bell 1 and relay/chime 1 
                 * respectively, and digital pins 5 and 6 for door bell 2 and relay/chime 2.
                 */
                
                
                #include <MySensor.h>
                #include <SPI.h>
                #include <Bounce2.h>
                
                #define NODE_ID AUTO // or set a manual ID in place of AUTO
                
                #define DOORBELL1_PIN  3      // Arduino Digital I/O pin number for the doorbell button 
                #define RELAY1_PIN  4         // Arduino Digital I/O pin number for the relay 
                #define DOORBELL1_CHILD_ID 0  //ID of the front doorbell
                #define SWITCH1_CHILD_ID 1    // Id of the switch that will control front doorbell sound
                #define RELAY1_ON 1
                #define RELAY1_OFF 0
                #define DOORBELL2_PIN  5      // Arduino Digital I/O pin number for the doorbell button 
                #define RELAY2_PIN  6         // Arduino Digital I/O pin number for the relay 
                #define DOORBELL2_CHILD_ID 2  //ID of the back doorbell
                #define SWITCH2_CHILD_ID 3    // Id of the switch that will control back doorbell sound
                #define RELAY2_ON 1
                #define RELAY2_OFF 0
                
                Bounce debouncer = Bounce();
                
                MySensor gw;
                MyMessage switchMsg1(SWITCH1_CHILD_ID, V_LIGHT);
                MyMessage switchMsg2(SWITCH2_CHILD_ID, V_LIGHT);
                MyMessage doorbellMsg1(DOORBELL1_CHILD_ID, V_TRIPPED);
                MyMessage doorbellMsg2(DOORBELL2_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 doorbell1Millis;  //Used to keep track of the last front doorbell button press
                unsigned long doorbell1Timer;  //Used to keep track of front doorbell ring time
                unsigned long doorbell2Millis;  //Used to keep track of the last back doorbell button press
                unsigned long doorbell2Timer;  //Used to keep track of back doorbell ring time
                byte doorbell1PreviousVal;  //Used to keep track of front doorbell button pressed state
                byte doorbell2PreviousVal;  //Used to keep track of back doorbell button pressed state
                boolean ringDoorbell1;  //Used to initiate the ring front doorbell if statement
                boolean doorbell1Sound; //Used to keep track if the front doorbell should sound or be silent.  Value recieved from doorbell on/off switch
                boolean doorbell1Off = true;  //Used to keep track of front doorbell ring state
                boolean ringDoorbell2;  //Used to initiate the ring front doorbell if statement
                boolean doorbell2Sound; //Used to keep track if the front doorbell should sound or be silent.  Value recieved from doorbell on/off switch
                boolean doorbell2Off = true;  //Used to keep track of front doorbell ring state
                
                void setup()
                {
                  gw.begin(incomingMessage, NODE_ID);
                
                  // Send the sketch version information to the gateway and Controller
                  gw.sendSketchInfo("2 Doorbell Monitor", "1.0");
                
                  // Setup the button and activate internal pull-up
                  pinMode(DOORBELL1_PIN, INPUT_PULLUP);
                  pinMode(DOORBELL2_PIN, INPUT_PULLUP);
                
                  // After setting up the button, setup debouncer
                  debouncer.attach(DOORBELL1_PIN);
                  debouncer.attach(DOORBELL2_PIN);
                  debouncer.interval(5);
                
                  // Register all sensors to gw (they will be created as child devices)
                  gw.present(SWITCH1_CHILD_ID, S_LIGHT);
                  gw.present(DOORBELL1_CHILD_ID, S_MOTION);
                  gw.present(SWITCH2_CHILD_ID, S_LIGHT);
                  gw.present(DOORBELL2_CHILD_ID, S_MOTION);
                
                  // Make sure relays are off when starting up
                  digitalWrite(RELAY1_PIN, RELAY1_OFF);
                  digitalWrite(RELAY2_PIN, RELAY2_OFF);
                  // Then set relay pins in output mode
                  pinMode(RELAY1_PIN, OUTPUT);
                  pinMode(RELAY2_PIN, OUTPUT);
                
                  // Set doorbellSound to last known state (using eeprom storage)
                  doorbell1Sound = gw.loadState(SWITCH1_CHILD_ID);
                  doorbell2Sound = gw.loadState(SWITCH2_CHILD_ID);
                }
                
                void loop()
                {
                  gw.process();
                    unsigned long current1Millis = millis();
                  //Check to see if front doorbell button was pushed.
                  if (current1Millis - doorbell1Millis > doorbellDelay) //used to stop doorbell from being pressed too frequently
                  {
                    debouncer.update();
                    // Read front doorbell button value
                    byte doorbell1Detect = !debouncer.read();//read, then reverse the value so it will send correct trigger state to controller
                
                    if (doorbell1Detect != doorbell1PreviousVal)
                    {
                      //Serial.print("doorbell1Detect Value: ");
                      //Serial.println(doorbell1Detect);
                      if (doorbell1Detect == 1)
                      {
                        ringDoorbell1 = true;
                        doorbell1Timer = current1Millis;
                      }
                      doorbell1Millis = current1Millis;
                      doorbell1PreviousVal = doorbell1Detect;
                    }
                  }
                
                  if (ringDoorbell1)
                  {
                    if (doorbell1Sound)
                    {
                      if (doorbell1Off)
                      {
                        digitalWrite(RELAY1_PIN, RELAY1_ON);
                        //Serial.println("Front Doorbell sounded.");
                        doorbell1Off = false;
                      }
                      else
                      {
                        if (current1Millis - doorbell1Timer > ringTime)
                        {
                          ringDoorbell1 = false;
                          digitalWrite(RELAY1_PIN, RELAY1_OFF);
                          //Serial.println("Front Doorbell off.");
                          doorbell1Off = true;
                        }
                      }
                    }
                  }
                
                //Check to see if back doorbell button was pushed.
                unsigned long current2Millis = millis();
                    if (current2Millis - doorbell2Millis > doorbellDelay) //used to stop doorbell from being pressed too frequently
                  {
                    debouncer.update();
                    // Read back doorbell button value
                    byte doorbell2Detect = !debouncer.read();//read, then reverse the value so it will send correct trigger state to controller
                
                    if (doorbell2Detect != doorbell2PreviousVal)
                    {
                      //Serial.print("doorbell2Detect Value: ");
                      //Serial.println(doorbell2Detect);
                      if (doorbell2Detect == 1)
                      {
                        ringDoorbell2 = true;
                        doorbell2Timer = current2Millis;
                      }
                      doorbell2Millis = current2Millis;
                      doorbell2PreviousVal = doorbell2Detect;
                    }
                  }
                
                  if (ringDoorbell2)
                  {
                    if (doorbell2Sound)
                    {
                      if (doorbell2Off)
                      {
                        digitalWrite(RELAY2_PIN, RELAY2_ON);
                        //Serial.println("Back Doorbell sounded.");
                        doorbell2Off = false;
                      }
                      else
                      {
                        if (current2Millis - doorbell2Timer > ringTime)
                        {
                          ringDoorbell2 = false;
                          digitalWrite(RELAY2_PIN, RELAY2_OFF);
                          //Serial.println("Back Doorbell off.");
                          doorbell2Off = 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
                      doorbell1Sound = message.getBool();
                      // Store state in eeprom
                      gw.saveState(SWITCH1_CHILD_ID, doorbell1Sound);
                
                      // Write some debug info
                      Serial.print("Incoming change for sensor:");
                      Serial.print(message.sensor);
                      Serial.print(", New status: ");
                      Serial.println(message.getBool());
                    }
                    
                  }```
                BulldogLowellB 1 Reply Last reply
                0
                • petewillP petewill

                  @BulldogLowell Haha, I just took the easy way out and ran a 5V line :)

                  @drock1985

                  I built the project around the idea the wife would want something more elaborate than a simple ding sound, but I was wrong lol.

                  Yeah, that's happened to me as well on other projects :)

                  BulldogLowellB Offline
                  BulldogLowellB Offline
                  BulldogLowell
                  Contest Winner
                  wrote on last edited by
                  #26

                  Haha, I just took the easy way out and ran a 5V line

                  @petewill

                  that may be the easy way, but not as fun :(

                  petewillP 1 Reply Last reply
                  0
                  • D drock1985

                    Hi @petewill

                    I finally got the parts in to do the project. I've been working on the code, but I seem to be running into an issue. I have the four devices show up in Domoticz, but I'm not getting any feedback from the sensor. Would you mind looking at the code for me please? This is the first program I have ever worked on, and not much of a programmer mentality yet.

                    /*
                     * 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
                     * 
                     * 2 Door Chime
                     * Version 1.0 - ResentedPoet
                     * DESCRIPTION
                     * Original idea/concept by PeteWill. Modified code to add second actuator (relay)
                     * door chimes with 2 doors. This will allow your home automation system to differentiate
                     * between front and back door. As well, this allows current 2 door chimes to still have
                     * their individual chimes. Pins 3 and 4 are used for door bell 1 and relay/chime 1 
                     * respectively, and digital pins 5 and 6 for door bell 2 and relay/chime 2.
                     */
                    
                    
                    #include <MySensor.h>
                    #include <SPI.h>
                    #include <Bounce2.h>
                    
                    #define NODE_ID AUTO // or set a manual ID in place of AUTO
                    
                    #define DOORBELL1_PIN  3      // Arduino Digital I/O pin number for the doorbell button 
                    #define RELAY1_PIN  4         // Arduino Digital I/O pin number for the relay 
                    #define DOORBELL1_CHILD_ID 0  //ID of the front doorbell
                    #define SWITCH1_CHILD_ID 1    // Id of the switch that will control front doorbell sound
                    #define RELAY1_ON 1
                    #define RELAY1_OFF 0
                    #define DOORBELL2_PIN  5      // Arduino Digital I/O pin number for the doorbell button 
                    #define RELAY2_PIN  6         // Arduino Digital I/O pin number for the relay 
                    #define DOORBELL2_CHILD_ID 2  //ID of the back doorbell
                    #define SWITCH2_CHILD_ID 3    // Id of the switch that will control back doorbell sound
                    #define RELAY2_ON 1
                    #define RELAY2_OFF 0
                    
                    Bounce debouncer = Bounce();
                    
                    MySensor gw;
                    MyMessage switchMsg1(SWITCH1_CHILD_ID, V_LIGHT);
                    MyMessage switchMsg2(SWITCH2_CHILD_ID, V_LIGHT);
                    MyMessage doorbellMsg1(DOORBELL1_CHILD_ID, V_TRIPPED);
                    MyMessage doorbellMsg2(DOORBELL2_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 doorbell1Millis;  //Used to keep track of the last front doorbell button press
                    unsigned long doorbell1Timer;  //Used to keep track of front doorbell ring time
                    unsigned long doorbell2Millis;  //Used to keep track of the last back doorbell button press
                    unsigned long doorbell2Timer;  //Used to keep track of back doorbell ring time
                    byte doorbell1PreviousVal;  //Used to keep track of front doorbell button pressed state
                    byte doorbell2PreviousVal;  //Used to keep track of back doorbell button pressed state
                    boolean ringDoorbell1;  //Used to initiate the ring front doorbell if statement
                    boolean doorbell1Sound; //Used to keep track if the front doorbell should sound or be silent.  Value recieved from doorbell on/off switch
                    boolean doorbell1Off = true;  //Used to keep track of front doorbell ring state
                    boolean ringDoorbell2;  //Used to initiate the ring front doorbell if statement
                    boolean doorbell2Sound; //Used to keep track if the front doorbell should sound or be silent.  Value recieved from doorbell on/off switch
                    boolean doorbell2Off = true;  //Used to keep track of front doorbell ring state
                    
                    void setup()
                    {
                      gw.begin(incomingMessage, NODE_ID);
                    
                      // Send the sketch version information to the gateway and Controller
                      gw.sendSketchInfo("2 Doorbell Monitor", "1.0");
                    
                      // Setup the button and activate internal pull-up
                      pinMode(DOORBELL1_PIN, INPUT_PULLUP);
                      pinMode(DOORBELL2_PIN, INPUT_PULLUP);
                    
                      // After setting up the button, setup debouncer
                      debouncer.attach(DOORBELL1_PIN);
                      debouncer.attach(DOORBELL2_PIN);
                      debouncer.interval(5);
                    
                      // Register all sensors to gw (they will be created as child devices)
                      gw.present(SWITCH1_CHILD_ID, S_LIGHT);
                      gw.present(DOORBELL1_CHILD_ID, S_MOTION);
                      gw.present(SWITCH2_CHILD_ID, S_LIGHT);
                      gw.present(DOORBELL2_CHILD_ID, S_MOTION);
                    
                      // Make sure relays are off when starting up
                      digitalWrite(RELAY1_PIN, RELAY1_OFF);
                      digitalWrite(RELAY2_PIN, RELAY2_OFF);
                      // Then set relay pins in output mode
                      pinMode(RELAY1_PIN, OUTPUT);
                      pinMode(RELAY2_PIN, OUTPUT);
                    
                      // Set doorbellSound to last known state (using eeprom storage)
                      doorbell1Sound = gw.loadState(SWITCH1_CHILD_ID);
                      doorbell2Sound = gw.loadState(SWITCH2_CHILD_ID);
                    }
                    
                    void loop()
                    {
                      gw.process();
                        unsigned long current1Millis = millis();
                      //Check to see if front doorbell button was pushed.
                      if (current1Millis - doorbell1Millis > doorbellDelay) //used to stop doorbell from being pressed too frequently
                      {
                        debouncer.update();
                        // Read front doorbell button value
                        byte doorbell1Detect = !debouncer.read();//read, then reverse the value so it will send correct trigger state to controller
                    
                        if (doorbell1Detect != doorbell1PreviousVal)
                        {
                          //Serial.print("doorbell1Detect Value: ");
                          //Serial.println(doorbell1Detect);
                          if (doorbell1Detect == 1)
                          {
                            ringDoorbell1 = true;
                            doorbell1Timer = current1Millis;
                          }
                          doorbell1Millis = current1Millis;
                          doorbell1PreviousVal = doorbell1Detect;
                        }
                      }
                    
                      if (ringDoorbell1)
                      {
                        if (doorbell1Sound)
                        {
                          if (doorbell1Off)
                          {
                            digitalWrite(RELAY1_PIN, RELAY1_ON);
                            //Serial.println("Front Doorbell sounded.");
                            doorbell1Off = false;
                          }
                          else
                          {
                            if (current1Millis - doorbell1Timer > ringTime)
                            {
                              ringDoorbell1 = false;
                              digitalWrite(RELAY1_PIN, RELAY1_OFF);
                              //Serial.println("Front Doorbell off.");
                              doorbell1Off = true;
                            }
                          }
                        }
                      }
                    
                    //Check to see if back doorbell button was pushed.
                    unsigned long current2Millis = millis();
                        if (current2Millis - doorbell2Millis > doorbellDelay) //used to stop doorbell from being pressed too frequently
                      {
                        debouncer.update();
                        // Read back doorbell button value
                        byte doorbell2Detect = !debouncer.read();//read, then reverse the value so it will send correct trigger state to controller
                    
                        if (doorbell2Detect != doorbell2PreviousVal)
                        {
                          //Serial.print("doorbell2Detect Value: ");
                          //Serial.println(doorbell2Detect);
                          if (doorbell2Detect == 1)
                          {
                            ringDoorbell2 = true;
                            doorbell2Timer = current2Millis;
                          }
                          doorbell2Millis = current2Millis;
                          doorbell2PreviousVal = doorbell2Detect;
                        }
                      }
                    
                      if (ringDoorbell2)
                      {
                        if (doorbell2Sound)
                        {
                          if (doorbell2Off)
                          {
                            digitalWrite(RELAY2_PIN, RELAY2_ON);
                            //Serial.println("Back Doorbell sounded.");
                            doorbell2Off = false;
                          }
                          else
                          {
                            if (current2Millis - doorbell2Timer > ringTime)
                            {
                              ringDoorbell2 = false;
                              digitalWrite(RELAY2_PIN, RELAY2_OFF);
                              //Serial.println("Back Doorbell off.");
                              doorbell2Off = 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
                          doorbell1Sound = message.getBool();
                          // Store state in eeprom
                          gw.saveState(SWITCH1_CHILD_ID, doorbell1Sound);
                    
                          // Write some debug info
                          Serial.print("Incoming change for sensor:");
                          Serial.print(message.sensor);
                          Serial.print(", New status: ");
                          Serial.println(message.getBool());
                        }
                        
                      }```
                    BulldogLowellB Offline
                    BulldogLowellB Offline
                    BulldogLowell
                    Contest Winner
                    wrote on last edited by
                    #27

                    @drock1985

                    I think your code is a little hard to get through, but you need two instances of the Bounce library if you want to manage two buttons:

                      debouncer.attach(DOORBELL1_PIN);
                      debouncer.attach(DOORBELL2_PIN);
                    

                    do this instead:

                    //...
                    Bounce debouncePin1 = Bounce();
                    Bounce debouncePin2 = Bounce();
                    //...
                    void setup()
                    {
                      //...
                      debouncePin1.attach(DOORBELL1_PIN);
                      debouncePin1.interval(5);
                      debouncePin2.attach(DOORBELL2_PIN);
                      debouncePin2.interval(5);
                      //...
                    }
                    

                    and update the state with:

                    debouncerPin1.update();
                    

                    get it?

                    alternatively you could use an array:

                    Bounce debouncer[2] = Bounce();
                    

                    it would make your code a lot easier, but you have to understand arrays and Classes or you will be a little lost.

                    1 Reply Last reply
                    0
                    • BulldogLowellB BulldogLowell

                      Haha, I just took the easy way out and ran a 5V line

                      @petewill

                      that may be the easy way, but not as fun :(

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

                      @BulldogLowell

                      that may be the easy way, but not as fun :(

                      I know huh? It seems my opportunity for fun has been getting less and less these days :( I still need to finish the PhoneyTV project...

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

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        timropp
                        wrote on last edited by
                        #29

                        My mini RBoard just arrived yesterday to do this... too bad I won't have any time to mess with it till probably next weekend. I'll definitely share some pics and results once I get it installed!

                        VeraEdge UI7 with Mysensors ethernet gateway

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          timropp
                          wrote on last edited by
                          #30

                          I did take a look at my doorbell last night. I have a transformer down in the basement that's outputting 16VAC. Then the doorbell upstairs, with no convenient place to get power from. The wires from both the doorbell button and the transformer come to the doorbell "box" on the wall.

                          At first I was looking for a way to convert the 16VAC to 5VDC. Then as I was looking at the space in the doorbell to mount the board, I saw two more wires not connected to anything. They ran 4 conductor wire from the transformer to the bell! Sweet! So now I'll put a 5V source (probably phone charger to USB cable with the end cut off) in the basement, connect that to the other unused pair of wires, and have my power where I need it.

                          Is there any issue with running the 5V DC power and the 16VAC power alongside each other? It's not like either is carrying data, so I don't think there would be...

                          VeraEdge UI7 with Mysensors ethernet gateway

                          1 Reply Last reply
                          0
                          • rvendrameR Offline
                            rvendrameR Offline
                            rvendrame
                            Hero Member
                            wrote on last edited by
                            #31

                            @timropp , If you are following the circuits posted above, the relays should provide complete isolation between 5VDC and 16VAC, so everything fine .

                            Home Assistant / Vera Plus UI7
                            ESP8266 GW + mySensors 2.3.2
                            Alexa / Google Home

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

                              Hi,

                              Just a quick question. I'm trying the original code for the doorbell, and I have it registering in Domoticz just great,. I have two lights, one to turn off the relay and the other, not sure of (thought it would turn on if doorbell was tripped). Anyways, did I miss something or did domoticz register it as the wrong item?

                              Thanks,

                              petewillP 1 Reply Last reply
                              0
                              • D drock1985

                                Hi,

                                Just a quick question. I'm trying the original code for the doorbell, and I have it registering in Domoticz just great,. I have two lights, one to turn off the relay and the other, not sure of (thought it would turn on if doorbell was tripped). Anyways, did I miss something or did domoticz register it as the wrong item?

                                Thanks,

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

                                @drock1985 I have mine registered as a motion sensor. So when the button is pressed it shows tripped. It will only show tripped for one second though so maybe the Domoticz UI isn't updating fast enough?

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

                                D 1 Reply Last reply
                                0
                                • petewillP petewill

                                  @drock1985 I have mine registered as a motion sensor. So when the button is pressed it shows tripped. It will only show tripped for one second though so maybe the Domoticz UI isn't updating fast enough?

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

                                  @petewill

                                  Ah, that very well may be it. I'll investigate that end further. Thanks.

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

                                    @petewill

                                    Been looking into this, not sure what the problem is. I changed over the motion sensor settings in Domoticz so that it would stay on for 5 seconds after being tripped, but it never registers the change. I can turn the chime itself on and off no problem, just no alert.

                                    This is the output from serial monitor in Arduino with the doorbell sensor. The sensor acknowledges the change in switch state (for muting the chime) but doesn't for the action of the button being pushed. Doesn't appear to be a message being sent out either.

                                    send: 7-7-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
                                    send: 7-7-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                                    read: 0-0-7 s=255,c=3,t=6,pt=0,l=1,sg=0:M
                                    sensor started, id=7, parent=0, distance=1
                                    send: 7-7-0-0 s=255,c=3,t=11,pt=0,l=16,sg=0,st=ok:Doorbell Monitor
                                    send: 7-7-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
                                    send: 7-7-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
                                    send: 7-7-0-0 s=0,c=0,t=1,pt=0,l=0,sg=0,st=ok:
                                    read: 0-0-7 s=1,c=1,t=2,pt=0,l=1,sg=0:0
                                    Incoming change for sensor:1, New status: 0
                                    read: 0-0-7 s=1,c=1,t=2,pt=0,l=1,sg=0:1
                                    Incoming change for sensor:1, New status: 1

                                    1 Reply Last reply
                                    0
                                    • D Offline
                                      D Offline
                                      drock1985
                                      wrote on last edited by drock1985
                                      #36
                                      This post is deleted!
                                      1 Reply Last reply
                                      0
                                      • D Offline
                                        D Offline
                                        drock1985
                                        wrote on last edited by
                                        #37

                                        Well, I got it to work. Had to add a gw.send command to the code. The below is for the original 1 door chime that @petewill has created. I have added the code to make this compatible with Domoticz.

                                        /*
                                         * 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
                                         * 
                                         * Version 1.1 - ResentedPoet
                                         * 
                                         * Added gw.send command so that if doorbellDetect variable was active, it would send V_TRIPPED
                                         * to the motion sensor controlling the doorbell. Necessary for Domoticz compatibility
                                         */
                                        
                                        
                                        #include <MySensor.h>
                                        #include <SPI.h>
                                        #include <Bounce2.h>
                                        
                                        #define NODE_ID AUTO // 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);
                                              if (doorbellDetect == 1)
                                              {
                                                ringDoorbell = true;
                                                doorbellTimer = currentMillis;
                                                gw.send(doorbellMsg.set(doorbellDetect?"1":"0"));  // Send tripped value to gw
                                              }
                                              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());
                                            }
                                          }
                                        
                                        1 Reply Last reply
                                        0
                                        • D Offline
                                          D Offline
                                          drock1985
                                          wrote on last edited by
                                          #38

                                          This is the output from Serial Monitor now on the doorchime controller.

                                          req id
                                          send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
                                          read: 0-0-255 s=255,c=3,t=4,pt=0,l=1,sg=0:8
                                          send: 8-8-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
                                          send: 8-8-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                                          read: 0-0-8 s=255,c=3,t=6,pt=0,l=1,sg=0:M
                                          id=8
                                          send: 8-8-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
                                          send: 8-8-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                                          read: 0-0-8 s=255,c=3,t=6,pt=0,l=1,sg=0:M
                                          sensor started, id=8, parent=0, distance=1
                                          send: 8-8-0-0 s=255,c=3,t=11,pt=0,l=16,sg=0,st=ok:Doorbell Monitor
                                          send: 8-8-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
                                          send: 8-8-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
                                          send: 8-8-0-0 s=0,c=0,t=1,pt=0,l=0,sg=0,st=ok:
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
                                          read: 0-0-8 s=1,c=1,t=2,pt=0,l=1,sg=0:1
                                          Incoming change for sensor:1, New status: 1
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
                                          read: 0-0-8 s=1,c=1,t=2,pt=0,l=1,sg=0:0
                                          Incoming change for sensor:1, New status: 0
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
                                          read: 0-0-8 s=1,c=1,t=2,pt=0,l=1,sg=0:1
                                          Incoming change for sensor:1, New status: 1
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
                                          send: 8-8-0-0 s=0,c=1,t=16,pt=0,l=1,sg=0,st=ok:1

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


                                          11

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 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