Hello.
I have been using Blynk for 3 years now. I was on the original legacy version for the past 2 years with minimal issues.
I am using an Arduino Uno Wifi Rev 2, I have had it successfully connected, last year I had an issue where after 12 hours or so it would go offline. I have attached my code below. Tonight, it will connect for about 10 minutes then go offline and never reconnect. I dumbed down my code severely to see if it was an issue with the code. I also put the arduino on its own separate network. That did not work either. I have multiple esp32s on my primary network with minimal issues.
Here is my dumbed down code. Do you see any issues?
Thanks
Caiden
#define BLYNK_TEMPLATE_ID "TMPL5IxsyFuz"
#define BLYNK_DEVICE_NAME "Snowmaking Pump and Compressor Control"
#define BLYNK_AUTH_TOKEN "1rNZ6iZ0Rkwb4yOb46LoN4QwKTnBQVW_"
//A0-AIR PRESSURE SENSOR
//A3-WATER PRESSURE SENSOR
//A5-SUCTION PRESSURE SENSOR
//D2-DHT SENSOR 1
//D1-DHT SENSOR 2
//D3- Air Valve
//D4- Water Valve
//D5- Air Compressor
//D6- Cat Pump
//V1-HUMIDITY SENSOR OUTDOOR
//V2-TEMPERATURE SENSOR OUTDOOR
//V3-HUMIDITY SENSOR 2
//V4-TEMPERATURE SENSOR 2
//V5- PRESSURE AIR
//V6- PRESSURE WATER
//V7- OUTSIDE WETBULB
//V8- ONLINE LED
//V9- WATER METER
//V10- WATER METER RESETTABLE
//V11- PUMP HOUR METER
//V12- AIR COMPRESSOR HOUR METER
//V13- RUN HOUR METER
//V14- SEASON HOUR METER
//V15- DEW POINT
#include <Arduino.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>
#define BLYNK_PRINT Serial
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "caidensnowmaking";
char pass[] = "2077510937";
BlynkTimer timer;
//Air smoothing
#define WINDOW_SIZE 5
long INDEX = 0;
long VALUE = 0;
long SUM = 0;
long READINGS[WINDOW_SIZE];
long AVERAGED = 0;
//Water smoothing
long INDEX1 = 0;
long VALUE1 = 0;
long SUM1 = 0;
long READINGS1[WINDOW_SIZE];
long AVERAGED1 = 0;
//Suction smoothing
long INDEX2 = 0;
long VALUE2 = 0;
long SUM2 = 0;
long READINGS2[WINDOW_SIZE];
long AVERAGED2 = 0;
//Air Pressure Sensor
int pressure;
const int pressureInput = A0; //select the analog input pin for the pressure transducer
const int pressureZero = 102.4; //analog reading of pressure transducer at 0psi
const int pressureMax = 900; //analog reading of pressure transducer at 100psi
const int pressuretransducermaxPSI = 150; //psi value of transducer being used
float pressureValue = 0;
//Water Pressure Sensor
int pressure1;
const int pressureInput1 = A3; //select the analog input pin for the pressure transducer
const int pressureZero1 = 100; //analog reading of pressure transducer at 0psi
const int pressureMax1 = 900; //analog reading of pressure transducer at 1000psi
const int pressuretransducermaxPSI1 = 1000; //psi value of transducer being used
float pressureValue1 = 0;
//Suction Pressure Sensor
int pressure2;
const int pressureInput2 = A5; //select the analog input pin for the pressure transducer
const int pressureZero2 = 100; //analog reading of pressure transducer at 0psi
const int pressureMax2 = 900; //analog reading of pressure transducer at 150psi
const int pressuretransducermaxPSI2 = 100; //psi value of transducer being used
float pressureValue2 = 0;
void smoothing() {
//air
SUM = SUM - READINGS[INDEX]; // Remove the oldest entry from the sum
VALUE = analogRead(A0); // Read the next sensor value
READINGS[INDEX] = VALUE; // Add the newest reading to the window
SUM = SUM + VALUE; // Add the newest reading to the sum
INDEX = (INDEX + 1) % WINDOW_SIZE; // Increment the index, and wrap to 0 if it exceeds the window size
AVERAGED = SUM / WINDOW_SIZE; // Divide the sum of the window by the window size for the result
pressureValue = ((AVERAGED - pressureZero) * pressuretransducermaxPSI) / (pressureMax - pressureZero);
Blynk.virtualWrite(V5, pressureValue);
Blynk.virtualWrite(V20, VALUE);
//water
SUM1 = SUM1 - READINGS1[INDEX1]; // Remove the oldest entry from the sum
VALUE1 = analogRead(A3); // Read the next sensor value
READINGS1[INDEX1] = VALUE1; // Add the newest reading to the window
SUM1 = SUM1 + VALUE1; // Add the newest reading to the sum
INDEX1 = (INDEX1 + 1) % WINDOW_SIZE; // Increment the index, and wrap to 0 if it exceeds the window size
AVERAGED1 = SUM1 / WINDOW_SIZE; // Divide the sum of the window by the window size for the result
pressureValue1 = ((AVERAGED1 - pressureZero1) * pressuretransducermaxPSI1) / (pressureMax1 - pressureZero1);
{
if (pressureValue1 < 10)
{
Blynk.virtualWrite(V6, 0);
Blynk.virtualWrite(V21, VALUE1);
}
else {
Blynk.virtualWrite(V6, pressureValue1);
Blynk.virtualWrite(V21, VALUE1);
}
}
//Suction water
SUM2 = SUM2 - READINGS2[INDEX2]; // Remove the oldest entry from the sum
VALUE2 = analogRead(A5); // Read the next sensor value
READINGS2[INDEX2] = VALUE2; // Add the newest reading to the window
SUM2 = SUM2 + VALUE2; // Add the newest reading to the sum
INDEX2 = (INDEX2 + 1) % WINDOW_SIZE; // Increment the index, and wrap to 0 if it exceeds the window size
AVERAGED2 = SUM2 / WINDOW_SIZE; // Divide the sum of the window by the window size for the result
pressureValue2 = ((AVERAGED2 - pressureZero2) * pressuretransducermaxPSI2) / (pressureMax2 - pressureZero2);
Blynk.virtualWrite(V0, pressureValue2);
Blynk.virtualWrite(V22, VALUE2);
}
void notify() {
if (pressureValue1 > 750) {
Blynk.notify("Caution Water Pressure High");
}
if ((digitalRead(6) == LOW) && (pressureValue1 < 400)) {
Blynk.notify("Caution Water Pressure Low");
}
if ((digitalRead(5) == LOW) && (pressureValue < 70)) {
Blynk.notify("Caution Air Pressure Low");
}
if (pressureValue > 110) {
Blynk.notify("Caution Air Pressure High");
}
}
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(A0, INPUT);
pinMode(A3, INPUT);
pinMode(A5, INPUT);
timer.setInterval(1000L, smoothing);
timer.setInterval(60000L, notify);
}
void loop() {
Blynk.run();
timer.run();
}