Lazy door bell sensor hack. this is only sensing when the door bell is actually ringing. This can't make the doorbell ring.
Find a cheap door bell, my hack is using this: 1 by One Wireless Door Chime R/X QH-0031 (Quhwa QH-09D) I bought this one in DK: http://www.jemogfix.dk/doerklokker__6754/traadloes-doerklokke_9025303
They are all made by Quhwa a Chinese company, mechanically they are the same, but sold in Europe during many different names, decided by the import company selling.
You don't need the interposer PCB that I have created and use, it's just convenient for me to re-use, to get NRF24L01+ and Arduino Pro Mini connected together https://www.openhardware.io/view/56/Mys-Interposer-NRFArduino-Pro-Mini
I am measuring the battery voltage, description here: https://www.mysensors.org/build/battery
To ensure that Arduino is not using all battery do the following:
And also I have set BOD off, so Arduino will continue to work below 2,7V. To complete this I use a USBtinyISP to progam this.
avrdude -c usbtiny -p m328p -U efuse:w:0x07:m
I am still using mysesensor ver1.5.4, which my Arduino code is reflecting
//#include <Arduino.h>
#include <SPI.h>
#include <MySensor.h>
#define CHILD_1 3 // childId
MySensor gw;
MyMessage msg(CHILD_1, V_TRIPPED);
#define PRIMARY_BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch
//Define battery max, Min voltage levels
#define MIN_V 1900
#define MAX_V 3200
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
void setup()
{
// use the 1.1 V internal reference
#if defined(__AVR_ATmega2560__)
analogReference(INTERNAL1V1);
#else
analogReference(INTERNAL);
#endif
// Setup the buttons
pinMode(PRIMARY_BUTTON_PIN, INPUT);
Serial.begin(115200);
//Serial.begin(9600);
//delay(500);
// Serial.println(F("Starting"));
gw.begin();
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Door Bell Sensor", "1.0");
// Register a sensors to gw. Use binary light for test purposes.
//gw.present(CHILD_1, S_DOOR);
gw.present(CHILD_1, S_MOTION);
}
void loop()
{
uint8_t value;
//value = digitalRead(PRIMARY_BUTTON_PIN);
//gw.process();
//if (value == 0) {
gw.send(msg.set(1));
Serial.println("ON");
gw.sleep(3000);
gw.send(msg.set(0));
Serial.println("OFF");
//gw.sleep(30000);
//}
// get the battery Voltage
int sensorValue = analogRead(BATTERY_SENSE_PIN);
#ifdef DEBUG
Serial.println(sensorValue);
#endif
// 1M, 470K divider across battery and using internal ADC ref of 1.1V
// Sense point is bypassed with 0.1 uF cap to reduce noise at that point
// ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
// 3.44/1023 = Volts per bit = 0.003363075
// float batteryV = sensorValue * 0.003363075;
// int batteryPcnt = sensorValue / 10;
//bja int batteryPcnt = min(map(readVcc(), MIN_V, MAX_V, 0, 100), 100); // Convert voltage to percentage
int batteryPcnt = min(map(readVcc(), MIN_V, MAX_V, 0, 100), 100); // Convert voltage to percentage
#ifdef DEBUG
Serial.print("Battery Voltage: ");
//Serial.print(batteryV);
//Serial.println(" V");
Serial.print("Battery percent: ");
Serial.print(batteryPcnt);
Serial.println(" %");
#endif
gw.sendBatteryLevel(batteryPcnt);
gw.sleep(500);
gw.sleep(PRIMARY_BUTTON_PIN-2, CHANGE, 0);
}
long readVcc() {
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = _BV(MUX3) | _BV(MUX2);
#else
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Start conversion
while (bit_is_set(ADCSRA,ADSC)); // measuring
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both
long result = (high<<8) | low;
result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
return result; // Vcc in millivolts
}
Qty | Value | Device | Package | Parts | Description | MF | MPN | Aliexpress or Ebay link |
---|---|---|---|---|---|---|---|---|
1 | NRF24L01+ module | Transceiver | ||||||
1 | Arduino Pro Mini | MCU | ||||||
1 | 220kOhm | voltage divider for ring signal | ||||||
1 | 270kOhm | voltage divider for ring signal | ||||||
1 | 470kOhm | voltage divider for battery voltage | ||||||
1 | 1MOhm | voltage divider for battery voltage | ||||||
1 | 0,1uF cap | voltage divider cap stabilizer for battery voltage | ||||||
1 | 4,7uF electrolytic cap | Stabilise NRF voltage | ||||||
3 | dupont wires | to solder on door bell | ||||||
1 | plastic bag | insulation for Arduino/NRF24L01+ | ||||||
1 | rubberband | for mounting Arduino/NRF24L01+ to door bell |
Name | Size | # Downloads |
---|---|---|
mys_doorbell.ino | 3.31 kB | 524 |