Troubleshooting Smart Doorbell Integration with Homey

Hi everyone, I’m reaching out to share my experience and seek advice on integrating a traditional doorbell with Homey V2.0x. I’ve been working on this project for almost two weeks and while it’s functional, I’m encountering some unexpected behaviors that I’d like to address.

Project Overview

I’ve successfully converted a standard doorbell into a smart doorbell using a NodeMCU ESP8266 and HomeyDuino. The setup involves:

  • A NodeMCU ESP8266 microcontroller
  • A 5V 700mA power adapter
  • A 9V 1A AC adapter for the doorbell
  • An optocoupler to isolate the 5V relay
  • Homey V2.0x software

The doorbell sends notifications to my phone via Homey when activated and includes a ringer for in-house alerts. It’s been running smoothly for the most part, but I’ve noticed a few quirks.

Challenges Faced

  1. Relay Activation Delay

    • There’s a slight delay (~2 seconds) between pressing the doorbell and the relay activating. I’ve tried adjusting the delay in the code, but this seems to affect the stability of the connection. Any suggestions on optimizing this?
  2. Notification Persistence

    • Once the doorbell is pressed, the notification is sent, but it doesn’t automatically clear when the ringing stops. Is there a way to have the notification self-dismiss after a set period or when the doorbell is no longer active?
  3. Power Management Issues

    • Occasionally, the NodeMCU seems to reset, causing the doorbell to stop working temporarily. This happens more frequently during extended periods of inactivity. I’ve ensured all connections are secure, but I’m wondering if there’s a better power management setup I could implement.

Code Snippets and Setup

Here’s a brief overview of the code I’m using:
javascript
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Homey.h>

int Status = 5; // Relay control pin
int sensor = 4; // Doorbell button pin

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

void loop() {
wifi();
Homey.loop();
long state = digitalRead(sensor);
if (state == LOW) {
digitalWrite(Status, HIGH);
delay(10);
Homey.setCapabilityValue(“_onoff”, true);
Homey.trigger(“_onoff”, true);
Serial.println(“Doorbell activated!”);
delay(1200);
} else {
digitalWrite(Status, LOW);
Homey.setCapabilityValue(“_onoff”, false);
}
}

Seeking Advice

I’d love to hear from anyone who’s worked on similar projects or has insights into these issues. Specific questions include:

  • How can I reduce the relay activation delay without compromising stability?
  • Is there a way to make the notification self-dismiss after a certain period?
  • What steps can I take to prevent the NodeMCU from resetting unexpectedly?

Any tips or alternative approaches would be greatly appreciated! I’m eager to refine this setup and make it as reliable as possible.

Thanks in advance for your help!

Best regards,
[Your Name]