allart
Published © GPL3+

Doorbell Battery Warning

This hack monitors the doorbell battery voltage. It makes a tick when it's time to recharge or replace the batteries.

IntermediateWork in progress1 hour1,057
Doorbell Battery Warning

Things used in this project

Hardware components

ATtiny85
Microchip ATtiny85
×1
Wemos D1 R2
×1
Resistor 27kΩ
×1
Resistor 47kΩ
×1
Buzzer
Buzzer
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

measure voltage

3AA batteries (in series) in doorbell are connected to ground (-) and voltage divider. This makes input voltage below 3.2V (max 3.2V for Wemos). RST - D0 connection is to wake up Wemos after deep sleep. Wemos converts input to real value and uploads to thingspeak. Cycle time is 30 minutes.

Code

Monitor minimum voltage level

Arduino
Measure voltage with Wemos, send value to Thingspeak, voltage divider, deep sleep, 3.2V input, RST-D0, test 20 s, 30 min use.
#include <ESP8266WiFi.h>

// replace with your channels thingspeak API key and your SSID and password
String apiKey = "XXXXXAPIKEYXXXXX";
const char* ssid = "xxssidxx";
const char* password = "xxpaswdxx";
const char* server = "api.thingspeak.com";

String VoltageMsg;
float sensorVolt;
int sensorValue;
const int sleepTimeM = 30; //minutes

WiFiClient client;

void setup() 
{
  Serial.begin(115200);
  delay(10);
  
  // connecting to wifi
  WiFi.begin(ssid, password);
  
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) 
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  // connected
}
 
void loop() 
{
//////////////////////////////// read and convert voltage value
  //measure value on A0
  sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  // map to analog value
  sensorVolt = sensorValue * 5.77 / 1023;
  Serial.println(sensorVolt);
  VoltageMsg = "The voltage is : ";
  VoltageMsg += sensorVolt;

  if (client.connect(server,80)) {
    String postStr = apiKey;
    postStr +="&field1=";
    postStr += sensorVolt;
    postStr += "\r\n\r\n";
    
    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(postStr.length());
    client.print("\n\n");
    client.print(postStr);
    
    Serial.println(VoltageMsg);
    Serial.println("Sending data to Thingspeak");
  }
  client.stop();
  
  Serial.println("Waiting 30 minutes");

  ESP.deepSleep(sleepTimeM*60000000, WAKE_RF_DEFAULT); // Sleep for sleepTimeM minutes
}

Credits

allart

allart

0 projects • 0 followers

Comments