How To - Doorbell Automation Hack
-
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.
-
@BulldogLowell Haha, I just took the easy way out and ran a 5V line :)
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 :)
-
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.
@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.
-
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()); } }``` -
@BulldogLowell Haha, I just took the easy way out and ran a 5V line :)
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 :)
Haha, I just took the easy way out and ran a 5V line
that may be the easy way, but not as fun :(
-
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()); } }```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.
-
Haha, I just took the easy way out and ran a 5V line
that may be the easy way, but not as fun :(
-
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...
-
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,
-
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,
-
@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?
-
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 -
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()); } } -
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 -
So got my doorbell up and working. Here's the details: I used the mini RBoard and it's working out great.

I soldered the cap directly onto the nrf board. Unfortunately, that board overhangs the A0 connections on the rboard (there's 2 pins there, one is the A0 pin and one is a ground). Thankfully, it only ACTUALLY covered the ground, so it was easy to work around. The brown wire in the photo is the wire I have connected to the A0 pin. The green wire is a temp wire I was connecting to the ground in the serial connections.
In the doorbell, I cut away one of the panels over one of the resonant chambers since I saw that the module would fit in there perfectly. I then wired it up and tucked it away. I did lose a little volume since the chamber is filled rather than resonating, but it's worth it to have the doorbell notifying my Vera system. That can flash lights and so forth to notify us other ways - we couldn't usually hear the doorbell when downstairs anyway.

Code wise, I used the original code above with just a couple minor changes. I set the doorbell_pin to A0, the relay_pin to 4, and the node_ID to auto. I also set it to act as a repeater since it's hardwired to power. Now that I have it working, I wish I'd changed the ringTime to a lower value since 7/10 of a second is way longer than the doorbell normally takes between the two notes, but it's not a big deal. Not worth pulling the board out, disconnecting it, reprogramming it, and reinstalling everything :-)
-
My wiring:
I discovered that they ran 4 conductor wire from the transformer in the basement to this location. So I plugged a phone charger in near the transformer, cut the end off a USB cable, and connected the 5V and gnd wires from that USB cable to the spare 2 wires in the cable. So then there's 6 wires coming into the doorbell as shown here: 2 for 16VAC from the transformer, 2 for 5VDC from the phone charger, and 2 from the doorbell button. I then connected the 5V pair to the top pair of screw terminals in the photo on the rboard. They're the blue and green wires. The white wire in the top terminal is one side of the button, connecting to ground there. The second side of the button is the red wire going into the grey wire nut. The brown wire coming out of the nut connects to the A0 pin on the board. Finally, the 2 16VAC wires are red and white. The red goes over to the right terminal on the plunger mechanism. The white goes to the common terminal on the rboard's relay connections. Finally, a black wire connects the NO from the relay to the other side of the plunger.
Hopefully that was all clear for anyone wanting to wire up their own!
-
Hello all,
I'm trying to hook this doorbell sensor up, what I've found is that when I connect it, I must connect it to NC. The downside is that when I reset the Arduino, the doorbell keeps ringing until pin4 is pulled up. How can I change that in the sketch?
Also I can ring it once, it rings and then it stops working. Connection to the gateway is lost and it won't ring either.
been trying to fix it for 3 days now, but I can't seem to figure out what I've done wrong.
Hooked up pin 4 to the input pin of the relay. The relay is directly powered by 5v coming from a usb hub with 2A.
The Arduino is powered using the same 5V, with a regulator to the radio to give it 3.3V. Connected a 4.7uF cap directly on the radio.
When I reset the arduino this comes to the gateway:0;0;3;0;9;read: 16-16-0 s=255,c=0,t=17,pt=0,l=3,sg=0:1.5 0;0;3;0;9;read: 16-16-0 s=255,c=3,t=11,pt=0,l=16,sg=0:Doorbell Monito 0;0;3;0;9;read: 16-16-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0 0;0;3;0;9;read: 16-16-0 s=1,c=0,t=3,pt=0,l=0,sg=0: 0;0;3;0;9;read: 16-16-0 s=0,c=0,t=1,pt=0,l=0,sg=0: 0;0;3;0;9;read: 16-16-255 s=255,c=3,t=7,pt=0,l=0,sg=0: 0;0;3;0;9;send: 0-0-16-16 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0I can connect perfectly to the gateway using MyMQTT on Android so I think it is failing on the side of the doorbell any help would be greatly appreciated!