No I didn’t reach the limit. Please review my Code Snippet.
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <NewPing.h>
#define TRIGGER_PIN D6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN D7 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 332
#define PING_INTERVAL 200 // Milliseconds between pings.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
//Receiver
//char auth[] = "********";
//Water Tank 2
char auth[] = "********";
//Water Tank 3
//char auth[] = "********";
//Water Tank 1
//char auth[] = "********";
//WidgetLCD lcd(V0);
SimpleTimer timer;
WidgetBridge bridge1(V1);
BLYNK_CONNECTED() {
// Place the AuthToken of the second hardware here
bridge1.setAuthToken("********");
}
void setup()
{
Serial.begin(9600);
delay(10);
Blynk.begin(auth, "SSID", "pwd");
delay(10);
Blynk.email("pavitar@"********".com","Water Tank #Pilot Online","Water Tank is online.");
timer.setInterval(1000L, ultra);
}
void ultra()
{
unsigned int uS = sonar.ping();
int level = (uS / US_ROUNDTRIP_CM);
int totalheight = 312 - 20;
int netlevel = level - 20;
long tankemptylevel = (((float)netlevel / (float)totalheight) * 100);
long tank_fulllevel_Percentage = 100 - tankemptylevel;
// Debug
// Blynk.virtualWrite(V1,level);
// Blynk.virtualWrite(V2,totalheight);
// Blynk.virtualWrite(V3,netlevel);
// Blynk.virtualWrite(V4,tankemptylevel);
// Blynk.virtualWrite(V5,tank_fulllevel_Percentage);
Blynk.virtualWrite(V1,tank_fulllevel_Percentage);
Blynk.virtualWrite(V2, 312 - netlevel);
//Blynk.virtualWrite(V3, pTotalheight);
int brightness = 20;
if(tank_fulllevel_Percentage <= 15){ //0 - 15%
bridge1.analogWrite( 2, brightness); //RED
bridge1.analogWrite(13, 0); //RED
bridge1.analogWrite( 0, 0); //BLUE
bridge1.analogWrite(12, 0); //BLUE
bridge1.analogWrite( 4, 0); //GREEN
bridge1.analogWrite(14, 0); //GREEN
Blynk.email("pavitar@"********".com","Water Tank #Pilot Status Alert","Water Tank is almost empty - At "+(String)tank_fulllevel_Percentage+"%.Please fill it asap.");
Blynk.email("vishwas@"********".com","Water Tank #Pilot Status Alert","Water Tank is almost empty - At "+(String)tank_fulllevel_Percentage+"%.Please fill it asap. ");
}else if(tank_fulllevel_Percentage <= 30){ //16 - 30%
bridge1.analogWrite( 2, brightness); //RED
bridge1.analogWrite(13, brightness); //RED
bridge1.analogWrite( 0, 0); //BLUE
bridge1.analogWrite(12, 0); //BLUE
bridge1.analogWrite( 4, 0); //GREEN
bridge1.analogWrite(14, 0); //GREEN
}else if(tank_fulllevel_Percentage <= 50){ //31 - 50%
bridge1.analogWrite( 2, brightness); //RED
bridge1.analogWrite(13, brightness); //RED
bridge1.analogWrite( 0, 30); //BLUE
bridge1.analogWrite(12, 0); //BLUE
bridge1.analogWrite( 4, 0); //GREEN
bridge1.analogWrite(14, 0); //GREEN
}else if(tank_fulllevel_Percentage <= 70){ //51 - 70%
bridge1.analogWrite( 2, brightness); //RED
bridge1.analogWrite(13, brightness); //RED
bridge1.analogWrite( 0, 30); //BLUE
bridge1.analogWrite(12, 30); //BLUE
bridge1.analogWrite( 4, 0); //GREEN
bridge1.analogWrite(14, 0); //GREEN
}else if(tank_fulllevel_Percentage <= 90){ //71 - 90%
bridge1.analogWrite( 2, brightness); //RED
bridge1.analogWrite(13, brightness); //RED
bridge1.analogWrite( 0, 30); //BLUE
bridge1.analogWrite(12, 30); //BLUE
bridge1.analogWrite( 4, 100); //GREEN
bridge1.analogWrite(14, 0); //GREEN
}else if(tank_fulllevel_Percentage > 91){ //91 - 100%
bridge1.analogWrite( 2, brightness); //RED
bridge1.analogWrite(13, brightness); //RED
bridge1.analogWrite( 0, 30); //BLUE
bridge1.analogWrite(12, 30); //BLUE
bridge1.analogWrite( 4, 100); //GREEN
bridge1.analogWrite(14, 100); //GREEN
Blynk.email("pavitar@"********".com","Water Tank #Pilot Status Alert","Water Tank is almost full - At "+(String)tank_fulllevel_Percentage+"%.Please stop filling to avoid overflow.");
Blynk.email("vishwas@"********".com","Water Tank #Pilot Status Alert","Water Tank is almost full - At "+(String)tank_fulllevel_Percentage+"%.Please stop filling to avoid overflow. ");
}
//Blynk.setProperty(V1,"label", "Percentage");
//Blynk.setProperty(V1,"color", "#D3435C");
}
void loop()
{
Blynk.run();
timer.run();
}