๐ซ A retrofitted wired audio doorbell with added WiFi connectivity ๐
This example uses minimal code and hardware components to demonstrate the doorbell function.
The ESP32-C3 is in deep sleep mode most of the time, consuming very little power. When the push button is pressed, the ESP32-C3 wakes up, sounds the bell, and goes back to sleep.
Initially, the doorbell was vibrating and not sounding. The 3V3 power supply was used from the output of the deb board, which was not sufficient to drive the bell. The 3V3 and GND was connected to the power supply. Then connected to the doorbell directly, and the bell started to sound.
If your doorbell speaker is vibrating but not producing sound, here are some potential reasons:
// #define LED 3 // for the PCB
#define LED LED_BUILTIN // for the breadboard with PCB
#define BELL_PIN 7
#define WAKEUP_INTERRUPT_PIN 4
RTC_DATA_ATTR int bootCount = 0;
void setup() {
++bootCount;
Serial.begin(115200);
Serial.println("Boot number: " + String(bootCount));
// ring the bell
Serial.println("Ringing the bell");
pinMode(BELL_PIN, OUTPUT);
digitalWrite(BELL_PIN, HIGH);
delay(1000);
digitalWrite(BELL_PIN, LOW);
// blink the LED 10 times to indicate that the device is awake
pinMode(LED, OUTPUT);
for (int i = 0; i < 10; ++i) {
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(LED, LOW);
delay(1000);
}
// go to deep sleep
Serial.println("Going to deep sleep now");
esp_deep_sleep_enable_gpio_wakeup(1 << WAKEUP_INTERRUPT_PIN,
ESP_GPIO_WAKEUP_GPIO_HIGH);
esp_deep_sleep_start();
}
void loop() { }
# Uncomment for PCB
BOARD?=esp32:esp32:esp32c3:CDCOnBoot=cdc
PORT?=/dev/cu.usbmodem1410*
# Uncomment for breadboard with PCB
# BOARD?=esp32:esp32:esp32c3
# PORT?=/dev/cu.SLAB_USBtoUART*
BUILD=build
.PHONY: default lint compile flash clean
default: lint compile flash clean
lint:
cpplint --extensions=ino --filter=-legal/copyright,-runtime/int *.ino
compile: clean lint
arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./
flash:
arduino-cli upload --fqbn $(BOARD) --port $(PORT) --input-dir $(BUILD)
clean:
rm -rf build