this is a project to monitor the on off cycles of when the sump pump operates as well as monitor the temperature and humidity of the closet in the basement where it is
interesting… can you tell us more about the circuit shown in the pictures?
I assume it is for detecting the pump motor, which is also presumably plugged into that power socket.
Yes, please tell us more. I have a sump pump and always wanted to do this. How are you sensing the on/off of the pump. I have a current sensor salvaged from a wattage monitor (like a clamp on amp meter) that I thought it could adapt it to sense the current draw when the pump is on but haven’t really looked into it.
i have 3 diodes in series and another 3 diodes in series in parallel to that but going the other way which creates a small voltage drop… that voltage drop powers the led in a opto coupler and that on / off is sensed by the esp8622
Just use a optocoulper with 47K 2W resistor on pin one and two (anode and cathode) . Use a 1K current limiting resistor on collector/emitter depending upon which pin you are using on esp8288 !! Reverse the connections if it wants to be a pull up or pull down type ! Google for more info and circuits.
Using an optocoupler with resistor is best !! Using huge diodes will only add cost and makes things bulkier!
/*https://community.blynk.cc/t/doubts-current-sensor-acs712-30a-nodemcu-esp8266/1617/25 */
const int Blue_LED = 2; //D4
bool Connected2Blynk = false;
#define BLYNK_PRINT Serial
#define TRIGGER_PIN 0
#define DHTPIN 4 // Digital pin connected to the DHT sensor
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
char auth[] = "762a7507b3864sdfsdfsdff0cd50d";// auth code for app c
#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;
//char ssid[] = "ssid here";
//char pass[] = "psk here";
WidgetLED led1(V8);
BlynkTimer timer;
void sendSensor()
{
// Delay between measurements.
// delay(delayMS);
float fahrenheittemp = 70;
// Get temperature event and print its value.
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println(F("Error reading temperature!"));
}
else {
float celsius = event.temperature;
float fahrenheit = (celsius * 1.8) + 32;
fahrenheittemp = fahrenheit;
Serial.print(F("Temperature: "));
// Serial.print(event.temperature);
Serial.print(fahrenheit);
Blynk.virtualWrite(V6, fahrenheit);
}
// Get humidity event and print its value.
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println(F("Error reading humidity!"));
}
else {
Serial.print(F(" Humidity: "));
Serial.print(event.relative_humidity);
Serial.println(F("%"));
Blynk.virtualWrite(V5, (event.relative_humidity));
}
if(fahrenheittemp > 100){
Blynk.email("kimbrec@cdw.com", "ESP8266 Alert", "Temperature over 100!!");
Blynk.notify("ESP8266 Alert - Temperature over 100F!");
}
}
//########################################
void sendWifi() {
int wifisignal = WiFi.RSSI();
Blynk.virtualWrite(V10, wifisignal);
}
//########################################
void CheckConnection(){
Connected2Blynk = Blynk.connected();
if(!Connected2Blynk){
Serial.println("Not connected to Blynk server");
Blynk.connect(3333); // timeout set to 10 seconds and then continue without Blynk
}
else{
Serial.println("Connected to Blynk server");
}
}
//########################################
void getcurrent(){
pinMode(D1, INPUT_PULLUP);
WidgetLED led1(V8);
float result; //value read from the sensor
int readValue; //value read from the sensor
bool pumpon;
// while((millis()-start_time) < 500) //sample for 1 Sec
{
readValue = digitalRead (D1);
// see if you have a new maxValue
if (readValue < 1)
{
/*record the maximum sensor value*/
pumpon = true;
led1.on();
}
if (readValue > 0)
{
/*record the maximum sensor value*/
pumpon = false;
led1.off();
}
}
Blynk.virtualWrite(V9, pumpon);
Blynk.virtualWrite(V7, result);
}
//########################################
void setup()
{
// pinMode(Wlan_Setup, INPUT);
pinMode(Blue_LED, OUTPUT);
Serial.begin(9600);
void wifisetup();
WiFi.begin(WiFi.SSID().c_str(), WiFi.psk().c_str());
delay(1000);
Serial.println("");
Serial.println("####################");
Serial.println("WiFi connected");
Serial.println("controller IP address: ");
Serial.println(WiFi.localIP());
Serial.println("controller WLAN: ");
Serial.println(WiFi.SSID());
Serial.println("controller Signal Strength: ");
Serial.println(WiFi.RSSI());
Serial.println("controller set PSK: ");
if ( digitalRead(TRIGGER_PIN) == LOW ) {
WiFiManager wifiManager;
//reset settings - for testing
wifiManager.resetSettings();
Serial.println("WiFi settings have been cleared!!!!!!");
digitalWrite(Blue_LED,0);
//sets timeout until configuration portal gets turned off
//useful to make it all retry or go to sleep
//in seconds
//wifiManager.setTimeout(120);
//WITHOUT THIS THE AP DOES NOT SEEM TO WORK PROPERLY WITH SDK 1.5 , update to at least 1.5.1
//WiFi.mode(WIFI_STA);
if (!wifiManager.startConfigPortal("SumpPumpMonitor")) {
Serial.println("failed to connect and hit timeout");
delay(3000);
//reset and try again, or maybe put it to deep sleep
ESP.reset();
delay(5000);
}
//if you get here you have connected to the WiFi
Serial.println("connected...Meow Meow Meow :)");
}
Serial.println(WiFi.psk());
Serial.println("####################");
delay(1000);
// Blynk.begin(auth, ssid, pass);
Blynk.begin(auth, WiFi.SSID().c_str(), WiFi.psk().c_str());
Blynk.config(auth);
Blynk.connect(3333);
if (Blynk.connect() == false) {
// Wait until connected
digitalWrite(Blue_LED,0);
}
else{
digitalWrite(Blue_LED,1);
}
Serial.println("Connected to Blynk server");
timer.setInterval(11000L, CheckConnection); // check if still connected every 11 seconds
#define TRIGGER_PIN 0
pinMode(TRIGGER_PIN, INPUT);
Serial.begin(9600);
// Initialize device.
dht.begin();
Serial.println(F("DHTxx Unified Sensor Example"));
// Print temperature sensor details.
sensor_t sensor;
dht.temperature().getSensor(&sensor);
Serial.println(F("------------------------------------"));
Serial.println(F("Temperature Sensor"));
Serial.print (F("Sensor Type: ")); Serial.println(sensor.name);
Serial.print (F("Driver Ver: ")); Serial.println(sensor.version);
Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id);
Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F("°C"));
Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F("°C"));
Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F("°C"));
Serial.println(F("------------------------------------"));
// Print humidity sensor details.
dht.humidity().getSensor(&sensor);
Serial.println(F("Humidity Sensor"));
Serial.print (F("Sensor Type: ")); Serial.println(sensor.name);
Serial.print (F("Driver Ver: ")); Serial.println(sensor.version);
Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id);
Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F("%"));
Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F("%"));
Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F("%"));
Serial.println(F("------------------------------------"));
// Set delay between sensor readings based on sensor details.
delayMS = sensor.min_delay / 1000;
timer.setInterval(1000L, sendSensor);
timer.setInterval(1000L, sendWifi);
timer.setInterval(1000L, getcurrent);
//timer.setTimeout(1000L, sendSensor);
//timer.setTimeout(1000L, sendWifi);
//timer.setTimeout(500L, getcurrent);
}
//########################################
void loop()
{
if(Connected2Blynk){
Blynk.run();
}
timer.run();
}
//########################################
BTW… i thought of that method first but what i am doing and need to do is current detection between the AC source and the sump pump / switch combination. With your method i was have to sense after the switch instead of before the switch like i am doing.