Do you want a quick, easy, cheap RF remote control for your Raspberry Pi projects? Well, look no further than the front door! As you've probably got a half-duplex RF setup you've never considered using in a project before. Try this simple hack of a cheap wireless doorbell kit.
It easily works on either a Raspberry Pi or an Arduino for wireless control via the GPIO pins. It is a great way to give your project a remote control if you only require one button!
This project is a simple hack of a cheap wireless doorbell kit, with examples working on an Arduino or a Raspberry Pi. The 433MHz wireless remote control is great for outdoor applications and will work even if there are obstructions between the transmitter and the receiver.
Hardware
- HPM Wireless Doorbell Kit model D642/01 available from Bunnings Warehouse
Getting the Doorbell ready to interface with a Raspberry Pi or Arduino
1. Remove the battery cover from the back of the speaker unit to reveal the battery holder
2. There is one screw to remove from here, then you should be able to open up the speaker unit
3. Remove the 2 screws holding the circuit board in place and flip the board over to reveal the receiver unit
4. The receiver unit is labeled RL-3952RX. From testing the receiver using a multimeter, these are what I identified the pinouts to be:
5. Do a quick functionality test of the doorbell (flash an LED):
- Connect either signal pin to a breadboard rail via an alligator clip.
- Insert a 220-ohm resistor where the alligator clip wire is inserted and place the other end of the resistor on another rail.
- Insert the anode end of the LED into the rail and the cathode end into the GND rail of the breadboard
- Connect a GND pin of the receiver unit to the GND rail of the breadboard
- Insert 2 x AA batteries into the battery holder.
When you press the button on the doorbell, you should see the LED light up and then go out (as well as hearing the doorbell ring). The LED will be flickering. This is because the signal is pulsed.
Interfacing with a Raspberry Pi
To connect the remote to the Pi:
- Put jumper wires on GPIO 21, GPIO 20, and a GND pin on the Raspberry Pi.
- Plug the GND jumper wire into the GND rail of the breadboard.
- Connect either GND pin on the receiver module to a pin sticking out of a hole in the breadboard ground rail (use alligator clip wire).
- Connect the other alligator clip wire to a signal pin on the receiver, then onto the pin end of the jumper wire running to GPIO 21 on the Pi.
- Connect the wire on GPIO 20 to a slot in the breadboard, connect the 220-ohm resistor to this slot then connect the other end of the resistor to another empty rail.
- Insert the anode end (the longer wire) of the LED into the breadboard rail where the resistor ends and connect the cathode (short wire) to the GND rail on the breadboard.
For this example, we’re going to use the doorbell button to toggle the LED on and off. The following is the Python script used for this project:
from gpiozero import LED, Button import time led = LED(20) remote = Button(21, pull_up = False) # By default pull_up is True light_on = False # Boolean to keep track of light state while True: if remote.is_pressed: if light_on == False: light_on = True led.on() time.sleep(2.0) # Prevents false triggers elif light_on == True: light_on = False led.off() time.sleep(2.0) # Prevents false triggers time.sleep(0.1)
Run the script and press the button on the doorbell. If all goes well, the LED will light up and you will hear the doorbell chime. Press the button again after 2 seconds and the LED should switch off (yes, the doorbell will ring again).
Interfacing with an Arduino
Here, I’m using the USB cable connected to my PC to power the Arduino, but you can also run the Arduino of a different power source once the sketch is uploaded if you wish.
For the Arduino project:
- Insert 2 x AA batteries into the doorbell speaker unit.
- Connect either signal pin on the receiver to A0 on the Arduino, use alligator clip wire and pin/loose wire.
- Connect either GND pin on the receiver to a GND pin on the Arduino (alligator clip and a metal pin/loose wire).
- Optional: insert the anode of a 5mm LED into pin 13, the cathode into the adjacent GND pin.
- Copy the following sketch into the Arduino IDE and upload it to your Arduino board:
const int remote = A0; const int ledPin = 13; int lightState = LOW; void setup() { pinMode(remote, INPUT); pinMode(ledPin, OUTPUT); }
void loop() { int reading = analogRead(remote); if (reading >= 505) // Should be somewhere around 2.3 volts when doorbell button is pressed. { if (lightState == LOW)
{ lightState = HIGH; digitalWrite(ledPin, HIGH); delay(2500); // 2 1/2 second delay. Needed because the signal flickers on/off for close to 2 seconds. } // Any shorter a delay and you will get false triggers. else { lightState = LOW; digitalWrite(ledPin, LOW); delay(2500); } }
}
Note that you need to use analogRead()
instead of digitalRead()
to get the input. This is because the Arduino runs on 5-volt logic and the receiver runs on 3.3-volt logic. The digitalRead()
function on Arduino interprets voltages greater than 2.5 volts to be ‘1’ and less than 2.5 volts to be ‘0’.
With analogRead()
you can measure the incoming voltage and set where you want the trigger level to be. The scale for analogRead()
is 0 to 1023… 0 obviously represents 0 volts, 1023 represents 5 volts.
Therefore, a value of 512 is 2.5 volts (512/1024 x 5).
With a little experimenting, I found a value of 505 for the reading was a good measure so the LED will toggle on and off correctly.
Once the sketch is uploaded, press the button on the doorbell and the LED should light up (the doorbell will ring). After 2 seconds, press the doorbell button again and the LED should switch off (yes, the doorbell will ring again, feel free to remove the speaker if necessary)
If you wish to use the receiver in one of your own projects, you will need to de-solder the 6 pins that are circled in red.
Now you have a 433MHz transmitter/receiver you can use for your projects! Remember to attach a wire to the antenna pin when you do, the wire on the speaker circuit board measured 165mm long.