Usage Example for Arduino-Wireless Doorbell Simulation

This article presents a practical guide for simulating a wireless doorbell using Arduino, detailing the hardware setup, connection instructions, and sample code to effectively demonstrate RF signal transmission and sensor interaction.

  • This sample is mainly used for demonstration: the transmitter is powered by a battery and the sensor's signal is sent out through RF signal, which simulates the function of a wireless doorbell
  • Take Arduino as an example, the other main controllers use the same principle, only need to connect to the corresponding digital port.
  • Take inching mode in the receiver as an example, the principles of other modes are the same.

Hardware Preparation

Other sensor application scenarios

  • Crash sensor: position detection-automatic position recovery in scenarios where the closed container is not easy to wire
  • Vibration sensor: vibration detection-door opening and closing vibration
  • Infrared photoelectric switch: counting detection-number of people/workpiece counting
  • Other digital sensors(Play with your imagination)

Note: The sensor can be selected arbitrarily, as long as it is digital. The button and motion sensor are used here as a function demonstration to simulate the function of a wireless doorbell.

Software Preparation

Connection

The transmitting end:

** Receiving end: **

Sample code

#define Button_D2 2//Arduino
#define Button_D3 3//Arduino
//#define Button_D2 D2 //ESP32
//#define Button_D3 D3 //ESP32

void setup() {
    Serial.begin(115200);
    pinMode(Button_D2, INPUT);
    pinMode(Button_D3, INPUT);
}
void loop() {
    if (((digitalRead(Button_D2)==1) && (digitalRead(Button_D3)==1))) {
        Serial.println("Someone presses the doorbell");
        delay(3000);
    }
    else if (((digitalRead(Button_D2)==0) && (digitalRead(Button_D3)==1))) {
        Serial.println("Someone passes by but does not press the doorbell");
        delay(100);
    }
    else if (((digitalRead(Button_D2)==1) && (digitalRead(Button_D3)==0))) {
        Serial.println("Someone has waited for a while and then press the doorbell");
        delay(3000);
    }
    delay(100);
}

Result

**When someone passes by and presses the button, the serial port prints "Someone presses the doorbell"; when someone passes by but does not press the doorbell, the serial port prints "Someone passes by but does not press the doorbell"; when someone comes to the door and stands for a while Press the doorbell, and the serial port prints "Someone has waited for a while and then press the doorbell". **

Was this article helpful?

TOP