Successful DIY Smart Doorbell Conversion

Hi everyone, I just wanted to share my recent success with converting a traditional doorbell into a smart one using Homey. It was a bit of a challenge, but the result is fantastic!

I started by sourcing a NodeMCU ESP8266 module and an optocoupler to safely isolate the doorbell’s electrical circuit. The doorbell itself was a simple mechanical one, so I knew I needed to create a way for it to communicate with my Homey hub.

After some research, I found that Athom’s documentation provided a solid foundation. I set up the NodeMCU with the necessary code, ensuring it could detect when the doorbell was pressed and send a notification to Homey. The key was getting the GPIO pins correctly configured and ensuring the optocoupler was properly integrated to prevent any voltage spikes from damaging the ESP module.

Once the hardware was set up, I moved on to the software side. I created a new flow in Homey where the doorbell press triggers a notification. This involved setting up a boolean sensor and linking it to the notification action. Testing was crucial here—I wanted to make sure that every press of the doorbell reliably sent a notification without any false positives or delays.

After a few days of tweaking and testing, everything worked perfectly! Now, whenever someone presses the doorbell, I get a notification on my phone, and the ringer inside the house sounds as usual. It’s a great way to keep the traditional functionality while adding smart capabilities.

I’d like to thank the community for the resources and support that made this project possible. If anyone is considering a similar DIY, I highly recommend checking out the HomeyDuino documentation and experimenting with NodeMCU. It’s a rewarding project that combines classic hardware with modern smart tech!

Here’s the code I used for reference (please note I’m not a developer, so use at your own risk):

cpp
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Homey.h>

int sensor = 4;
int Status = 5;

void setup() {
Serial.begin(115200);
Homey.begin(“Doorbell”);
Homey.setClass(“socket”);
Homey.addCapability(“onoff”, onoffCb);
pinMode(sensor, INPUT);
pinMode(Status, OUTPUT);
}

void loop() {
long state = digitalRead(sensor);
if (state == LOW) {
digitalWrite(Status, HIGH);
Homey.setCapabilityValue(“_onoff”, true);
Homey.trigger(“_onoff”, true);
delay(1200);
digitalWrite(Status, LOW);
Homey.setCapabilityValue(“_onoff”, false);
}
}

void onoffCb() {
bool value = Homey.value.toInt();
setOutput(value);
}

void setOutput(bool value) {
digitalWrite(Status, value);
Homey.setCapabilityValue(“_onoff”, value);
}

If you have any questions or suggestions, feel free to reach out. Happy tinkering! :rocket: