Water alarm with notifications

This is a water alarm for my Air Conditioner’s 15 liters water collector canister that is needed to be manually emptied from time to time. Code can also be used as a flooding alarm system. This code checks for water every 30 seconds and turns on a led and a virtual led when water is detected. It also sends a push+email notification every 8 hours as long as water is detected.
Suggestions for improvements are welcome. Enjoy /Stefan @ stockholmviews.com

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

// Your WiFi credentials.
char ssid[] = "fake";
char pass[] = "fake-again";
const int ledPin =  D5; // (WeMos)

BlynkTimer timer;
int sensorData;

void sendAnalog()
  sensorData = analogRead(A0); //reading the sensor on A0
  Blynk.virtualWrite(V4, sensorData); //sending to Blynk
    if (sensorData > 400) {
digitalWrite(ledPin, HIGH);
Blynk.virtualWrite(V5, 255);
    }else {
digitalWrite(ledPin, LOW);
Blynk.virtualWrite(V5, 0); 

void sendNotification()
    if (ledPin != HIGH) {
Blynk.notify("Time to empty the water collector!");
Blynk.email("your@gmail.com", "Time to empty the water collector", "Starting to fill up!");
Blynk.email("another@gmail.com", "Time to empty the water collector", "Starting to fill up!");

void setup()
  // Debug console

  // Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  Blynk.begin(auth, ssid, pass, "IP-address", 8080);
  timer.setInterval(30000L, sendAnalog);
  timer.setInterval(28800000L, sendNotification);
void loop()
  timer.run(); // Initiates BlynkTimer
  1. change spelling to “empty”
  2. I suspect the second email will not be sent. You need to build in a delay between sending mails (to prevent spamming)
1 Like

Somebody can’t spell :rofl::rofl::rofl:



Spelling is one error typing to fast is another matter and I’m probably guilty to both violations .
My excuse is being Swedish :wink:
Spelling corrected I will test the possible spam issue and report back.