I use the following sketch to test if the doorbell speaker reacts on the signal I found. It turned out that it works better when I adjusted the timings a little bit. That’s why you won’t find 520 microseconds, but 417 microseconds in line 29 of the code.
/* DoorbellSender.ino - Sends signal to Grundig wireless doorbell (model QH-831A)
when push button is pressed.
Creative Commons Attribution-ShareAlike 3.0 license
Original: June 2012 @ Rayshobby.net
Modified: July 2013 @ crutzen.eu
Connect data pin of RF sender to digital pin 3 of the Arduino.
Connect push button to digital pin 2 of the Arduino.
The signal exists of 24 bits.
1 means: long ON followed by short OFF
0 means: short ON followed by long OFF
__ _____________ _____ __
| | | | | |
|_____________________| |_____| |____________|
| 15846us | 1251 | 417 | 417 | 1251 |
| | | | | |
|<--------Sync------->|<--------1------->|<--------0------->|
To detect the delay values for your device, read the instructions at https://blog.crutzen.eu
*/
#define BUTTON_PIN 2
#define RF_DATA_PIN 3
#define SHORT_DELAY 417
#define LONG_DELAY (3*SHORT_DELAY)
#define TOTAL_DELAY (SHORT_DELAY + LONG_DELAY)
#define SYNC_DELAY (38*SHORT_DELAY)
void chime() {
unsigned long signal = 0b010111110110001000001000;
for (unsigned char i=0; i<30; i++) { // repeat signal 30 times
for (unsigned char k=0; k<24; k++) {
unsigned long d = ((bitRead(signal, 23-k)) == 1 ? LONG_DELAY : SHORT_DELAY);
digitalWrite(RF_DATA_PIN, HIGH);
delayMicroseconds(d);
digitalWrite(RF_DATA_PIN, LOW);
delayMicroseconds(TOTAL_DELAY - d);
}
delayMicroseconds(SYNC_DELAY);
}
}
void setup() {
pinMode(RF_DATA_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT);
//chime();
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW) {
chime();
delay(1000);
}
}
Source:
Geef een reactie