using tried and working hardware, that had no issues with staying connected, upgraded the software and it not will not retain its setup and I need to go to its app and reconfigure it
,even when I remove the wemos from the pcb this need to be done. So i think it must be in the code somewhere.
/*************************************************************
Blynk is a platform with iOS and Android apps to control
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
You can easily build mobile and web interfaces for any
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: https://www.blynk.io
Sketch generator: https://examples.blynk.cc
Blynk community: https://community.blynk.cc
Follow us: https://www.fb.com/blynkapp
https://twitter.com/blynk_app
Blynk library is licensed under MIT license
*************************************************************
Blynk.Edgent implements:
- Blynk.Inject - Dynamic WiFi credentials provisioning
- Blynk.Air - Over The Air firmware updates
- Device state indication using a physical LED
- Credentials reset using a physical Button
*************************************************************/
//-----------// SET FOR D1 Pro-wemos 2nd printed board
// New Board Ver2 unit 1
// gives voltage reading, set to read 10 on DS18B20's
// lights up Leds in dashboard and app and closes relay
// hard code is turned off but set to 2 notifactions per hour for door, 2 per half hour for wet sensor
/* This program runs on an wemos D1 Pro.
*
AO - pin = ADCO - Voltage Sensor
D3 - Pin = GPIO 00 - Reset to GND
D5 - Pin = GPIO 14 - DS18b20
D2 - Pin = GPIO 04 - Wet/Dry Relay Out \ Siren
D6 - Pin = GPIO 12 - Wet/Dry Sensor
D7 - Pin = GPIO 13 - Door
V10 = Water Sensor led (in App)
V1 = Temp #1
V2 = Temp #2
V3 = Temp #3
V4 = Temp #4
V13 = Adjusted Battery Voltage
V25 = door contact led (in app)
*/
#define BLYNK_TEMPLATE_ID "TMPLrgM4PTAi"
#define BLYNK_DEVICE_NAME "WemosD1 4-11-26"
#define BLYNK_TEMPLATE_NAME "The Watching My Boat 2"
//#define BLYNK_AUTH_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxx"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
//#define BLYNK_"WatchingMyBoat"_wifi_ssid
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#define USE_WEMOS_D1_MINI
#define APP_DEBUG
#define VOLT_SCALE 65.9 // current starting working number
#define CAL_FACTOR 1.0232 // fine tune here only-- take meter voltage, divide by blynk voltage, use that number
#define VT_PIN A0
#define ONE_WIRE_BUS 14
#include "BlynkEdgent.h"
//#include <SimpleTimer.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
const int Contact1 = 13; // Door contact on pin d8 (int0)
const int Relay = 4; // Used with Wet/Dry Sensor on pin D2
const byte WETDRY = 12; // Button on digital pin d7 (int1)
int flag=0;
bool doorAlertStatus = false; // Whether or not we've already sent a notification for the door sensor
bool waterAlertStatus = false; // wether or not we sent notification for the water sensor
bool voltAlertStatus = false;
BlynkTimer timer; // Start funtion timer
WidgetLED led1(V20); // Led Inicator Water
WidgetLED led2(V21); // Led Inicator Door
WidgetLED led3(V22); // Led Inicator Voltage
void getTempData()
{
sensors.requestTemperatures();
for (int i = 0; i < 10; i++)
{
float tempF = sensors.getTempFByIndex(i);
Blynk.virtualWrite(V1 + i, tempF);
}
}
void handleWaterLocal()
{
boolean isWet = (digitalRead(WETDRY) == LOW);
if (isWet == false)
{
digitalWrite(Relay, HIGH);
}
else
{
digitalWrite(Relay, LOW);
}
}
// Voltage Sensor
void getVoltage()
{
int vt_read = analogRead(VT_PIN);
float voltage = (vt_read / VOLT_SCALE) * CAL_FACTOR;
Blynk.virtualWrite(V0, voltage);
if (voltage <= 12.1)
{
led3.on();
if (!voltAlertStatus)
{
Blynk.logEvent("low_voltage", "Battery voltage low!");
voltAlertStatus = true;
}
}
else
{
led3.off();
voltAlertStatus = false;
}
}
void contact1LedNote()
{
boolean isClosed =(digitalRead(Contact1) == LOW);
if (isClosed == false)
{
led2.on(); // If the door is open we turn the LED on
Blynk.logEvent("door_open", "Door Has Opened,") ; // Sends the notification app
// https://blynk.cloud/external/api/logEvent?token=s5nEV2oM568MX259OPFbSgCI5yJb5-Sa=Door opened // sends notifcation from code
if (!doorAlertStatus) { // Check the status of the notification flag boolean here; if we haven't sent a notification we send one
doorAlertStatus = true; // Change the notification flag to indicate we have sent the message
}
}
else
{
led2.off(); // turn off the LED
if (doorAlertStatus) { // Check the status of the notification flag boolean here; if we haven't sent a notification (disabled) change the status
//Blynk.notify("Alert : Door is Closed!"); // disabled
doorAlertStatus = false; // reset the notification flag boolean so we can send another message
}
}
}
void wetDryLedNote()
{
boolean isWet =(digitalRead(WETDRY) == LOW);
if (isWet == false)
{
led1.on(); // If the sensor is wet we turn the LED on
// Relay.on();
Blynk.logEvent("Wet", "Water Sensor Is Wet,") ; // Sends the notification app
//https://blynk.cloud/external/api/logEvent?token=s5nEV2oM568MX259OPFbSgCI5yJb5-Sa=Wet Sensor // Sends the notification from code // if sensor is wet
if (!waterAlertStatus) { // Check the status of the notification flag boolean here; if we haven't sent a notification we send one
waterAlertStatus = true; // Change the notification flag to indicate we have sent the message
digitalWrite(Relay, HIGH);
}
}
else
{
led1.off(); // turn off the LED
// Relay.off(); // turn Relay off // if sensor is Dry
if (waterAlertStatus) { // Check the status of the notification flag boolean here; if we haven't sent a notification (disabled) change the status
// https://blynk.cloud/external/api/logEvent?token=Eqai2X3wZh-qBN2bUiuEoChAR62pPVR1=Sensor Is Dry // Sends the notification
waterAlertStatus = false; // reset the notification flag boolean so we can send another message
digitalWrite(Relay, LOW);
}
}
}
void setup()
{
Serial.begin(115200);
pinMode(WETDRY, INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);
pinMode (13 ,INPUT_PULLUP);
pinMode (Relay, OUTPUT);
//pinMode (16,INPUT_PULLUP);
// IMMEDIATE FAIL-SAFE CHECK
if (digitalRead(WETDRY) == LOW)
{
digitalWrite(Relay, HIGH);
}
else
{
digitalWrite(Relay, LOW);
}
sensors.begin();
BlynkEdgent.begin();
timer.setInterval(1000L, getVoltage);
timer.setInterval(1500L, getTempData);
timer.setInterval (2000L, contact1LedNote);
timer.setInterval(2500, wetDryLedNote);
}
void loop() {
handleWaterLocal(); // Always running to make sure water alarm sounds even without blynk connected
BlynkEdgent.run();
timer.run();
}