Current Relay On/Off Status- In App Button

Hello Everyone,

Currently I am working on a Hydroponic Tower where I am monitoring several sets of data. Additionally I have alarms set which turn on the lights and water pump at defined intervals as per the code below. The system itself, overall, works as I need it. I’m still making some fine adjustments as I go along. At the moment, all the data going to the Blynk app(version 3.4.5) and I am able to view the data in realtime via an Arduino Uno Rev. 2 wifi.

Where I am running into an issue is controlling and monitoring both the Pump and Lights. These are connected to their respective relay where their data pins are connected and controlled by the Uno. As a note, there are no physical buttons within the system.

Current Issue with Virtual Buttons:

Virtual Button1
- Initially after code is uploaded. Button is Highlighted “ON” and light turns on. When toggled
to turn off, the lights turn off and button show “Off” briefly and then goes back to “On” without
being toggled. Lights are still off even though the button show “On”
- During toggling, briefly the button goes to “Off” then goes back to “On” Lights still remain off
- Work around was to create a digital button in order to have control of the lights remotely.
However, this does not provide current status when they system running in
automation(defined timings in code).
VButton Settings:
- Connected to V5 Datastream
- Mode set to Switch
Virtual Button2
- Button turns Pump On and off as needed when toggled.
- When pump turns on during the defined timings within the code(automation), the status on
the Virtual
button is not correct and does not change accordingly
VButton Settings:
- Connected to V8 Datastream
- Mode set to Switch

I’m sure being new to both Arduino and Blynk, I have something coded wrong so I apologize in advance. Any guidance would be appreciated in trying to obtain the goals below.

Goal:
Virtual Button1 in Blynk app
- Manually toggle Light On/Off
- Provide current Off/On status of Lights(maybe Relay State) within the Virtual Button or
Virtual LED

Virtual Button2
- Manually toggle Pump On/Off
- Provide current Off/On status of Pump(maybe Relay State) within the Virtual Button or
Virtual LED

//temphumid Stuff
#include <DHT.h>
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
#define DHTPIN 2
DHT dht(DHTPIN, DHTTYPE);
int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value

//LED Stuff
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
#define LED_PIN    6
#define LED_COUNT 17
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

//Liquid level variables //
int rawLiquidReading;
float liquidLevel;
const long lowEtapeValue = 517;
const long highEtapeValue = 781;
const byte liquidLevelPin = A1;

//Pump and light stuff
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>;
#include <DS1307RTC.h>
#include <TimeLib.h> //added from the TimeRTCSet
int Light = 13;
int Pump = 12;
AlarmId id;


//TDS Stuff
#include <EEPROM.h>
#include "GravityTDS.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 7
#define TdsSensorPin A0
OneWire oneWire(ONE_WIRE_BUS);
GravityTDS gravityTds;
DallasTemperature sensors(&oneWire);
float tdsValue = 0;


//Blynk_Wifi Stuff
#include <BlynkSimpleWiFiNINA.h>
#define BLYNK_TEMPLATE_ID "*************"
#define BLYNK_DEVICE_NAME "*************"
#define BLYNK_AUTH_TOKEN "*************"
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFiNINA.h>
char ssid[] = "*************";
char pass[] = "*************";
char auth[] = "*************";
BlynkTimer timer;
BLYNK_WRITE(V5) // Executes when the value of virtual pin 5 changes
{
  if(param.asInt() == 1)
  {
    // execute this code if the switch widget is now ON
    digitalWrite(Light,HIGH);  // Set Light HIGH

    Blynk.virtualWrite(V5,1);  // Turn the widget attached to V5 On
  }
  else
  {
    // execute this code if the switch widget is now OFF
    digitalWrite(Light,LOW);  // Set Light LOW

    Blynk.virtualWrite(V5,0);  // Turn the widget attached to V5 Off
  }
}
BLYNK_WRITE(V8) // Executes when the value of virtual pin 8 changes
{
  if(param.asInt() == 1)
  {
    // execute this code if the switch widget is now ON
    digitalWrite(Pump,HIGH);  // Set Pump HIGH

    Blynk.virtualWrite(V8,1);  // Turn the widget attached to V8 On
  }
  else
  {
    // execute this code if the switch widget is now OFF
    digitalWrite(Pump,LOW);  // Set digital Pump LOW

    Blynk.virtualWrite(V8,0);  // Turn the widget attached to V8 Off
  }
}
BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V5);  // will cause BLYNK_WRITE(V5) to be executed
  Blynk.syncVirtual(V8);  // will cause BLYNK_WRITE(V8) to be executed
}
  


//lcd stuff
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup()
{
  Serial.begin(9600);
  sensors.begin();
  while (!Serial);
  pinMode(Light, OUTPUT);
  digitalWrite(Light, LOW);
  pinMode(Pump, OUTPUT);
  digitalWrite(Pump, LOW);
  pinMode(liquidLevelPin, INPUT);

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)


  // first run the example from the following path: file, examples, DS1307RTC, to set the time of the RTC, then upload this sketch
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if (timeStatus() != timeSet)
    Serial.println("Unable to sync with the RTC");
  else
    Serial.println("RTC has set the system time");

  // create the alarms, to trigger at specific times
  Alarm.alarmRepeat(6, 0, 0, LightsOn); // Lights on 6:00am every day
  Alarm.alarmRepeat(6, 0, 0, PumpOn); // Pump on 6:00am every day
  Alarm.alarmRepeat(6, 5, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(7, 5, 0, PumpOn); // Pump on 7:05am every day
  Alarm.alarmRepeat(7, 10, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(8, 10, 0, PumpOn); // Pump on 8:10am every day
  Alarm.alarmRepeat(8, 15, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(9, 15, 0, PumpOn); // Pump on 9:15am every day
  Alarm.alarmRepeat(9, 20, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(10, 20, 0, PumpOn); // Pump on 10:20am every day
  Alarm.alarmRepeat(10, 25, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(11, 25, 0, PumpOn); // Pump on 11:25am every day
  Alarm.alarmRepeat(11, 30, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(12, 30, 0, PumpOn); // Pump on 12:30pm every day
  Alarm.alarmRepeat(12, 35, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(13, 35, 0, PumpOn); // Pump on 1:35pm every day
  Alarm.alarmRepeat(13, 40, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(14, 40, 0, PumpOn); // Pump on 2:40pm every day
  Alarm.alarmRepeat(14, 45, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(15, 45, 0, PumpOn); // Pump on 3:45pm every day
  Alarm.alarmRepeat(15, 50, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(16, 50, 0, PumpOn); // Pump on 4:50pm every day
  Alarm.alarmRepeat(16, 55, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(17, 55, 0, PumpOn); // Pump on 5:55pm every day
  Alarm.alarmRepeat(18, 00, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(19, 00, 0, LightsOff); // Lights off at 7:00pm every day, remain off until 6:00am
  Alarm.alarmRepeat(19, 00, 0, PumpOn); // Pump on 7:00pm every day
  Alarm.alarmRepeat(19, 05, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(20, 05, 0, PumpOn); // Pump on 8:05pm every day
  Alarm.alarmRepeat(20, 15, 0, PumpOff); // Pump runs for 5 min. and then off unitl 6:00am every day

  lcd.begin(20, 4);
  Serial.println("Connecting to Blynk...");
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);


  gravityTds.setPin(TdsSensorPin);
  gravityTds.setAref(5.0);  //reference voltage on ADC, default 5.0V on Arduino UNO
  gravityTds.setAdcRange(1024);  //1024 for 10bit ADC;4096 for 12bit ADC; 256 for 8 bit
  gravityTds.begin();  //initialization

  int waterValue = analogRead(liquidLevel);


  dht.begin();

  //  Setup a function to be called every second
  //timer.setInterval(1000L, sendSensor);

  lcd.init(); //initialize the lcd
  lcd.backlight(); //open the backlight
  lcd.setCursor(0, 0);
  lcd.print("wLevel");
  lcd.setCursor(0, 1);
  lcd.print("Humid");
  lcd.setCursor(0, 2);
  lcd.print("wTemp");
  lcd.setCursor(0, 3);
  lcd.print("aTemp");
  lcd.setCursor(16, 0);
  lcd.print("TDS");

}

void loop()
{

  digitalClockDisplay();
  Alarm.delay(1000); // wait one second between clock display

  Blynk.run();
  timer.run();
  sensors.requestTemperatures();

  gravityTds.setTemperature(sensors.getTempCByIndex(0));  // set the temperature and execute temperature compensation
  gravityTds.update();  //sample and calculate
  tdsValue = gravityTds.getTdsValue();  // then get the value

  hum = dht.readHumidity();
  temp = dht.readTemperature() * 1.8 + 32;
  lcd.setCursor(8, 0); //Water Level
  lcd.print(liquidLevel, 0); //Water Level value displayed on lcd
  lcd.setCursor(12, 0); //Percent symbol location
  lcd.print("%"); //Percentage symblol
  //lcd.setCursor(16, 1); //TDS Level
  //lcd.print(tdsValue, 0); ///tds value displayed on lcd
  lcd.setCursor(16, 2); //ppm location
  lcd.print("PPM"); //Percentage symblol
  lcd.setCursor(8, 3); //aTemp value
  lcd.print(temp, 0); //avtemperaturevvalue displayed on lcd
  lcd.setCursor(11, 3); //Degree Symbol location
  lcd.print((char)223); //Degree Symbol
  lcd.setCursor(12, 3); //Temperature Symbol location
  lcd.print("F"); //Temperature Symbol
  lcd.setCursor(8, 1); //humidity value
  lcd.print(hum, 0); //humidity Level value displayed on lcd
  lcd.setCursor(12, 1); //Humidity Symbol location
  lcd.print("%"); //Humidity Symbol
  lcd.setCursor(8, 2); //Water Temp Location
  lcd.print(sensors.getTempCByIndex(0) * 1.8 + 32, 0); //Water Temp Value
  lcd.setCursor(11, 2); //wDegree Symbol location
  lcd.print((char)223); //wtem Degree Symbol
  lcd.setCursor(12, 2); //wTaemperature Symbol location
  lcd.print("F  "); //wTemperature Symbol


  rawLiquidReading = analogRead(liquidLevelPin);
  Serial.print("Raw Liquid Level: ");
  Serial.print(rawLiquidReading);

  liquidLevel = map(rawLiquidReading, lowEtapeValue, highEtapeValue, 0, 100);
  Serial.print(" / Liquid Remaining: ");
  Serial.print(liquidLevel);
  Serial.println("%.");


  if (liquidLevel  > 20 && liquidLevel < 50) {
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(0, 150, 0));
    strip.show();
  }

  else if (liquidLevel >= 50) {
    strip.clear();
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(0, 0, 150));
    strip.show();
  }

  else if (liquidLevel <= 20) {
    strip.clear();
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(255, 0, 0));
    strip.show();
  }

  Blynk.virtualWrite(V0, liquidLevel); //water level vpin
  Blynk.virtualWrite(V1, tdsValue); //tds vpin
  Blynk.virtualWrite(V5, temp); //aTemp vpin
  Blynk.virtualWrite(V2, hum); //humidity vpin
  Blynk.virtualWrite(V4, sensors.getTempCByIndex(0) * 1.8 + 32); //wtemp vpin
  Blynk.virtualWrite(V10, rawLiquidReading); //humidity vpin

}



// functions to be called when an alarm triggers




void LightsOn() {

  Serial.println("Alarm: - turn lights On");
  digitalWrite(Light, HIGH);
}


void LightsOff() {
  Serial.println("Alarm: - turn lights Off");
  digitalWrite(Light, LOW);
}

void PumpOn() {
  Serial.println("Alarm: - turn lights On");
  digitalWrite(Pump, HIGH);
}

void PumpOff() {
  Serial.println("Alarm: - turn lights Off");
  digitalWrite(Pump, LOW);
}


void digitalClockDisplay() {
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println();
}

void printDigits(int digits) {
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if (digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void colorWipe(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }
}

Okay, let’s start with a few Blynk basics…

This should simply be…

Blynk.begin(auth, ssid, pass):

And these three lines should be the first three lines of your sketch…

It’s then normal (good) practice to follow this with all of your #includes for your libraries.

Next, you need to read this…

You’ve omitted two important pieces of information regarding your virtual datastreams…

  • Min/max values
  • Data Types

also you’ve not said whether your switch widgets are set to Push or Switch.

GPIO13 on the Uno type boards does some weird stuff at startup. I’ve always tended to steer clear of it personally.

Pete.

Pete, Thank you for the quick reply.

I moved the three lines of code regarding the Blynk template info to the top as requested and commented out"Blynk.begin(auth, ssid, pass, “blynk.cloud”, 80);" and added “Blynk.begin(auth, ssid, pass);” The result was no data went to my LCD (only showed solid squares) and lost connection to Blynk. I committed " Blynk.begin(auth, ssid, pass);" and uncommitted “Blynk.begin(auth, ssid, pass, “blynk.cloud”, 80);” and everything came back up.

I plan on cleaning up the code, primarily the loop, once everything is functional. I hate to introduce other issues while I am still trying to learn this stuff.

In regards to the Max/Min and Data Type for both virtual buttons:
Min=0 and Max=1
Data Type - Integer

I felt like GPIO 13 was acting weird. Would you happen to have a suggestion for a substitute?

What version of the Blynk library are you using?

I’m not really familiar with the Rev2 WiFi pinout, so can’t really help with that.

Pete.

Good Morning Pete, I apologize for the delay in my response. The version of Blynk in the Library was 0.6.1. When I opened the Manager, there was an update available so I went ahead and updated to version 1.1.0. I will give this a try when I get home from work today to see if there are any differences in the functionality and provide any feedback.

0.6.1 is the last Legacy version of the library.
You need to be running 1.1.0

Pete.

I updated to 1.1.0 this morning and the sketch would not compile. I did not have time to debug it before I had to leave for work. It was giving the error with “atol “ which I thought got corrected. May have to go into the pharam file and make the corrections. Not sure yet. I will jump into it this evening.

No. Search for the error and you’ll see how to edit the relevant library file to fix it.

Pete.

Good Evening, I was able to make the changes to the text file for the “Atoll”/“Atol” issue. Additionally I changed the GrowLights from GPIO 13 to 8. The sketch was uploaded. The virtual buttons still act the same as before. Below is a visual of how the app looks on my side. The two virtual button are on top and the digital buttons are on the bottom. My thinking, as a test, was that i could toggle the digital buttons and the virtual button would reflect the respective state.

Delete the digital switch widgets, they are confusing the issue. The virtual switch widgets won’t synchronise with them unless you add additional code to check the state of the GPIOs and update the virtual buttons accordingly.

Posting your updated sketch, and a clear description of how things are behaving, and how this is different from how they should behave would be helpful.

Is this a Cannabis grow system?
Are you using LED lights?

Pete.

Good Morning Pete, Per your request I deleted out the digital widgets. Below is the latest status. Hopefully I captured the latest status and provided sufficient information. There is more info that I can add too much confusion at the same time. If I missed anything, please let me know.

Request Completed

  • Deleted the digital widgets(see screenshot of app below),

  • Moved the Blynk info to the top of the sketch

  • Committed out Blynk.begin(auth, ssid, pass, “blynk.cloud”, 80); and added Blynk.begin(auth, ssid, pass)

  • Updated Blynk Libary to version 1.1.0

  • Changed GPIO 13 to 8

Pending Request:

  • Clean up Loop (Will be completed once system is fully functional, if possible)

  • Format Sketch based on best practices (Will be completed once system is fully functional, if possible)

Project
Hydroponic Tower (for vegetables)

Project Goal
Hydroponic Tower that will operate independently with minimum effort from the user. Have the ability to monitor the Water Level, TDS, Water Temp, Air Temp, humidity, pump status and lighting status both remotely (Blynk) and locally(visual and LCD Screen). The system will also need to provide water and lighting (LED Grow Lights)at defined times.

Current Status
The Hydroponic Tower is fully functional where it is providing current data based on the required sensors listed above. Water and lighting is being provided based on defined schedule listed in sketch below.

Issue
The current issue is based on the ability to view the current status of both the Pump and LED Grow Lights via a button widget within the Blynk app on an Apple I-Phone. Additionally, having the ability to turn the lights/pump either on or off with the same button Widget.

  • Light Widget
    The Light widget was added to both the web interface and app. Settings are in the below screenshots. The Growlight Widget functionality within both the web and app is the same. The button highlightes Green and Reads “ON”. When toggled to turn off, it will briefly go to off and immediately go back to the initial state of ON. The button will not turn the lights either on or off. I need the widget to turn the lights on or off and show the current status of the lights.

  • Pump Widget
    The pump widget will turn the pump both on(Widget highlighted) and off. However, when the pump turns on while in automation mode, the widget shows whatever its latest status was. As an example, if the widget is reading “OFF” and the pump turns on based on the defined time in the code, the widget still reads “OFF”. Based on this example, Since the widget turns the pump both on and off, I need the widget to change to “ON” to represent its current status. As a note, both the Pump and Lights are connected to 5V relays.

#define BLYNK_TEMPLATE_ID "***************"
#define BLYNK_DEVICE_NAME "***************"
#define BLYNK_AUTH_TOKEN "***************"

//temphumid Variables
#include <DHT.h>
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
#define DHTPIN 2
DHT dht(DHTPIN, DHTTYPE);
int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value

//LED Variables
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
#define LED_PIN    6
#define LED_COUNT 17
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

//Liquid level variables //
int rawLiquidReading;
float liquidLevel;
const long lowEtapeValue = 517;
const long highEtapeValue = 781;
const byte liquidLevelPin = A1;

//Pump and light Variables
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>;
#include <DS1307RTC.h>
#include <TimeLib.h> //added from the TimeRTCSet
int Light = 8;
int Pump = 12;
AlarmId id;


//TDS Variables
#include <EEPROM.h>
#include "GravityTDS.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 7
#define TdsSensorPin A0
OneWire oneWire(ONE_WIRE_BUS);
GravityTDS gravityTds;
DallasTemperature sensors(&oneWire);
float tdsValue = 0;


//Blynk_Wifi Variables
#include <BlynkSimpleWiFiNINA.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFiNINA.h>
char ssid[] = "***************";
char pass[] = "***************";
char auth[] = "***************";
BlynkTimer timer;
BLYNK_WRITE(V5) // Executes when the value of virtual pin 5 changes
{
  if (param.asInt() == 1)
  {
    // execute this code if the switch widget is now ON
    digitalWrite(Light, HIGH); // Set Light HIGH

    Blynk.virtualWrite(V5, 1); // Turn the widget attached to V5 On
  }
  else
  {
    // execute this code if the switch widget is now OFF
    digitalWrite(Light, LOW); // Set Light LOW

    Blynk.virtualWrite(V5, 0); // Turn the widget attached to V5 Off
  }
}
BLYNK_WRITE(V8) // Executes when the value of virtual pin 5 changes
{
  if (param.asInt() == 1)
  {
    // execute this code if the switch widget is now ON
    digitalWrite(Pump, HIGH); // Set Pump HIGH

    Blynk.virtualWrite(V8, 1); // Turn the widget attached to V8 On
  }
  else
  {
    // execute this code if the switch widget is now OFF
    digitalWrite(Pump, LOW); // Set digital Pump LOW

    Blynk.virtualWrite(V8, 0); // Turn the widget attached to V8 Off
  }
}
BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V5);  // will cause BLYNK_WRITE(V5) to be executed
  Blynk.syncVirtual(V8);  // will cause BLYNK_WRITE(V8) to be executed
}



//lcd Variables
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup()
{
  Serial.begin(9600);
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  Blynk.begin(auth, ssid, pass);
  sensors.begin();
  while (!Serial);
  pinMode(Light, OUTPUT);
  digitalWrite(Light, LOW);
  pinMode(Pump, OUTPUT);
  digitalWrite(Pump, LOW);
  pinMode(liquidLevelPin, INPUT);


  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)


  // first run the example from the following path: file, examples, DS1307RTC, to set the time of the RTC, then upload this sketch
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if (timeStatus() != timeSet)
    Serial.println("Unable to sync with the RTC");
  else
    Serial.println("RTC has set the system time");

  // create the alarms, to trigger at specific times
  Alarm.alarmRepeat(6, 0, 0, LightsOn); // Lights on 6:00am every day
  Alarm.alarmRepeat(6, 0, 0, PumpOn); // Pump on 6:00am every day
  Alarm.alarmRepeat(6, 5, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(7, 5, 0, PumpOn); // Pump on 7:05am every day
  Alarm.alarmRepeat(7, 10, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(8, 10, 0, PumpOn); // Pump on 8:10am every day
  Alarm.alarmRepeat(8, 15, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(9, 15, 0, PumpOn); // Pump on 9:15am every day
  Alarm.alarmRepeat(9, 20, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(10, 20, 0, PumpOn); // Pump on 10:20am every day
  Alarm.alarmRepeat(10, 25, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(11, 25, 0, PumpOn); // Pump on 11:25am every day
  Alarm.alarmRepeat(11, 30, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(12, 30, 0, PumpOn); // Pump on 12:30pm every day
  Alarm.alarmRepeat(12, 35, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(13, 35, 0, PumpOn); // Pump on 1:35pm every day
  Alarm.alarmRepeat(13, 40, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(14, 40, 0, PumpOn); // Pump on 2:40pm every day
  Alarm.alarmRepeat(14, 45, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(15, 45, 0, PumpOn); // Pump on 3:45pm every day
  Alarm.alarmRepeat(15, 50, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(16, 50, 0, PumpOn); // Pump on 4:50pm every day
  Alarm.alarmRepeat(16, 55, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(17, 55, 0, PumpOn); // Pump on 5:55pm every day
  Alarm.alarmRepeat(18, 00, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(19, 00, 0, LightsOff); // Lights off at 7:00pm every day, remain off until 6:00am
  Alarm.alarmRepeat(19, 00, 0, PumpOn); // Pump on 7:00pm every day
  Alarm.alarmRepeat(19, 05, 0, PumpOff); // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(20, 05, 0, PumpOn); // Pump on 8:05pm every day
  Alarm.alarmRepeat(20, 15, 0, PumpOff); // Pump runs for 5 min. and then off unitl 6:00am every day

  lcd.begin(20, 4);

  gravityTds.setPin(TdsSensorPin);
  gravityTds.setAref(5.0);  //reference voltage on ADC, default 5.0V on Arduino UNO
  gravityTds.setAdcRange(1024);  //1024 for 10bit ADC;4096 for 12bit ADC; 256 for 8 bit
  gravityTds.begin();  //initialization

  int waterValue = analogRead(liquidLevel);


  dht.begin();

  //  Setup a function to be called every second
  //timer.setInterval(1000L, sendSensor);

  lcd.init(); //initialize the lcd
  lcd.backlight(); //open the backlight
  lcd.setCursor(0, 0);
  lcd.print("wLevel");
  lcd.setCursor(0, 1);
  lcd.print("Humid");
  lcd.setCursor(0, 2);
  lcd.print("wTemp");
  lcd.setCursor(0, 3);
  lcd.print("aTemp");
  lcd.setCursor(16, 0);
  lcd.print("TDS");

}

void loop()
{

  digitalClockDisplay();
  Alarm.delay(1000); // wait one second between clock display

  Blynk.run();
  timer.run();
  sensors.requestTemperatures();

  gravityTds.setTemperature(sensors.getTempCByIndex(0));  // set the temperature and execute temperature compensation
  gravityTds.update();  //sample and calculate
  tdsValue = gravityTds.getTdsValue();  // then get the value

  hum = dht.readHumidity();
  temp = dht.readTemperature() * 1.8 + 32;
  lcd.setCursor(8, 0); //Water Level
  lcd.print(liquidLevel, 0); //Water Level value displayed on lcd
  lcd.setCursor(12, 0); //Percent symbol location
  lcd.print("%"); //Percentage symblol
  //lcd.setCursor(16, 1); //TDS Level
  //lcd.print(tdsValue, 0); ///tds value displayed on lcd
  lcd.setCursor(16, 2); //ppm location
  lcd.print("PPM"); //Percentage symblol
  lcd.setCursor(8, 3); //aTemp value
  lcd.print(temp, 0); //avtemperaturevvalue displayed on lcd
  lcd.setCursor(11, 3); //Degree Symbol location
  lcd.print((char)223); //Degree Symbol
  lcd.setCursor(12, 3); //Temperature Symbol location
  lcd.print("F"); //Temperature Symbol
  lcd.setCursor(8, 1); //humidity value
  lcd.print(hum, 0); //humidity Level value displayed on lcd
  lcd.setCursor(12, 1); //Humidity Symbol location
  lcd.print("%"); //Humidity Symbol
  lcd.setCursor(8, 2); //Water Temp Location
  lcd.print(sensors.getTempCByIndex(0) * 1.8 + 32, 0); //Water Temp Value
  lcd.setCursor(11, 2); //wDegree Symbol location
  lcd.print((char)223); //wtem Degree Symbol
  lcd.setCursor(12, 2); //wTaemperature Symbol location
  lcd.print("F  "); //wTemperature Symbol


  rawLiquidReading = analogRead(liquidLevelPin);
  Serial.print("Raw Liquid Level: ");
  Serial.print(rawLiquidReading);

  liquidLevel = map(rawLiquidReading, lowEtapeValue, highEtapeValue, 0, 100);
  Serial.print(" / Liquid Remaining: ");
  Serial.print(liquidLevel);
  Serial.println("%.");


  if (liquidLevel  > 20 && liquidLevel < 50) {
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(0, 150, 0));
    strip.show();
  }

  else if (liquidLevel >= 50) {
    strip.clear();
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(0, 0, 150));
    strip.show();
  }

  else if (liquidLevel <= 20) {
    strip.clear();
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(255, 0, 0));
    strip.show();
  }

  Blynk.virtualWrite(V0, liquidLevel); //water level vpin
  Blynk.virtualWrite(V1, tdsValue); //tds vpin
  Blynk.virtualWrite(V5, temp); //aTemp vpin
  Blynk.virtualWrite(V2, hum); //humidity vpin
  Blynk.virtualWrite(V4, sensors.getTempCByIndex(0) * 1.8 + 32); //wtemp vpin
  Blynk.virtualWrite(V10, rawLiquidReading); //humidity vpin

}



// functions to be called when an alarm triggers




void LightsOn() {

  Serial.println("Alarm: - turn lights On");
  digitalWrite(Light, HIGH);
}


void LightsOff() {
  Serial.println("Alarm: - turn lights Off");
  digitalWrite(Light, LOW);
}

void PumpOn() {
  Serial.println("Alarm: - turn lights On");
  digitalWrite(Pump, HIGH);
}

void PumpOff() {
  Serial.println("Alarm: - turn lights Off");
  digitalWrite(Pump, LOW);
}


void digitalClockDisplay() {
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println();
}

void printDigits(int digits) {
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if (digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void colorWipe(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }
}

I won’t comment further until you’ve completed that task, it’s key to solving the issue.

You also need to look at your virtual pin usage, as V5 appears to be used for two different et things.

Pete.

Loop has been cleaned up (hopefully, I did it correctly). Updated sketch(see below) was uploaded and tested.

Current App Status:

  • Light Widget V5
    will now toggle the lights both on and off ( I had V5 assigned to another sensor which should have
    been V3 which caused confusion within Blynk).

    Required functionality of Light Widget
    Widget will toggle light On/Off - This has been corrected, Thank you Pete for pointing the issue out!
    Widget to show current status of the lights - Open topic

  • Virtual Pin V8
    Toggles the pump both on and off.

    Required functionality of Pump Widget
    Widget will toggle Pump On/Off - This works as required
    Widget to show current status of the lights - Open topic

#define BLYNK_TEMPLATE_ID "*************"
#define BLYNK_DEVICE_NAME "*************"
#define BLYNK_AUTH_TOKEN "*************"

//temphumid Variables

#include <DHT.h>
#define DHTTYPE DHT22  // DHT 22 (AM2302), AM2321
#define DHTPIN 2
DHT dht(DHTPIN, DHTTYPE);
int chk;
float hum;   //Stores humidity value
float temp;  //Stores temperature value

//LED Variables
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>  // Required for 16 MHz Adafruit Trinket
#endif
#define LED_PIN 6
#define LED_COUNT 17
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

//Liquid level variables 
int rawLiquidReading;
float liquidLevel;
const long lowEtapeValue = 517;
const long highEtapeValue = 781;
const byte liquidLevelPin = A1;

//Pump and light Variables
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>;
#include <DS1307RTC.h>
#include <TimeLib.h>  //added from the TimeRTCSet
int Light = 8;
int Pump = 12;
AlarmId id;

//TDS Variables
#include <EEPROM.h>
#include "GravityTDS.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 7
#define TdsSensorPin A0
OneWire oneWire(ONE_WIRE_BUS);
GravityTDS gravityTds;
DallasTemperature sensors(&oneWire);
float tdsValue = 0;

//Blynk_Wifi Variables
#include <BlynkSimpleWiFiNINA.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFiNINA.h>
char ssid[] = "*************";
char pass[] = "*************";
char auth[] = "*************";
BlynkTimer timer;
BLYNK_WRITE(V5)  // Executes when the value of virtual pin 5 changes
{
  if (param.asInt() == 1) {
    digitalWrite(Light, HIGH);  // Set Light HIGH
    Blynk.virtualWrite(V5, 1);  // Turn the widget attached to V5 On

  } else {
    // execute this code if the switch widget is now OFF
    digitalWrite(Light, LOW);  // Set Light LOW
    Blynk.virtualWrite(V5, 0);  // Turn the widget attached to V5 Off
  }
}
BLYNK_WRITE(V8)  // Executes when the value of virtual pin V8 changes
{
  if (param.asInt() == 1) {
    // execute this code if the switch widget is now ON
    digitalWrite(Pump, HIGH);  // Set Pump HIGH
    Blynk.virtualWrite(V8, 1);  // Turn the widget attached to V8 On

  } else {
    // execute this code if the switch widget is now OFF
    digitalWrite(Pump, LOW);  // Set digital Pump LOW
    Blynk.virtualWrite(V8, 0);  // Turn the widget attached to V8 Off
  }
}

BLYNK_CONNECTED() {
  Blynk.syncVirtual(V5);  // will cause BLYNK_WRITE(V5) to be executed
  Blynk.syncVirtual(V8);  // will cause BLYNK_WRITE(V8) to be executed
}

//lcd Variables
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {

  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  sensors.begin();
  while (!Serial);
  pinMode(Light, OUTPUT);
  digitalWrite(Light, LOW);
  pinMode(Pump, OUTPUT);
  digitalWrite(Pump, LOW);
  pinMode(liquidLevelPin, INPUT);

  strip.begin();            // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();             // Turn OFF all pixels ASAP
  strip.setBrightness(50);  // Set BRIGHTNESS to about 1/5 (max = 255)

  // first run the example from the following path: file, examples, DS1307RTC, to set the time of the RTC, then upload this sketch
  setSyncProvider(RTC.get);  // the function to get the time from the RTC
  if (timeStatus() != timeSet)
    Serial.println("Unable to sync with the RTC");
  else
    Serial.println("RTC has set the system time");

  // create the alarms, to trigger at specific times
  Alarm.alarmRepeat(6, 0, 0, LightsOn);     // Lights on 6:00am every day
  Alarm.alarmRepeat(6, 0, 0, PumpOn);       // Pump on 6:00am every day
  Alarm.alarmRepeat(6, 5, 0, PumpOff);      // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(7, 5, 0, PumpOn);       // Pump on 7:05am every day
  Alarm.alarmRepeat(7, 10, 0, PumpOff);     // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(8, 10, 0, PumpOn);      // Pump on 8:10am every day
  Alarm.alarmRepeat(8, 15, 0, PumpOff);     // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(9, 15, 0, PumpOn);      // Pump on 9:15am every day
  Alarm.alarmRepeat(9, 20, 0, PumpOff);     // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(10, 20, 0, PumpOn);     // Pump on 10:20am every day
  Alarm.alarmRepeat(10, 25, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(11, 25, 0, PumpOn);     // Pump on 11:25am every day
  Alarm.alarmRepeat(11, 30, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(12, 30, 0, PumpOn);     // Pump on 12:30pm every day
  Alarm.alarmRepeat(12, 35, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(13, 35, 0, PumpOn);     // Pump on 1:35pm every day
  Alarm.alarmRepeat(13, 40, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(14, 40, 0, PumpOn);     // Pump on 2:40pm every day
  Alarm.alarmRepeat(14, 45, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(15, 45, 0, PumpOn);     // Pump on 3:45pm every day
  Alarm.alarmRepeat(15, 50, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(16, 50, 0, PumpOn);     // Pump on 4:50pm every day
  Alarm.alarmRepeat(16, 55, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(17, 55, 0, PumpOn);     // Pump on 5:55pm every day
  Alarm.alarmRepeat(18, 00, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(19, 00, 0, LightsOff);  // Lights off at 7:00pm every day, remain off until 6:00am
  Alarm.alarmRepeat(19, 00, 0, PumpOn);     // Pump on 7:00pm every day
  Alarm.alarmRepeat(19, 05, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(20, 05, 0, PumpOn);     // Pump on 8:05pm every day
  Alarm.alarmRepeat(20, 15, 0, PumpOff);    // Pump runs for 5 min. and then off unitl 6:00am every day

  lcd.begin(20, 4);
  gravityTds.setPin(TdsSensorPin);
  gravityTds.setAref(5.0);       //reference voltage on ADC, default 5.0V on Arduino UNO
  gravityTds.setAdcRange(1024);  //1024 for 10bit ADC;4096 for 12bit ADC; 256 for 8 bit
  gravityTds.begin();            //initialization
  int waterValue = analogRead(liquidLevel);
  dht.begin();

  timer.setInterval(1000L, TDSValues);
  timer.setInterval(1000L, DHT22Values);
  timer.setInterval(1000L, Liquidlevelvalues);
  timer.setInterval(1000L, LCDPrintValues);
  timer.setInterval(1000L, VirtualPins);

  lcd.init();       //initialize the lcd
  lcd.backlight();  //open the backlight
  lcd.setCursor(0, 0);
  lcd.print("wLevel");
  lcd.setCursor(0, 1);
  lcd.print("Humid");
  lcd.setCursor(0, 2);
  lcd.print("wTemp");
  lcd.setCursor(0, 3);
  lcd.print("aTemp");
  lcd.setCursor(16, 0);
  lcd.print("TDS");
}

void loop() {
  digitalClockDisplay();
  Alarm.delay(1000);  // wait one second between clock display
  Blynk.run();
  timer.run();
  sensors.requestTemperatures();
  TDSValues();
  DHT22Values();
  Liquidlevelvalues();
  LCDPrintValues();
  VirtualPins();
}

//End Void Loop

void VirtualPins() {
  Blynk.virtualWrite(V0, liquidLevel);                            //water level vpin
  Blynk.virtualWrite(V1, tdsValue);                               //tds vpin
  Blynk.virtualWrite(V3, temp);                                   //aTemp vpin
  Blynk.virtualWrite(V2, hum);                                    //humidity vpin
  Blynk.virtualWrite(V4, sensors.getTempCByIndex(0) * 1.8 + 32);  //wtemp vpin
  Blynk.virtualWrite(V10, rawLiquidReading);                      //humidity vpin
}

void LCDPrintValues() {
  lcd.setCursor(8, 0);        //Water Level
  lcd.print(liquidLevel, 0);  //Water Level value displayed on lcd
  lcd.setCursor(12, 0);       //Percent symbol location
  lcd.print("%");             //Percentage symblol
  //lcd.setCursor(16, 1); //TDS Level
  //lcd.print(tdsValue, 0); ///tds value displayed on lcd
  lcd.setCursor(16, 2);                                 //ppm location
  lcd.print("PPM");                                     //Percentage symblol
  lcd.setCursor(8, 3);                                  //aTemp value
  lcd.print(temp, 0);                                   //avtemperaturevvalue displayed on lcd
  lcd.setCursor(11, 3);                                 //Degree Symbol location
  lcd.print((char)223);                                 //Degree Symbol
  lcd.setCursor(12, 3);                                 //Temperature Symbol location
  lcd.print("F");                                       //Temperature Symbol
  lcd.setCursor(8, 1);                                  //humidity value
  lcd.print(hum, 0);                                    //humidity Level value displayed on lcd
  lcd.setCursor(12, 1);                                 //Humidity Symbol location
  lcd.print("%");                                       //Humidity Symbol
  lcd.setCursor(8, 2);                                  //Water Temp Location
  lcd.print(sensors.getTempCByIndex(0) * 1.8 + 32, 0);  //Water Temp Value
  lcd.setCursor(11, 2);                                 //wDegree Symbol location
  lcd.print((char)223);                                 //wtem Degree Symbol
  lcd.setCursor(12, 2);                                 //wTaemperature Symbol location
  lcd.print("F  ");                                     //wTemperature Symbol
}

void Liquidlevelvalues() {
  rawLiquidReading = analogRead(liquidLevelPin);
  Serial.print("Raw Liquid Level: ");
  Serial.print(rawLiquidReading);

  liquidLevel = map(rawLiquidReading, lowEtapeValue, highEtapeValue, 0, 100);
  Serial.print(" / Liquid Remaining: ");
  Serial.print(liquidLevel);
  Serial.println("%.");

  if (liquidLevel > 20 && liquidLevel < 50) {
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(0, 150, 0));
    strip.show();
  }

  else if (liquidLevel >= 50) {
    strip.clear();
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(0, 0, 150));
    strip.show();
  }

  else if (liquidLevel <= 20) {
    strip.clear();
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(255, 0, 0));
    strip.show();
  }
}

void DHT22Values() {
  hum = dht.readHumidity();
  temp = dht.readTemperature() * 1.8 + 32;
}

void TDSValues() {
  gravityTds.setTemperature(sensors.getTempCByIndex(0));  // set the temperature and execute temperature compensation
  gravityTds.update();                                    //sample and calculate
  tdsValue = gravityTds.getTdsValue();                    // then get the value
}

void LightsOn() {
  Serial.println("Alarm: - turn lights On");
  digitalWrite(Light, HIGH);
}

void LightsOff() {
  Serial.println("Alarm: - turn lights Off");
  digitalWrite(Light, LOW);
}

void PumpOn() {
  Serial.println("Alarm: - turn lights On");
  digitalWrite(Pump, HIGH);
}

void PumpOff() {
  Serial.println("Alarm: - turn lights Off");
  digitalWrite(Pump, LOW);
}

void digitalClockDisplay() {
  // digital clock display of the time

  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println();
}

void printDigits(int digits) {
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if (digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void colorWipe(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) {  // For each pixel in strip...
    strip.setPixelColor(i, color);               //  Set pixel's color (in RAM)
    strip.show();                                //  Update strip to match
    delay(wait);                                 //  Pause for a moment
  }
}

No, when you’ve done it properly these should be the only two lines of code in your void loop…

Is this a typo? Should it say pump rather than lights?

Pete.

You are correct, it was a typo

Happy Thanksgiving!

Cleaned up the Loop where only Blynk and Timer are in there. The sketch may not be up to the standards but it compiled and I uploaded it to the Uno and the system(Hydroponic Tower) is functioning as required.

The Blynk app has the same behavior with the virtual buttons where they will turn the Lights and Pumps ON/OFF when toggled but fail to show the status when the Light and Pump turn ON/OFF via the alarms in the sketch. Below is the updated Sketch.

#define BLYNK_TEMPLATE_ID "********"
#define BLYNK_DEVICE_NAME "********"
#define BLYNK_AUTH_TOKEN "********"

//temphumid Variables

#include <DHT.h>
#define DHTTYPE DHT22  // DHT 22 (AM2302), AM2321
#define DHTPIN 2
DHT dht(DHTPIN, DHTTYPE);
int chk;
float hum;   //Stores humidity value
float temp;  //Stores temperature value

//LED Variables
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>  // Required for 16 MHz Adafruit Trinket
#endif
#define LED_PIN 6
#define LED_COUNT 17
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

//Liquid level variables
int rawLiquidReading;
float liquidLevel;
const long lowEtapeValue = 517;
const long highEtapeValue = 781;
const byte liquidLevelPin = A1;

//Pump and light Variables
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>;
#include <DS1307RTC.h>
#include <TimeLib.h>  //added from the TimeRTCSet
int Light = 8;
int Pump = 12;
AlarmId id;

//TDS Variables
#include <EEPROM.h>
#include "GravityTDS.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 7
#define TdsSensorPin A0
OneWire oneWire(ONE_WIRE_BUS);
GravityTDS gravityTds;
DallasTemperature sensors(&oneWire);
float tdsValue = 0;

//Blynk_Wifi Variables
#include <BlynkSimpleWiFiNINA.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFiNINA.h>
char ssid[] = "********";
char pass[] = "********";
char auth[] = "********";
BlynkTimer timer;
BLYNK_WRITE(V5)  // Executes when the value of virtual pin 5 changes
{
  if (param.asInt() == 1) {
    digitalWrite(Light, HIGH);  // Set Light HIGH
    Blynk.virtualWrite(V5, 1);  // Turn the widget attached to V5 On

  } else {
    // execute this code if the switch widget is now OFF
    digitalWrite(Light, LOW);  // Set Light LOW
    Blynk.virtualWrite(V5, 0);  // Turn the widget attached to V5 Off
  }
}
BLYNK_WRITE(V8)  // Executes when the value of virtual pin V8 changes
{
  if (param.asInt() == 1) {
    // execute this code if the switch widget is now ON
    digitalWrite(Pump, HIGH);  // Set Pump HIGH
    Blynk.virtualWrite(V8, 1);  // Turn the widget attached to V8 On

  } else {
    // execute this code if the switch widget is now OFF
    digitalWrite(Pump, LOW);  // Set digital Pump LOW
    Blynk.virtualWrite(V8, 0);  // Turn the widget attached to V8 Off
  }
}

BLYNK_CONNECTED() {
  Blynk.syncVirtual(V5);  // will cause BLYNK_WRITE(V5) to be executed
  Blynk.syncVirtual(V8);  // will cause BLYNK_WRITE(V8) to be executed
}

//lcd Variables
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); 

void setup() {

  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  sensors.begin();
  while (!Serial);
  pinMode(Light, OUTPUT);
  digitalWrite(Light, LOW);
  pinMode(Pump, OUTPUT);
  digitalWrite(Pump, LOW);
  pinMode(liquidLevelPin, INPUT);

  strip.begin();            // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();             // Turn OFF all pixels ASAP
  strip.setBrightness(50);  // Set BRIGHTNESS to about 1/5 (max = 255)

  // first run the example from the following path: file, examples, DS1307RTC, to set the time of the RTC, then upload this sketch
  setSyncProvider(RTC.get);  // the function to get the time from the RTC
  if (timeStatus() != timeSet)
    Serial.println("Unable to sync with the RTC");
  else
    Serial.println("RTC has set the system time");

  // create the alarms, to trigger at specific times
  Alarm.alarmRepeat(6, 0, 0, LightsOn);     // Lights on 6:00am every day
  Alarm.alarmRepeat(6, 0, 0, PumpOn);       // Pump on 6:00am every day
  Alarm.alarmRepeat(6, 5, 0, PumpOff);      // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(7, 5, 0, PumpOn);       // Pump on 7:05am every day
  Alarm.alarmRepeat(7, 10, 0, PumpOff);     // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(8, 10, 0, PumpOn);      // Pump on 8:10am every day
  Alarm.alarmRepeat(8, 15, 0, PumpOff);     // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(9, 15, 0, PumpOn);      // Pump on 9:15am every day
  Alarm.alarmRepeat(9, 20, 0, PumpOff);     // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(10, 20, 0, PumpOn);     // Pump on 10:20am every day
  Alarm.alarmRepeat(10, 25, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(11, 25, 0, PumpOn);     // Pump on 11:25am every day
  Alarm.alarmRepeat(11, 30, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(12, 30, 0, PumpOn);     // Pump on 12:30pm every day
  Alarm.alarmRepeat(12, 35, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(13, 35, 0, PumpOn);     // Pump on 1:35pm every day
  Alarm.alarmRepeat(13, 40, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(14, 40, 0, PumpOn);     // Pump on 2:40pm every day
  Alarm.alarmRepeat(14, 45, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(15, 45, 0, PumpOn);     // Pump on 3:45pm every day
  Alarm.alarmRepeat(15, 50, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(16, 50, 0, PumpOn);     // Pump on 4:50pm every day
  Alarm.alarmRepeat(16, 55, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(17, 55, 0, PumpOn);     // Pump on 5:55pm every day
  Alarm.alarmRepeat(18, 00, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(19, 00, 0, LightsOff);  // Lights off at 7:00pm every day, remain off until 6:00am
  Alarm.alarmRepeat(19, 00, 0, PumpOn);     // Pump on 7:00pm every day
  Alarm.alarmRepeat(19, 05, 0, PumpOff);    // Pump runs for 5 min. and then off every day
  Alarm.alarmRepeat(20, 05, 0, PumpOn);     // Pump on 8:05pm every day
  Alarm.alarmRepeat(20, 15, 0, PumpOff);    // Pump runs for 5 min. and then off unitl 6:00am every day

  lcd.begin(20, 4);
  gravityTds.setPin(TdsSensorPin);
  gravityTds.setAref(5.0);       //reference voltage on ADC, default 5.0V on Arduino UNO
  gravityTds.setAdcRange(1024);  //1024 for 10bit ADC;4096 for 12bit ADC; 256 for 8 bit
  gravityTds.begin();            //initialization
  int waterValue = analogRead(liquidLevel);
  dht.begin();

  timer.setInterval(1000L, TDSValues);
  timer.setInterval(1000L, DHT22Values);
  timer.setInterval(1000L, Liquidlevelvalues);
  timer.setInterval(1000L, LCDPrintValues);
  timer.setInterval(1000L, VirtualPins);
  timer.setInterval(1000L, digitalClockDisplay);
  timer.setInterval(1000L, Temprequest);
  timer.setInterval(500L, alarmdelay);





  lcd.init();       //initialize the lcd
  lcd.backlight();  //open the backlight
  lcd.setCursor(0, 0);
  lcd.print("wLevel");
  lcd.setCursor(0, 1);
  lcd.print("Humid");
  lcd.setCursor(0, 2);
  lcd.print("wTemp");
  lcd.setCursor(0, 3);
  lcd.print("aTemp");
  lcd.setCursor(16, 0);
  lcd.print("TDS");
}

void loop() {
  Blynk.run();
  timer.run();
  
}

//End Void Loop

void VirtualPins() {
  Blynk.virtualWrite(V0, liquidLevel);                            //water level vpin
  Blynk.virtualWrite(V1, tdsValue);                               //tds vpin
  Blynk.virtualWrite(V3, temp);                                   //aTemp vpin
  Blynk.virtualWrite(V2, hum);                                    //humidity vpin
  Blynk.virtualWrite(V4, sensors.getTempCByIndex(0) * 1.8 + 32);  //wtemp vpin
  Blynk.virtualWrite(V10, rawLiquidReading);                      //humidity vpin
}

void LCDPrintValues() {
  lcd.setCursor(8, 0);        //Water Level
  lcd.print(liquidLevel, 0);  //Water Level value displayed on lcd
  lcd.setCursor(12, 0);       //Percent symbol location
  lcd.print("%");             //Percentage symblol
  lcd.setCursor(16, 1); //TDS Level
  lcd.print(tdsValue, 0); ///tds value displayed on lcd
  lcd.setCursor(16, 2);                                 //ppm location
  lcd.print("PPM");                                     //Percentage symblol
  lcd.setCursor(8, 3);                                  //aTemp value
  lcd.print(temp, 0);                                   //avtemperaturevvalue displayed on lcd
  lcd.setCursor(11, 3);                                 //Degree Symbol location
  lcd.print((char)223);                                 //Degree Symbol
  lcd.setCursor(12, 3);                                 //Temperature Symbol location
  lcd.print("F");                                       //Temperature Symbol
  lcd.setCursor(8, 1);                                  //humidity value
  lcd.print(hum, 0);                                    //humidity Level value displayed on lcd
  lcd.setCursor(12, 1);                                 //Humidity Symbol location
  lcd.print("%");                                       //Humidity Symbol
  lcd.setCursor(8, 2);                                  //Water Temp Location
  lcd.print(sensors.getTempCByIndex(0) * 1.8 + 32, 0);  //Water Temp Value
  lcd.setCursor(11, 2);                                 //wDegree Symbol location
  lcd.print((char)223);                                 //wtem Degree Symbol
  lcd.setCursor(12, 2);                                 //wTaemperature Symbol location
  lcd.print("F  ");                                     //wTemperature Symbol
}

void Temprequest() {
 sensors.requestTemperatures(); 
}

void alarmdelay() {
 Alarm.delay(500); 
}

void Liquidlevelvalues() {
  rawLiquidReading = analogRead(liquidLevelPin);
  Serial.print("Raw Liquid Level: ");
  Serial.print(rawLiquidReading);

  liquidLevel = map(rawLiquidReading, lowEtapeValue, highEtapeValue, 0, 100);
  Serial.print(" / Liquid Remaining: ");
  Serial.print(liquidLevel);
  Serial.println("%.");

  if (liquidLevel > 20 && liquidLevel < 50) {
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(0, 150, 0));
    strip.show();
  }

  else if (liquidLevel >= 50) {
    strip.clear();
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(0, 0, 150));
    strip.show();
  }

  else if (liquidLevel <= 20) {
    strip.clear();
    for (int i = 0; i < 20; i++)
      strip.setPixelColor(i, strip.Color(255, 0, 0));
    strip.show();
  }
}

void DHT22Values() {
  hum = dht.readHumidity();
  temp = dht.readTemperature() * 1.8 + 32;
}

void TDSValues() {
  gravityTds.setTemperature(sensors.getTempCByIndex(0));  // set the temperature and execute temperature compensation
  gravityTds.update();                                    //sample and calculate
  tdsValue = gravityTds.getTdsValue();                    // then get the value
}

void LightsOn() {
  Serial.println("Alarm: - turn lights On");
  digitalWrite(Light, HIGH);
}

void LightsOff() {
  Serial.println("Alarm: - turn lights Off");
  digitalWrite(Light, LOW);
}

void PumpOn() {
  Serial.println("Alarm: - turn lights On");
  digitalWrite(Pump, HIGH);
}

void PumpOff() {
  Serial.println("Alarm: - turn lights Off");
  digitalWrite(Pump, LOW);
}

void digitalClockDisplay() {
  // digital clock display of the time

  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println();
}

void printDigits(int digits) {
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if (digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void colorWipe(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) {  // For each pixel in strip...
    strip.setPixelColor(i, color);               //  Set pixel's color (in RAM)
    strip.show();                                //  Update strip to match
    delay(wait);                                 //  Pause for a moment
  }
}

It’s not a good idea having all of your timers being called at exactly the same time. Your board isn’t capable of multi tasking, so you’re effectively queueing all of these tasks one after another. BlynkTimer will drop incomplete tasks in some situations when you do this.

See the “Staggering Timers” section of this tutorial for info on potential solutions…

Also, I’d be inclined to add these virtualWrites into the functions that take the various readings rather than having this timed function…

That’s because the functions called by your alarms don’t have any code in them to update the button statuses.
For example this….

Should probably look something like this…

void LightsOn() {
  Serial.println("Alarm: - turn lights On");
  digitalWrite(Light, HIGH);
  Blynk.virtualWrite(V5, 1); // update the Light button widget
}

Pete.

Hello Pete, sorry for the delayed response but the project had to be put on hold for a little while. However, I think I have your suggestions implemented correctly and the apps is now working as I would like so Thank you for your patience and support throughout getting this corrected. I do have a few bugs that I am trying to work out now which is where the app keeps going offline after a couple of hours and my LCD does not print the correct data output (Data within Blynk is correct). I think since I am using a Uno R2 Wifi is why my LCD data is weird. I changed my port to 8080 and going to see if that helps with the connection issue. If I can’t resolve these topics, I will start a new post in the respective forum. Again, Thank you very much!

#define BLYNK_TEMPLATE_ID "TMPLb8Oed55o"
#define BLYNK_DEVICE_NAME "HYDROPONIC"
#define BLYNK_AUTH_TOKEN "3tuBaNOnIw2nXi6x-Xa4C8nY67Hvxp3z"

//temphumid Variables

#include <DHT.h>
#define DHTTYPE DHT22  // DHT 22 (AM2302), AM2321
#define DHTPIN 2
DHT dht(DHTPIN, DHTTYPE);
int chk;
float hum;   //Stores humidity value
float temp;  //Stores temperature value

//LED Variables
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>  // Required for 16 MHz Adafruit Trinket
#endif
#define LED_PIN 6
#define LED_COUNT 17
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

//Liquid level variables
int rawLiquidReading;
float liquidLevel;
const long lowEtapeValue = 0;
const long highEtapeValue = 850;
const byte liquidLevelPin = A1;

//Pump and light Variables
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>;
#include <DS1307RTC.h>
#include <TimeLib.h>  //added from the TimeRTCSet
int Light = 8;
int Pump = 12;
AlarmId id;

//TDS Variables
#include <EEPROM.h>
#include "GravityTDS.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 7
#define TdsSensorPin A0
OneWire oneWire(ONE_WIRE_BUS);
GravityTDS gravityTds;
DallasTemperature sensors(&oneWire);
float tdsValue = 0;

//Blynk_Wifi Variables
#include <BlynkSimpleWiFiNINA.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFiNINA.h>
char ssid[] = "xxxxx";
char pass[] = "xxxxxx";
char auth[] = "xxxxxx";
BlynkTimer timer;
BLYNK_WRITE(V5)  // Executes when the value of virtual pin 5 changes
{
  if (param.asInt() == 1) {
    digitalWrite(Light, HIGH);  // Set Light HIGH
    Blynk.virtualWrite(V5, 1);  // Turn the widget attached to V5 On

  } else {
    // execute this code if the switch widget is now OFF
    digitalWrite(Light, LOW);  // Set Light LOW
    Blynk.virtualWrite(V5, 0);  // Turn the widget attached to V5 Off
  }
}
BLYNK_WRITE(V8)  // Executes when the value of virtual pin V8 changes
{
  if (param.asInt() == 1) {
    // execute this code if the switch widget is now ON
    digitalWrite(Pump, HIGH);  // Set Pump HIGH
    Blynk.virtualWrite(V8, 1);  // Turn the widget attached to V8 On

  } else {
    // execute this code if the switch widget is now OFF
    digitalWrite(Pump, LOW);  // Set digital Pump LOW
    Blynk.virtualWrite(V8, 0);  // Turn the widget attached to V8 Off
  }
}

BLYNK_CONNECTED() {
  Blynk.syncVirtual(V5);  // will cause BLYNK_WRITE(V5) to be executed
  Blynk.syncVirtual(V8);  // will cause BLYNK_WRITE(V8) to be executed
}

//lcd Variables
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
const int LCD_COLS = 20;
const int LCD_ROWS = 4;

void setup() {

  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  int status;
  status = lcd.begin(LCD_COLS, LCD_ROWS);
  if (status) // non zero status means it was unsuccesful
  {
    // hd44780 has a fatalError() routine that blinks an led if possible
    // begin() failed so blink error code using the onboard LED if possible
    hd44780::fatalError(status); // does not return
  }
    sensors.begin();
    while (!Serial);
    pinMode(Light, OUTPUT);
    digitalWrite(Light, LOW);
    pinMode(Pump, OUTPUT);
    digitalWrite(Pump, LOW);
    pinMode(liquidLevelPin, INPUT);

    strip.begin();            // INITIALIZE NeoPixel strip object (REQUIRED)
    strip.show();             // Turn OFF all pixels ASAP
    strip.setBrightness(50);  // Set BRIGHTNESS to about 1/5 (max = 255)

    // first run the example from the following path: file, examples, DS1307RTC, to set the time of the RTC, then upload this sketch
    setSyncProvider(RTC.get);  // the function to get the time from the RTC
    if (timeStatus() != timeSet)
      Serial.println("Unable to sync with the RTC");
    else
      Serial.println("RTC has set the system time");

    // create the alarms, to trigger at specific times
    Alarm.alarmRepeat(6, 0, 0, LightsOn);     // Lights on 6:00am every day
    Alarm.alarmRepeat(6, 0, 0, PumpOn);       // Pump on 6:00am every day
    Alarm.alarmRepeat(6, 5, 0, PumpOff);      // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(7, 5, 0, PumpOn);       // Pump on 7:05am every day
    Alarm.alarmRepeat(7, 10, 0, PumpOff);     // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(8, 10, 0, PumpOn);      // Pump on 8:10am every day
    Alarm.alarmRepeat(8, 15, 0, PumpOff);     // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(9, 15, 0, PumpOn);      // Pump on 9:15am every day
    Alarm.alarmRepeat(9, 20, 0, PumpOff);     // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(10, 20, 0, PumpOn);     // Pump on 10:20am every day
    Alarm.alarmRepeat(10, 25, 0, PumpOff);    // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(11, 25, 0, PumpOn);     // Pump on 11:25am every day
    Alarm.alarmRepeat(11, 30, 0, PumpOff);    // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(12, 30, 0, PumpOn);     // Pump on 12:30pm every day
    Alarm.alarmRepeat(12, 35, 0, PumpOff);    // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(13, 35, 0, PumpOn);     // Pump on 1:35pm every day
    Alarm.alarmRepeat(13, 40, 0, PumpOff);    // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(14, 40, 0, PumpOn);     // Pump on 2:40pm every day
    Alarm.alarmRepeat(14, 45, 0, PumpOff);    // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(15, 45, 0, PumpOn);     // Pump on 3:45pm every day
    Alarm.alarmRepeat(15, 50, 0, PumpOff);    // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(16, 50, 0, PumpOn);     // Pump on 4:50pm every day
    Alarm.alarmRepeat(16, 55, 0, PumpOff);    // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(17, 55, 0, PumpOn);     // Pump on 5:55pm every day
    Alarm.alarmRepeat(18, 00, 0, PumpOff);    // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(19, 00, 0, LightsOff);  // Lights off at 7:00pm every day, remain off until 6:00am
    Alarm.alarmRepeat(19, 00, 0, PumpOn);     // Pump on 7:00pm every day
    Alarm.alarmRepeat(19, 05, 0, PumpOff);    // Pump runs for 5 min. and then off every day
    Alarm.alarmRepeat(20, 05, 0, PumpOn);     // Pump on 8:05pm every day
    Alarm.alarmRepeat(20, 15, 0, PumpOff);    // Pump runs for 5 min. and then off unitl 6:00am every day

  
    gravityTds.setPin(TdsSensorPin);
    gravityTds.setAref(5.0);       //reference voltage on ADC, default 5.0V on Arduino UNO
    gravityTds.setAdcRange(1024);  //1024 for 10bit ADC;4096 for 12bit ADC; 256 for 8 bit
    gravityTds.begin();            //initialization
    int waterValue = analogRead(liquidLevel);
    dht.begin();

    timer.setInterval(300000L, TDSValues);//10000
    timer.setInterval(333333L, DHT22Values);//11128L
    timer.setInterval(1777L, Liquidlevelvalues);//1533L
    timer.setInterval(1373L, LCDPrintValues);//1000
    timer.setInterval(333333L, digitalClockDisplay);//1370L
    timer.setInterval(3793L, Temprequest);//1137L
    timer.setInterval(523L, alarmdelay);//528

    lcd.setCursor(5, 0);
    lcd.print("Water Level");
    lcd.setCursor(3, 2);
    lcd.print("Nutrient Level");
  }

  void loop() {
    Blynk.run();
    timer.run();

  }

  //End Void Loop

  void LCDPrintValues() {
    if (liquidLevel < 100)
      lcd.print("  ");
    if (liquidLevel < 10)
      lcd.print("  ");
    lcd.setCursor(7, 1); //Water Level
    lcd.print(liquidLevel, 0);  //Water Level value displayed on lcd
    lcd.setCursor(10, 1);       //Percent symbol location
    lcd.print(" %  ");             //Percentage symblol
    lcd.setCursor(6, 3); //TDS Level
    lcd.print(tdsValue, 0); ///tds value displayed on lcd
    lcd.setCursor(11, 3);                                 //ppm location
    lcd.print("PPM");                                     //Percentage symbol
  }

  void Temprequest() {
    sensors.requestTemperatures();
  }

  void alarmdelay() {
    Alarm.delay(500);
  }

  void Liquidlevelvalues() {
    rawLiquidReading = analogRead(liquidLevelPin);
    Blynk.virtualWrite(V0, liquidLevel);                  //water level vpin
    Blynk.virtualWrite(V10, rawLiquidReading);            //humidity vpin
    liquidLevel = map(rawLiquidReading, lowEtapeValue, highEtapeValue, 0, 100);

    if (liquidLevel > 20 && liquidLevel < 50) {
      for (int i = 0; i < 20; i++)
        strip.setPixelColor(i, strip.Color(0, 150, 0));
      strip.show();
    }

    else if (liquidLevel >= 50) {
      strip.clear();
      for (int i = 0; i < 20; i++)
        strip.setPixelColor(i, strip.Color(0, 0, 150));
      strip.show();
    }

    else if (liquidLevel <= 20) {
      strip.clear();
      for (int i = 0; i < 20; i++)
        strip.setPixelColor(i, strip.Color(255, 0, 0));
      strip.show();
    }
  }

  void DHT22Values() {
    hum = dht.readHumidity();
    temp = dht.readTemperature() * 1.8 + 32;
    Blynk.virtualWrite(V3, temp);                                   //aTemp vpin
    Blynk.virtualWrite(V2, hum);                                    //humidity vpin
  }

  void TDSValues() {
    gravityTds.setTemperature(sensors.getTempCByIndex(0));  // set the temperature and execute temperature compensation
    gravityTds.update();                                    //sample and calculate
    tdsValue = gravityTds.getTdsValue();                    // then get the value
    Blynk.virtualWrite(V1, tdsValue);                       //tds vpin
    Blynk.virtualWrite(V4, sensors.getTempCByIndex(0) * 1.8 + 32);  //wtemp vpin
  }

  void LightsOn() {
    digitalWrite(Light, HIGH);
    Blynk.virtualWrite(V5, 1); // update the Light button widget
  }

  void LightsOff() {
    digitalWrite(Light, LOW);
    Blynk.virtualWrite(V5, 0); // update the Light button widget
  }

  void PumpOn() {
    digitalWrite(Pump, HIGH);
    Blynk.virtualWrite(V8, 1); // update the Light button widget
  }

  void PumpOff() {
    digitalWrite(Pump, LOW);
    Blynk.virtualWrite(V8, 0); // update the Light button widget
  }

  void digitalClockDisplay() {
    // digital clock display of the time
    printDigits(minute());
    printDigits(second());
  }

  void printDigits(int digits) {
    // utility function for digital clock display: prints preceding colon and leading 0
    Serial.print(":");
    if (digits < 10)
      Serial.print('0');
    Serial.print(digits);
  }

  void colorWipe(uint32_t color, int wait) {
    for (int i = 0; i < strip.numPixels(); i++) {  // For each pixel in strip...
      strip.setPixelColor(i, color);               //  Set pixel's color (in RAM)
      strip.show();                                //  Update strip to match
      delay(wait);                                 //  Pause for a moment
    }
  }

I’m not sure that I follow the logic in that statement.
It could be why you’re getting disconnections though.

It’s not really clear from your strangely staggers timers exactly what it is that you are trying to achieve with your LCD.
I think you’’d be better having a simpler structure which takes say a temperature reading, updated the result to Blynk and also displays the result to the LCD. Then, after a given time you take a different reading, update it to Blynk and the LCD etc. etc.

I find your code difficult to read because of the way you’ve structured it, and the comments aren’t very meaningful.
I’d always recommend grouping all of your #include library commands together near the top of the code, with a note next to each about why it’s included (if that isn’t obvious) and a link to where the file came from. It’s also sensible to note the version of the library that was used

With BLYNK_WRITE callbacks, teg comments should be about what type of widget is attached to the datastream and what it’s used for (pump on/off switch for example).

You’ve also done some copy/pasting of code without updating the comments too…

The thing that is needed the most though is some in-code narrative about what all of your timers are doing, and why.

Pete.

From what I have ran across from trying to troubleshoot the issue is that the I2C backpacks on the LCD do not communicate well with the Rev. 2 Uno Wifi which have a megavr chip.

The timers are staggered based on how often I need the data and to try to minimize any overlaps where multiple timers are queued at the same time. Maybe my interpretation is wrong based on what I read on the Simple Timer link you provided. I don’t need to update the values on most of the sensors that often which is why I have them set to several minutes apart. However, I would like to know the water level within seconds because this will give me somewhat instant feedback while I am re-filling the reservoir. I personally do not like how they are staggered and would think there is a better approach to it other than how I have it.

I agree, the structure is not standardized. It is the result of me doing bench test on each sensor before combining them into one sketch. It kept it separated to help me troubleshoot issues. I know it drives those who code in much more detail crazy so I apologize in advance.

I will take your points and apply them and provide an update.