BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk and Nextion


#15

And what is the exact error the complier is giving??


#16

this is the error i get from the complier
`

C:\Users\Adam\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h: In function ‘email.constprop’:

C:\Users\Adam\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:201:5: internal compiler error: Segmentation fault

 }

 ^

Please submit a full bug report,

with preprocessed source if appropriate.

See http://gcc.gnu.org/bugs.html for instructions.

lto-wrapper.exe: fatal error: C:\Users\Adam\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\5.4.0-atmel3.6.1-arduino2/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/users/adam/appdata/local/arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/…/lib/gcc/avr/5.4.0/…/…/…/…/avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
`


#17

Could be that there are circle references in the code that cause the compile to fail that way.
Could you provide the full code for a test?


#19
#include <Nextion.h>  // Include the nextion library (the official one) https://github.com/itead/ITEADLIB_Arduino_Nextion
                      // Make sure you edit the NexConfig.h file on the library folder to set the correct serial port for the display.
                      // By default it's set to Serial1, which most arduino boards don't have.
                      // Change "#define nexSerial Serial1" to "#define nexSerial Serial" if you are using arduino uno, nano, etc.
#include "NexTouch.h"
#include "NexHardware.h"

#define BLYNK_PRINT Serial // Enables Serial Monitor
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h> // This part is for Ethernet stuff
#define W5100_CS  10
#define SDCARD_CS 4
#include <TimeLib.h>
#include <WidgetRTC.h>
char auth[] = "d27bf6f0a098498a81a5c65dab79b851"; // Put your Auth Token here.
BlynkTimer timer;
WidgetRTC rtc;
//Temperature 
#include <OneWire.h> // Get 1-wire Library here: http://www.pjrc.com/teensy/td_libs_OneWire.html
//Get DallasTemperature Library here:  http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library
#include <DallasTemperature.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define ONE_WIRE_BUS 48// DS18B20 on arduino pin
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
// This function will run every time Blynk connection is established
DeviceAddress Probe01 = { 0x28, 0xFF, 0x2D, 0x5A, 0xC4, 0x17, 0x05, 0xEF  }; 
DeviceAddress Probe02 = { 0x28, 0x1F, 0x12, 0x77, 0x91, 0x0A, 0x02, 0x68 };
float tanktemp;
float sumptemp;

BLYNK_CONNECTED() {
 rtc.begin();
 // Request Blynk server to re-send latest values for all pins
Blynk.syncAll();
}

//***********************************************************************ATO DECLIRATION******************************************************************************************
byte lowWaterPin = 6;    // Goes LOW when water below switch
byte highWaterPin = 7;   // Goes LOW when water below switch
byte pumpPin = 8;        // Relay to control the water pump
unsigned long maxRunTime = 60 * 1000L;   // pump on for max of one minute
unsigned long minOffTime = 60 * 60 * 1000L;  // pump must be off for at least one hour
unsigned long switchDebounceTime = 3 * 1000L;  // Switch must be activated for at least 3 seconds.
unsigned long lastPumpTime = 0;
unsigned long lastLowWaterDetectTime = 0;
boolean lastLowWaterState = HIGH;
boolean pumpRunning = false;
//************************************************************************RELAY'S DECLIRATION**************************************************************************
int relayPin = 49;// Heater on ssr1
int relay2Pin = 28;// Cooling to 16ch relay board relay 7 on the board
int relay3Pin = 22;// return pump on relay 1 on the board
int relay4Pin = 23;// Skimmer on relay 2 on the board
int relay5Pin = 24;// Reactor on relay 3 on the board
int relay6Pin = 25;// t5s on relay 4 on the board
int wave1Pin = 47;// Wave maker on ssr2 
int wave2Pin = 46;// Wavemaker 2 on ssr3
//***************************************************************TEMPERATURE DECLIRATION*********************************************************************************
float desiredTemp = 26;// Set this to your desired temp
float tempDiff = 1;// This variable provides a small +/- temp differential that will prevent constant relay switching.
bool      tempAlarmFlag    = false;      //flag to alarm, and avoid multiple Notification
bool      faultyProbeFlag  = false;      //flag to alarm, and avoid multiple Notification
float lowAlarm     = NAN;
float highAlarm    = NAN;
int onsec =3;                // 
int offsec=3;                // 
int x;
int y;
int CounterOn = 0;
int CounterOff = 0;
int ledStatus = 0;
int wavesw = 1;// Wave maker Onoff Button
int heatersw = 1;// Heater Onoff Button
int coolingsw = 1;// Cooling switch
char Date[16];
char Time[16];
//**************************************************************LEDS DECLIRATION*********************************************************************************************************
long startseconds = 0;         // start time in seconds
long stopseconds = 0;          // stop  time in seconds
long nowseconds = 0;           // time  now  in seconds
int fadetime = 0;
long fadetimeseconds = 0;
long fadetimemillis = 0;
int manual=0;// auto or manual for lighting 
int minPWM = 1;// variable for min PWM value. keep at 1 to avoid crashing the ledFade()
byte fadeIncrement = 1; //How smooth to fade? Uses all 4095 steps available.

int maxPWM0 = 0; // variable for max PWM value attached to BLYNK Virtual pin.
int maxPWM1 = 0; // variable for max PWM value attached to BLYNK Virtual pin.

int currentFadePosition0 = 0;// don't change this!
int currentFadePosition1 = 0;// don't change this!

unsigned long previousFadeMillis0;// millis() timing Variable, just for fading
unsigned long previousFadeMillis1;// millis() timing Variable, just for fading

long stepWaitTime0 = 0;  //How long to watch the clock before incrementing to the next step. (time in milliseconds)
long stepWaitTime1 = 0;  //How long to watch the clock before incrementing to the next step. (time in milliseconds)

int desiredledLevel0 = 0;
int desiredledLevel1 = 0;
int desiredledLevel2 = 0;
int desiredledLevel3 = 0;
int desiredledLevel4 = 0;
int desiredledLevel5 = 0;
int desiredledLevel6 = 0;
int desiredledLevel7 = 0;

#define led0  2 // white leds on pin... 
#define led1  3 // blue leds on pin...

//********************************************************************NEXTION DECLIRATION**************************************************************************************
int CurrentPage = 0;  // Create a variable to store which page is currently loaded


// Declare objects that we are going to read from the display. This includes buttons, sliders, text boxes, etc:
// Format: <type of object> <object name> = <type of object>(<page id>, <object id>, "<object name>");
/* ***** Types of objects:
 * NexButton - Button
 * NexDSButton - Dual-state Button
 * NexHotspot - Hotspot, that is like an invisible button
 * NexCheckbox - Checkbox
 * NexRadio - "Radio" checkbox, that it's exactly like the checkbox but with a rounded shape
 * NexSlider - Slider
 * NexGauge - Gauge
 * NexProgressBar - Progress Bar
 * NexText - Text box
 * NexScrolltext - Scroll text box
 * NexNumber - Number box
 * NexVariable - Variable inside the nextion display
 * NexPage - Page touch event
 * NexGpio - To use the Expansion Board add-on for Enhanced Nextion displays
 * NexRtc - To use the real time clock for Enhanced Nextion displays
 * *****
 */


NexSlider h0 = NexSlider(0, 1, "h0");// slider added, unlock slider

NexText Temperaturepg = NexText(1, 13, "Temperaturepg");// number box added, temperture on homescreen
NexText t0 = NexText(1, 14, "t0");// number box added, hour on timer, homescreen
NexText t1 = NexText(1, 15, "t1");// number box added, minute on homescreen
NexText t2 = NexText(1, 16, "t2");// number box added, second on homescreen
NexHotspot m0 = NexHotspot(1, 1, "m0");// hotspot added, settings button
NexHotspot m1 = NexHotspot(1, 2, "m1");// hotspot added, on off page 1 button
NexHotspot m2 = NexHotspot(1, 3, "m2");// hotspot added, feed button
NexHotspot m3 = NexHotspot(1, 4, "m3");// hotspot added, lighting button
NexHotspot m4 = NexHotspot(1, 10, "m4");// hotspot added, lockscreen button
NexHotspot m5 = NexHotspot(2, 1, "m5");// hotspot added, Homebutton in settings 
NexHotspot m6 = NexHotspot(2, 3, "m6");// hotspot added, Wavemaker button in settings 
NexHotspot m7 = NexHotspot(2, 4, "m7");// hotspot added, Dosing pumps button in settings 
NexHotspot m8 = NexHotspot(2, 5, "m8");// hotspot added, Temperature button in settings
NexHotspot m9 = NexHotspot(2, 6, "m9");// hotspot added, Lighting button in settings
NexHotspot m10 = NexHotspot(2, 2, "10");// hotspot added, Next settings pagein settings
NexHotspot m11 = NexHotspot(3, 1, "m11");// hotspot added, home button on page 2 of settings 
NexHotspot m12 = NexHotspot(3, 2, "m12");// hotspot added, Back button on page 2 of settings
NexHotspot m13 = NexHotspot(3, 3, "m13");// hotspot added, Time and date settings on page 2 f settings
NexHotspot m14 = NexHotspot(3, 4, "m14");// hotspot added, Screen settings on page 2 of settings
NexHotspot m15 = NexHotspot(5, 2, "m15");// hotspot added, Home button on screen brightness page.
NexHotspot m16 = NexHotspot(5, 3, "m16");// hotspot added, Sceen brightness next page.
NexButton b1 = NexButton(6, 2, "b1");  // Button added
NexDSButton bt0 = NexDSButton(6, 3, "bt0");  // Dual state button added, Return pump Button
NexDSButton bt1 = NexDSButton(6, 4, "bt1");  // Dual state button added, Skimmer button
NexDSButton bt2 = NexDSButton(6, 5, "bt2");  // Dual state button added, Reactor button
NexDSButton bt3 = NexDSButton(6, 6, "bt3");  // Dual state button added, Heating button
NexDSButton bt4 = NexDSButton(6, 7, "bt4");  // Dual state button added, Cooling button 
NexDSButton bt5 = NexDSButton(6, 8, "bt5");  // Dual state button added, Wave maker button
NexDSButton bt6 = NexDSButton(7, 3, "bt6");  // Dual state button added, T5'ss
NexDSButton bt7 = NexDSButton(7, 4, "bt7");  // Dual state button added, LED's
NexDSButton bt8 = NexDSButton(1, 11, "bt8");  // Dual state button added, Skimmer button
NexDSButton bt9 = NexDSButton(1, 12, "bt9");  // Dual state button added, Skimmer button
NexDSButton bt10 = NexDSButton(1, 13, "bt10");  // Dual state button added, Skimmer button
NexDSButton bt11 = NexDSButton(1, 14, "bt11");  // Dual state button added, Skimmer button
NexDSButton bt12 = NexDSButton(1, 15, "bt12");  // Dual state button added, Skimmer button
NexDSButton bt13 = NexDSButton(1, 16, "bt13");  // Dual state button added, Skimmer button


// Declare pages:
// Sending data to the display to nonexistent objects on the current page creates an error code sent by the display.
// Any error sent by the display creates lag on the arduino loop because arduino tries to read it, thinking it's a touch event.
// So to avoid this, I am only going to send data depending on the page the display is on.
// That's the reason I want the arduino to know which page is loaded on the display.
// To let arduino know what page is currently loaded, we are creating a touch event for each page.
// On the nextion project, each page most send a simulated "Touch Press Event" in the "Preinitialize Event" section so
// we can register that a new page was loaded.
NexPage page0 = NexPage(0, 0, "page0");  // Page added as a touch event
NexPage page1 = NexPage(1, 0, "page1");  // Page added as a touch event
NexPage page2 = NexPage(2, 0, "page2");  // Page added as a touch event, Settings
NexPage page3 = NexPage(3, 0, "page3");  // Page added as a touch event, More Settings
NexPage page4 = NexPage(4, 0, "page4");  // Page added as a touch event, Set Time 
NexPage page5 = NexPage(5, 0, "page5");  // Page added as a touch event, Brightness
NexPage page6 = NexPage(6, 0, "page6");  // Page added as a touch event, On Off Page 1
NexPage page7 = NexPage(7, 0, "page7");  // Page added as a touch event, On Off Page 2
NexPage page8 = NexPage(8, 0, "page8");  // Page added as a touch event, Temperature
NexPage page9 = NexPage(1, 0, "page9");  // Page added as a touch event, Lighting





// Declare touch event objects to the touch event list: 
// You just need to add the names of the objects that send a touch event.
// Format: &<object name>,

NexTouch *nex_listen_list[] = 
{
  &b1,  // Button added
  &bt0,  // Dual state button added
  &bt1,  // Dual state button added
  &bt2,  // Dual state button added
  &bt3,  // Dual state button added
  &bt4,  // Dual state button added
  &bt5,  // Dual state button added
  &bt6,  // Dual state button added
  &bt7,  // Dual state button added
  &bt8,  // Dual state button added, led for return pump, home screen
  &bt9,  // Dual state button added, led for skimmer, home screen
  &bt10,  // Dual state button added, led for reactor, home screen
  &bt11,  // Dual state button added, led for heatig,home screen
  &bt12,  // Dual state button added, led for cooling, home screen
  &bt13,  // Dual state button added  led for wavemakers, home screen
  &page0,  // Page added as a touch event
  &page1,  // Page added as a touch event
  &page2,  // Page added as a touch event
  &page3,  // Page added as a touch event
  &page4,  // Page added as a touch event
  &page5,  // Page added as a touch event
  &page6,  // Page added as a touch event
  &page7,  // Page added as a touch event
  &page8,  // Page added as a touch event
  &page9,  // Page added as a touch event
  &h0,     // slider added as touch event
  &m0,     // hotspot added as a touch event
  &m1,     // hotspot added as a touch event
  &m2,     // hotspot added as a touch event
  &m3,     // hotspot added as a touch event
  &m4,     // hotspot added as a touch event 
  NULL  // String terminated
};  // End of touch event list







////////////////////////// Touch events:
// Each of the following sections are going to run everytime the touch event happens:
// Is going to run the code inside each section only ones for each touch event.

void b1PushCallback(void *ptr)  // Press event for button b1
{
  digitalWrite(13, HIGH);  // Turn ON internal LED
}  // End of press event





void b1PopCallback(void *ptr)  // Release event for button b1
{
  digitalWrite(13, LOW);  // Turn OFF internal LED
}  // End of release event







void bt0PushCallback(void *ptr)  // Press event for dual state button bt0, Return pump
{
   uint32_t number5 = 0;  // Create variable to store value we are going to get
  bt0.getValue(&number5);  // Read value of dual state button to know the state (0 or 1)
  if(number5 == 1){  // If dual state button is equal to 1 (meaning is ON)...
    Blynk.virtualWrite(V1, HIGH);
    Blynk.syncVirtual(V1);
  }else{  // Since the dual state button is OFF...
    Blynk.virtualWrite(V1, LOW);
    Blynk.syncVirtual(V1);
  }
}  // End of press event



void bt1PushCallback(void *ptr) // Press event for dual state button bt1, Skimmer
{
  uint32_t number6 = 0;  // Create variable to store value we are going to get
  bt1.getValue(&number6);  // Read value of dual state button to know the state (0 or 1)

  if(number6 == 1){  // If dual state button is equal to 1 (meaning is ON)...
    Blynk.virtualWrite(V2, HIGH);
      Blynk.syncVirtual(V2);
  }else{  // Since the dual state button is OFF...
    Blynk.virtualWrite(V2, LOW);
      Blynk.syncVirtual(V2);
  }
}  // End of press event

void bt2PushCallback(void *ptr) // Press event for dual state button bt2, Reactor
{
  uint32_t number7 = 0;  // Create variable to store value we are going to get
  bt2.getValue(&number7);  // Read value of dual state button to know the state (0 or 1)

  if(number7 == 1){  // If dual state button is equal to 1 (meaning is ON)...
    Blynk.virtualWrite(V3, HIGH);
      Blynk.syncVirtual(V3);
  }else{  // Since the dual state button is OFF...
    Blynk.virtualWrite(V3, LOW);
      Blynk.syncVirtual(V3);
  }
}  // End of press event

void bt3PushCallback(void *ptr) // Press event for dual state button bt3, Heater
{
  uint32_t number8 = 0;  // Create variable to store value we are going to get
  bt3.getValue(&number8);  // Read value of dual state button to know the state (0 or 1)

  if(number8 == 1){  // If dual state button is equal to 1 (meaning is ON)...
    Blynk.virtualWrite(V8, HIGH);
  }else{  // Since the dual state button is OFF...
    Blynk.virtualWrite(V8, LOW);
  }
}  // End of press event

void bt4PushCallback(void *ptr) // Press event for dual state button bt4, Cooling
{
  uint32_t number9 = 0;  // Create variable to store value we are going to get
  bt4.getValue(&number9);  // Read value of dual state button to know the state (0 or 1)

  if(number9 == 1){  // If dual state button is equal to 1 (meaning is ON)...
    //Blynk.virtualWrite(V9, HIGH);
  }else{  // Since the dual state button is OFF...
    //Blynk.vitualWrite(V9, LOW);
  }
}  // End of press event

void bt5PushCallback(void *ptr) // Press event for dual state button bt5, Cooling
{
  uint32_t number10 = 0;  // Create variable to store value we are going to get
  bt5.getValue(&number10);  // Read value of dual state button to know the state (0 or 1)

  if(number10 == 1){  // If dual state button is equal to 1 (meaning is ON)...
    //Blynk.virtualWrite(V6, HIGH);
  }else{  // Since the dual state button is OFF...
    //Blynk.vitualWrite(V6, LOW);
  }
}  // End of press event

void bt6PushCallback(void *ptr) // Press event for dual state button bt6, T5s
{
  uint32_t number11 = 0;  // Create variable to store value we are going to get
  bt5.getValue(&number11);  // Read value of dual state button to know the state (0 or 1)

  if(number11 == 1){  // If dual state button is equal to 1 (meaning is ON)...
    //Blynk.virtualWrite(V17, HIGH);
  }else{  // Since the dual state button is OFF...
    //Blynk.vitualWrite(V17, LOW);
  }
}  // End of press event

void bt7PushCallback(void *ptr) // Press event for dual state button bt7, Leds
{
  uint32_t number12 = 0;  // Create variable to store value we are going to get
  bt5.getValue(&number12);  // Read value of dual state button to know the state (0 or 1)

  if(number12 == 1){  // If dual state button is equal to 1 (meaning is ON)...
    //Blynk.virtualWrite(V6, HIGH);
  }else{  // Since the dual state button is OFF...
    //Blynk.vitualWrite(V6, LOW);
  }
}  // End of press event


// Page change event:
void page0PushCallback(void *ptr)  // If page 0 is loaded on the display, the following is going to execute:
{
  CurrentPage = 0;  // Set variable as 0 so from now on arduino knows page 0 is loaded on the display
}  // End of press event


// Page change event:
void page1PushCallback(void *ptr)  // If page 1 is loaded on the display, the following is going to execute:
{
  CurrentPage = 1;  // Set variable as 1 so from now on arduino knows page 1 is loaded on the display
}  // End of press event

// Page change event:
void page2PushCallback(void *ptr)  // If page 2 is loaded on the display, the following is going to execute:
{
  CurrentPage = 2;  // Set variable as 2 so from now on arduino knows page 1 is loaded on the display
}  // End of press event

// Page change event:
void page3PushCallback(void *ptr)  // If page 3 is loaded on the display, the following is going to execute:
{
  CurrentPage = 3;  // Set variable as 3 so from now on arduino knows page 1 is loaded on the display
}  // End of press event

// Page change event:
void page4PushCallback(void *ptr)  // If page 4 is loaded on the display, the following is going to execute:
{
  CurrentPage = 4;  // Set variable as 4 so from now on arduino knows page 1 is loaded on the display
}  // End of press event

// Page change event:
void page5PushCallback(void *ptr)  // If page 5 is loaded on the display, the following is going to execute:
{
  CurrentPage = 5;  // Set variable as 5 so from now on arduino knows page 1 is loaded on the display
}  // End of press event

// Page change event:
void page6PushCallback(void *ptr)  // If page 6 is loaded on the display, the following is going to execute:
{
  CurrentPage = 6;  // Set variable as 6 so from now on arduino knows page 1 is loaded on the display
}  // End of press event

// Page change event:
void page7PushCallback(void *ptr)  // If page 7 is loaded on the display, the following is going to execute:
{
  CurrentPage = 7;  // Set variable as 7 so from now on arduino knows page 1 is loaded on the display
}  // End of press event

// Page change event:
void page8PushCallback(void *ptr)  // If page 8 is loaded on the display, the following is going to execute:
{
  CurrentPage = 8;  // Set variable as 8 so from now on arduino knows page 1 is loaded on the display
}  // End of press event

// Page change event:
void page9PushCallback(void *ptr)  // If page 9 is loaded on the display, the following is going to execute:
{
  CurrentPage = 9;  // Set variable as 9 so from now on arduino knows page 1 is loaded on the display
}  // End of press event

//************************************************************************* LED light control***********************************************************************************************
void setLed() {

  stepWaitTime0 = (fadetimemillis / maxPWM0);
  stepWaitTime1 = (fadetimemillis / maxPWM1);


}

void ledFade0(unsigned long thisMillis0) {
  if (nowseconds < startseconds) {
    currentFadePosition0 = minPWM;
  }
  if (nowseconds > startseconds && nowseconds < stopseconds) {
    // is it time to start the Sunrise?
    // if not, nothing happens
    if (thisMillis0 - previousFadeMillis0 >= stepWaitTime0) {
      currentFadePosition0 = currentFadePosition0 + fadeIncrement;
      if (currentFadePosition0 >= maxPWM0) {
        // At max limit stop the fade
        currentFadePosition0 = maxPWM0;
      }
      // put actionable () here.
      analogWrite(led0, currentFadePosition0);
      // reset millis for the next iteration (fade timer only)
      previousFadeMillis0 = thisMillis0;
    }
  }
  if (nowseconds > stopseconds) {
    // is it time to start the Sunset yet?
    // if not, nothing happens
    if (thisMillis0 - previousFadeMillis0 >= stepWaitTime0) {
      currentFadePosition0 = currentFadePosition0 - fadeIncrement;
      if (currentFadePosition0 <= minPWM) {
        // At min limit stop the fade
        currentFadePosition0 = minPWM;
      }
      // put actionable () here
      analogWrite(led0, currentFadePosition0);
      // reset millis for the next iteration (fade timer only)
      previousFadeMillis0 = thisMillis0;
    }
  }
}
void ledFade1(unsigned long thisMillis1) {
  if (nowseconds < startseconds) {
    currentFadePosition1 = minPWM;
  }
  if (nowseconds > startseconds && nowseconds < stopseconds) {
    // is it time to start the Sunrise?
    // if not, nothing happens
    if (thisMillis1 - previousFadeMillis1 >= stepWaitTime1) {
      currentFadePosition1 = currentFadePosition1 + fadeIncrement;
      if (currentFadePosition1 >= maxPWM1) {
        // At max limit stop the fade
        currentFadePosition1 = maxPWM1;
      }
      // put actionable () here.
      analogWrite(led1, currentFadePosition1);
      // reset millis for the next iteration (fade timer only)
      previousFadeMillis1 = thisMillis1;
    }
  }
  if (nowseconds > stopseconds) {
    // is it time to start the Sunset yet?
    // if not, nothing happens
    if (thisMillis1 - previousFadeMillis1 >= stepWaitTime1) {
      currentFadePosition1 = currentFadePosition1 - fadeIncrement;
      if (currentFadePosition1 <= minPWM) {
        // At min limit stop the fade
        currentFadePosition1 = minPWM;
      }
      // put actionable () here
      analogWrite(led1, currentFadePosition1);
      // reset millis for the next iteration (fade timer only)
      previousFadeMillis1 = thisMillis1;
    }
  }
}

#20
//************************************************************************* Digital clock display of the time*******************************************************************************
void clockDisplay(){
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  nowseconds = ((hour() * 3600) + (minute() * 60) + second());
  //Serial.print("Time =");
 // Serial.println(currentTime);
 // Serial.println(currentDate);
 // Serial.print("Nowseconds =");
 // Serial.println(nowseconds);
 // Serial.print("Start = ");
 // Serial.println(startseconds);
  //Serial.print("Stop = ");
 // Serial.println(stopseconds);
 // Serial.print("fade position0 =");
 // Serial.println(currentFadePosition0);
 // Serial.println();
  // Send time to the App
  Blynk.virtualWrite(V0, currentTime);
  // Send date to the App
  //Blynk.virtualWrite(V2, currentDate);
}

BLYNK_WRITE(V10) {// slider widget to set the maximum led level from the Blynk App.
  desiredledLevel0 = param.asInt();// channel 1
  maxPWM0 = map(desiredledLevel0, 0, 100, minPWM, 1023);
}
BLYNK_WRITE(V13) {// slider widget to set the maximum led level from the Blynk App.
  desiredledLevel1 = param.asInt();// channel 2
  maxPWM1 = map(desiredledLevel1, 0, 100, minPWM, 1023);
}

BLYNK_WRITE(V14) {// slider widget to set the led fade duration up tp 3 hours.
  fadetime = param.asInt();
  fadetimeseconds = map(fadetime, 0, 180, 1, 10800);// 3 hour fade duration is max
  fadetimemillis  = map(fadetime, 0, 180, 1, 10800000);// 3 hour fade duration is max
 // Serial.print("Fade Time in seconds =");
 // Serial.println(fadetimeseconds);
}

void activetoday() {       // check if schedule should run today
  if (year() != 1970) {
    Blynk.syncVirtual(V15); // sync led timeinput widget
    Blynk.syncVirtual(V16);// sync T5s timeinput widget
    sprintf(Date, "%02d/%02d/%04d",  day(), month(), year());
    sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
    nowseconds = ((hour() * 3600) + (minute() * 60) + second());
  }
}
BLYNK_WRITE(V16) {   // T5s
  TimeInputParam t(param);
int startsecond = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);  
int stopsecond = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
 // Serial.print("Start = ");
  //Serial.println(startsecond);
  //Serial.print("Stop = ");
  //Serial.println(stopsecond);
  //Serial.println();
  int dayadjustment = -1;  
  if(weekday() == 1){
    dayadjustment = 6; // needed for Sunday Time library is day 1 and Blynk is day 7
  }
  if(t.isWeekdaySelected((weekday() + dayadjustment))){ //Time library starts week on Sunday, Blynk on Monday  
    //Schedule is ACTIVE today 
    if(nowseconds >= startsecond - 31 && nowseconds <= startsecond + 31 ){    // 62s on 60s timer ensures 1 trigger command is sent
      Blynk.virtualWrite(V17, 1);  // turn on virtual button t5s
     // Serial.println("Schedule 1 started");
      digitalWrite(25, HIGH);// turn t5s relay on 
    }                  
    if(nowseconds >= stopsecond - 31 && nowseconds <= stopsecond + 31 ){   // 62s on 60s timer ensures 1 trigger command is sent
      Blynk.virtualWrite(V17, 0);   // turn OFF virtual vutton t5s 
    //  Serial.println("Schedule 1 finished");
     digitalWrite(25, LOW);// turn t5s relay off
    }               
  }
}

BLYNK_WRITE(V15) {// set time for leds 

  TimeInputParam t(param);
 // Serial.print("Checked schedule at: ");
 // Serial.println(Time);
  int dayadjustment = -1;
  if (weekday() == 1) {
    dayadjustment =  6; // needed for Sunday, Time library is day 1 and Blynk is day 7
  }
  if (t.isWeekdaySelected((weekday() + dayadjustment))) { //Time library starts week on Sunday, Blynk on Monday
   // Serial.println("Schedule ACTIVE today");
    nowseconds = ((hour() * 3600) + (minute() * 60) + second());
    startseconds = (t.getStartHour() * 3600) + (t.getStartMinute() * 60);
    if (nowseconds >= startseconds) {

      if (nowseconds <= startseconds + 90) {  // 90s on 60s timer ensures 1 trigger command is sent
        // code here

      }
    }
    else {
     // Serial.println("Relay not on");// nothing more to do here, waiting for relay to be turned on later today
    }
    stopseconds = (t.getStopHour() * 3600) + (t.getStopMinute() * 60);
    if (nowseconds >= stopseconds) {
      // 90s on 60s timer ensures 1 trigger command is sent
      if (nowseconds <= stopseconds + 90) {
        // code here

      }
    }
    else {
      if (nowseconds >= startseconds) { // only show if motor has already started today
       // Serial.println("Relay is still ON");
        // nothing more to do here, waiting for motor to be turned off later today
      }
    }
  }
  else {
   // Serial.println("Schedule INACTIVE today");
    // nothing to do today, check again in 1 minutes time
  }
 // Serial.println();
}

void reconnectBlynk() {
  if (!Blynk.connected()) {
    if (Blynk.connect()) {
      BLYNK_LOG("Reconnected");
    }
    else {
      BLYNK_LOG("Not reconnected");
    }
  }
}

//***********************************************************************WAVEMAKERS CONTROL*************************************************************************************************
BLYNK_WRITE(V4){   // wave on time slider
  x = param.asInt();
  onsec = x;   
}
BLYNK_WRITE(V7){  // wave Off time slider
  y = param.asInt();  // set variable as Slider value 
  offsec = y;  
  }

  void wavecontrol()
{
  if(wavesw == 1)
  

  if ((CounterOn > 0) && (ledStatus == 0) && (wavesw == 1))
  {
      digitalWrite(wave1Pin,HIGH);   //write to pin to turn the LED on.
      digitalWrite(wave2Pin,LOW);
   //   Serial.print(": LED on\n");
      ledStatus = 1;
      CounterOff = 0;
  }

  if ((CounterOn > 0) && (ledStatus == 1))
      {
      CounterOn = (CounterOn - 1);
      }
      
  if ((CounterOff == 0) && (CounterOn == 0) && (ledStatus == 1)  && (wavesw == 1))
    {
      CounterOff = onsec;
    }

  if ((CounterOff > 0) && (ledStatus == 1))
  {
      digitalWrite(wave1Pin,LOW);   //write to pin to turn wave1 off
      digitalWrite(wave2Pin,HIGH);//write to pin to turn wave2 on
      ledStatus = 0;
      CounterOn = 0;
   }
   
  if ((CounterOff > 0) && (ledStatus == 0))
      {
      CounterOff = (CounterOff - 1);
      }
      
  if ((CounterOff == 0) && (CounterOn == 0) && (ledStatus == 0))
    {
      CounterOn = offsec+1;
    }

}
  BLYNK_WRITE(V6) // wavemakers
  { 
  int wavesw = param.asInt(); // Get State of Virtual Button, wave makers
   if (wavesw == 1) {
     wavecontrol();
  }
  else
  {
    digitalWrite(wave1Pin,LOW);
    digitalWrite(wave2Pin,LOW);
  }
}

//*************************************************************************************TEMPERATURE CONTROL**********************************************************************************

BLYNK_WRITE(V8){  
   int heatersw = param.asInt(); // Get State of Virtual Button, heater
  if (heatersw == 1) {
     Heater();
  }
  else
  {
    digitalWrite(relayPin,LOW);
  }
}
BLYNK_WRITE(V9){  
  int coolingsw = param.asInt(); // Get State of Virtual Button, cooling
  if (coolingsw == 1) {
     Cooler();
  }
  else
  {
    digitalWrite(relay2Pin,HIGH);
  }
}
BLYNK_WRITE(V11)
{
  //reads the setppoint
  desiredTemp = param.asFloat();
}
BLYNK_WRITE(V12)
{
  //reads the differential
  tempDiff = param.asFloat();
}
BLYNK_WRITE(V32){
  //reads low alarm
  lowAlarm = param.asFloat();
}
BLYNK_WRITE(V33){
  //reads high alarm
  highAlarm = param.asFloat();
}
void relaysOn()
{
    digitalWrite(relay4Pin, LOW);
    Blynk.virtualWrite(V2, HIGH);
    digitalWrite(relay5Pin, LOW);
    Blynk.virtualWrite(V3, HIGH);
    Blynk.virtualWrite(V6,HIGH);// wavemakers
    Blynk.syncVirtual(V6);  // Trigger the associated function for V6 as if you had touched the widget in the App
}

void take_temp_readings() {
  //Serial.print("Number of Devices found on bus = ");  
  //Serial.println(DS18B20.getDeviceCount());   
  //Serial.print("Getting temperatures... ");  
  //Serial.println();     
  DS18B20.requestTemperatures();  // Command all devices on bus to read temperature  
  
tanktemp = DS18B20.getTempCByIndex(0);
sumptemp = DS18B20.getTempCByIndex(1);
  
   if (tanktemp == -127.00) 
   {
  //  Serial.println("Error getting temperature  ");
   } 
  }

    
void send_data_to_blynk()
{
  Blynk.virtualWrite(5, tanktemp); // send tank temp to virtual pin 5
  Blynk.virtualWrite(56, sumptemp);// send sump temp to virtual pin 56
  //Serial.println("Data sent to Blynk");
  //sending tank temp to nextion homepage txtbox
  //String command = "Temperaturepg.txt=\""+String(tanktemp,13)+"\"";
  //Serial.print(command);
  //Serial.write(0xff);
  //Serial.write(0xff);
 //Serial.write(0xff);
    char buffer[10];
    dtostrf(tanktemp, 2, 1, buffer);
    Temperaturepg.setText(buffer);
    yield;
   //check alarms;
  if (isnan(tanktemp)){
    if (Blynk.connected() && !faultyProbeFlag)
    {
      Blynk.notify("Probe disconnected");
      Blynk.email("A.bundy1995@hotmail.co.uk", "Aquaruim Controler Alert", "Probe disconnected");
      faultyProbeFlag = true;
    }
  }
  else if (tanktemp < lowAlarm && !tempAlarmFlag){
    Blynk.notify(String(tanktemp) + "ºC Low temp alarm");
    Blynk.email("A.bundy1995@hotmail.co.uk", "Aquaruim Controler Alert", (String(tanktemp) + "ºC Low temp alarm"));
    tempAlarmFlag = true;
  }
  else if (tanktemp > highAlarm && !tempAlarmFlag){
    Blynk.notify(String(tanktemp) + "ºC High temp alarm");
    Blynk.email("A.bundy1995@hotmail.co.uk", "Aquaruim Controler Alert", (String(tanktemp) + "ºC High temp alarm"));
    tempAlarmFlag = true;
  }
  else if (tanktemp > lowAlarm && tanktemp < highAlarm)
  {
    tempAlarmFlag = false;
  }
  else faultyProbeFlag = false;
}
//**************************************************************************************ATO CONTROL*****************************************************************************************
void ATOcontrol()
{
  unsigned long currentMillis = millis();

  boolean lowWaterState = digitalRead(lowWaterPin);
  boolean highWaterState = digitalRead(highWaterPin);

  if(lowWaterState != lastLowWaterState){
    lastLowWaterDetectTime = currentMillis;
  }


  if (pumpRunning) {  // if the pump is on then let's see if we should turn it off yet

    if ((highWaterState == HIGH) || (currentMillis - lastPumpTime >= maxRunTime)){
      digitalWrite(pumpPin, LOW);
      pumpRunning = false;
      lastPumpTime = currentMillis;
    }
  }
  else {   // pump is not running, see if we need to turn it on

      if((lowWaterState == LOW)  &&  (currentMillis - lastLowWaterDetectTime >= switchDebounceTime) && (currentMillis - lastPumpTime > minOffTime)){   // switch is low and has been for at least 3 seconds
        digitalWrite(pumpPin, HIGH);
        pumpRunning = true;
        lastPumpTime = currentMillis;
      } 
  }

  lastLowWaterState = lowWaterState;
}
void Heater()
{
   //if sensor not sending temperature turn relay OFF for safety
  if (isnan(tanktemp)) {
   digitalWrite(relayPin, LOW);
  }
  if ((tanktemp  < desiredTemp - tempDiff ) && (heatersw == 1))
  {
    digitalWrite(relayPin, HIGH);
  }
 
  if (tanktemp > desiredTemp )
  {
    digitalWrite(relayPin, LOW);
  }
}//--(end Heater )---

void Cooler()
{
  if ((tanktemp > desiredTemp - tempDiff ) && (coolingsw == 1))
  {
    digitalWrite(relay2Pin, LOW);
  }
  if (tanktemp < desiredTemp )
  {
    digitalWrite(relay2Pin, HIGH);
  }
  if (tanktemp == -127.00)
  digitalWrite(relay2Pin, HIGH);
}//--(end Cooler )---

// BUTTON INPUTS

BLYNK_WRITE(V18)  // Manual/Auto selection of lighting
{
  if (param.asInt()==1) {
    manual=1;
    Blynk.virtualWrite(V17, 0);
    analogWrite(2, 4095); //white leds on
    analogWrite(3, 4095); //blue leds on
  } else {
    analogWrite(2,0);// whites off 
    analogWrite(3,0);// blues off
}
}

BLYNK_WRITE(V17){  // T5s button off 
 int t5s = param.asInt(); // Get State of Virtual Button, Return pump
  if ((t5s == 1) && (manual ==0)){   // button ON
    // Turn as many pins/relays ON as you need
    digitalWrite(relay6Pin, LOW);
  } else {  // button OFF
    // Turn as many pins/relays OFF as you need
    digitalWrite(relay6Pin, HIGH);
  }
}

BLYNK_WRITE(V3){  // Reactor button off 
 int reactor = param.asInt(); // Get State of Virtual Button, Return pump
  if (reactor == 1) {  // button ON
    // Turn as many pins/relays ON as you need
    // bt2.setValue(1);
    digitalWrite(relay5Pin, LOW);
  } else {  // button OFF
    // Turn as many pins/relays OFF as you need
    // bt2.setValue(0);
    digitalWrite(relay5Pin, HIGH);
  }
}

BLYNK_WRITE(V2){  // Skimmer button off 
 int skimmer = param.asInt(); // Get State of Virtual Button, Return pump
  if (skimmer == 1) {  // button ON
    // Turn as many pins/relays ON as you need
  digitalWrite(relay4Pin, LOW);
  //bt1.setValue(1);
  } else {  // button OFF
    // Turn as many pins/relays OFF as you need
    digitalWrite(relay4Pin, HIGH);
     // bt1.setValue(0);
  }
}

BLYNK_WRITE(V1){  // Return pump button off 
 int value = param.asInt(); // Get State of Virtual Button, Return pump
  if (value == 1) {  // button ON
    // Turn as many pins/relays ON as you need
    digitalWrite(relay3Pin, LOW);
bt0.setValue(1);
    timer.setTimeout(30000, relaysOn);
  } else {  // button OFF
    // Turn as many pins/relays OFF as you need
 bt0.setValue(0);
 bt1.setValue(0);// skimmer button on nextion
 bt2.setValue(0);// reactor button on nextion
    digitalWrite(relay3Pin, HIGH);
    digitalWrite(relay4Pin, HIGH);
    Blynk.virtualWrite(V2, LOW);// Skimmer 
    // bt1.setValue(0);// skimmer button on nextion
    digitalWrite(relay5Pin, HIGH);
    Blynk.virtualWrite(V3, LOW);// Reactor
    // bt2.setValue(0);// reactor button on nextion
    Blynk.virtualWrite(V6, LOW);// Wavemakers 
    Blynk.syncVirtual(V6);  // Trigger the associated function for V6 as if you had touched the widget in the App
    Blynk.virtualWrite(V8, LOW);// Heating
    digitalWrite(relayPin, LOW);
    Blynk.virtualWrite(V9, LOW);// Cooling
    Blynk.syncVirtual(V9);
  }
}

BLYNK_WRITE(V38){  // feed button to turn relays off for set time then back on again
 int value = param.asInt(); // Get State of Virtual Button, Return pump
  if (value == 1) {  // button Pressed
    // Turn as many pins/relays OFF as you need
    digitalWrite(relay3Pin, HIGH);
    digitalWrite(relay4Pin, HIGH);
    Blynk.virtualWrite(V2, LOW);// Skimmer 
    digitalWrite(relay5Pin, HIGH);
    Blynk.virtualWrite(V3, LOW);// Reactor
    Blynk.virtualWrite(V6, LOW);// Wavemakers 
    Blynk.syncVirtual(V6);  // Trigger the associated function for V6 as if you had touched the widget in the App
    Blynk.virtualWrite(V8, LOW);// Heating
    digitalWrite(relayPin, LOW);
    Blynk.virtualWrite(V9, LOW);// Cooling
    Blynk.syncVirtual(V9);
    timer.setTimeout(30000, relaysOn);// wait for set time before turning everything back on.
    Blynk.virtualWrite(V1, HIGH);
    Blynk.syncVirtual(V1);
  }
}
void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);  // start serial port to show results
  nexInit();
setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)
  // run timer every minute to check for led On/Off action
  DS18B20.begin(); // Initialize the Temperature measurement library
  // set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
  DS18B20.setResolution(Probe01, 12);
  DS18B20.setResolution(Probe02,12);
pinMode(relayPin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
pinMode(relay3Pin, OUTPUT);
pinMode(relay4Pin, OUTPUT);
pinMode(relay5Pin, OUTPUT);
pinMode(wave1Pin, OUTPUT);
pinMode(wave2Pin, OUTPUT);
pinMode(relay6Pin, OUTPUT);// t5s declaired
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
  pinMode(lowWaterPin, INPUT_PULLUP);// ATO
  pinMode(highWaterPin, INPUT_PULLUP);//ATO
  pinMode(pumpPin, OUTPUT);// ATO

///////////////////////////////////////////////////////////////////////////////
  
  Blynk.begin(auth);  // Here your Arduino connects to the Blynk Cloud.  
  timer.setInterval(1000L, take_temp_readings);  // Setup a function to be called every second
  timer.setInterval(5000L, send_data_to_blynk);
  timer.setInterval(1500L, Heater);
  timer.setInterval(1300L, Cooler);
  timer.setInterval(1000L, setLed);
  timer.setInterval(1000L, clockDisplay);     // digital time displayed every second
  timer.setInterval(60000L, activetoday);     // check every minute if schedule should run today
  timer.setInterval(60000L, reconnectBlynk);  // check every 60s if still connected to server
  timer.setInterval(1000L, wavecontrol);
  timer.setInterval(1000L, ATOcontrol);
//////////////////////////////////////////////////////////////////////////////
// Register the event callback functions of each touch event:
  // You need to register press events and release events seperatly.
  // Format for press events: <object name>.attachPush(<object name>PushCallback);
  // Format for release events: <object name>.attachPop(<object name>PopCallback);
  b1.attachPush(b1PushCallback);  // Button press
  b1.attachPop(b1PopCallback);  // Button release
  bt0.attachPush(bt0PushCallback);  // Dual state button bt0 press
  bt1.attachPush(bt1PushCallback);  // Dual state button bt1 press
  bt2.attachPush(bt2PushCallback);  // Dual state button bt2 press
  bt3.attachPush(bt3PushCallback);  // Dual state button bt3 press
  bt4.attachPush(bt4PushCallback);  // Dual state button bt4 press
  bt5.attachPush(bt5PushCallback);  // Dual state button bt5 press  
  page0.attachPush(page0PushCallback);  // Page press event
  page1.attachPush(page1PushCallback);  // Page press event
  page2.attachPush(page2PushCallback);  // Page press event
  page3.attachPush(page3PushCallback);  // Page press event
  page4.attachPush(page4PushCallback);  // Page press event
  page5.attachPush(page5PushCallback);  // Page press event
  page6.attachPush(page6PushCallback);  // Page press event
  page7.attachPush(page7PushCallback);  // Page press event
  page8.attachPush(page8PushCallback);  // Page press event
  page9.attachPush(page9PushCallback);  // Page press event
//  h0.attachPop(h0PushCallback);  // Slider release, lockscreen
//  m0.attachPop(m0PopCallback);  // hotspot relase, settings button
//m1.attachPop(m1PopCallback);  // hotspot rlease, on off button 1
//m2.attachPop(m2PopCallback);  // hotspot release, feed button
 
  // End of registering the event callback functions

}//--(end setup )---

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  Blynk.run(); // All the Blynk Magic happens here...
  timer.run(); // Initiates BlynkTimer   
// get the current time, for this time around loop
  // all millis() timer checks will use this time stamp
 unsigned long currentMillis0 = millis();
  ledFade0(currentMillis0);
  unsigned long currentMillis1 = millis();
  ledFade1(currentMillis1);
 nexLoop(nex_listen_list);  // Check for any touch event
}//--(end main loop )---
//*********( THE END )***********

#21

Appologies for the layout, for some reason it didn’t format correctly :confused:


#22

Three backticks for and aft, not two :slight_smile:

Blynk%20-%20FTFC


#23

dohhh sorry about that :confused: i shall rememebr that for future posts, cheer Gunner. Just to add, its when i uncomment //bt1.setValue(1); or //bt1.setValue(0); on my skimmer button BLYNK_WRITE(V2){ i get the compling issue.


#24

As I don’t have NexHardware.h I just used an empty file and complied for Mega 2560 using IDE 1.8.7 on Win8.1 (also 1.8.8 on Win10) and the latest Blynk lib.
No errors with bt1.setValue(1); and bt1.setValue(0); uncommented in BLYNK_WRITE(V2). :+1:


#25

strangly i just tried it with no errors to,very strange as i havnt chnaged anything. upoon tetsing, sometimes blynk misses the button pressed on the nextion and dosnt act and vice verser. how could i get round this? should i add flags


#26

I think I’ve found something worth looking at: It’s the way the two DS18B20 are set (resolution) and how they are interrogated (blocking).

According to the datasheet (https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf table on page 3) it takes 750ms (!) (at 12 bit resolution) to get the temperature.

take_temp_readings() is called once per second (not sure if that is practically necessary). This is close to the time it takes to read the temperature from the sensors.

What I would change in the first place:

void take_temp_readings() 
{
  [...]
  //Serial.println();     
  tanktemp = DS18B20.getTempCByIndex(0);
  sumptemp = DS18B20.getTempCByIndex(1);
  DS18B20.requestTemperatures(); 
  
  [...] 
}
void setup()
{
  [...]
  DS18B20.begin(); 
  DS18B20.setResolution(Probe01,10);  
  DS18B20.setResolution(Probe02,10);
  
  DS18B20.setWaitForConversion(false); // make reading NON blocking
  DS18B20.requestTemperatures();       // start conversion for first reading 
  
  [...]
  
  timer.setInterval(2000L, take_temp_readings);  // Setup a function to be called every 2 seconds

  [...]
}//--(end setup )---

The hardware stops working
#27

thank you for noticing that :slight_smile: i have made the changes and the code seems much sommer now :slight_smile: and is no longer missing a button press either from the nextion. thank you so much for your help. If theres anything else that catches your eye please shout :slight_smile:


#28

Update, my idea with changing the button value works but if I change the page on the nextion and go back to the original page, all the settings are gone -.-


#29

@Bundy FYI, as your issue’s posts got longer, I moved them all into your own topic.

I also have a 2.4" Nextion display, but has so far it is only used it as a Weather Display for Blynk Data and I have not integrated any touch functions back to Blynk, so this is interesting reading for when I finally get around to that.


#30

Sweet cheers Gunner :slight_smile: ahh fair enough, I guess that data is refreshed at a set interval? I’m thinking this part may have something to do with it

// Page change event:
void page0PushCallback(void *ptr)  // If page 0 is loaded on the display, the following is going to execute:
{
 CurrentPage = 0;  // Set variable as 0 so from now on arduino knows page 0 is loaded on the display
}  // End of press event

Maybe set the button values again here although I’m not sure how to store a button value as a int instead of this uint32_t number5 = 0; where I could then use a statement like bt0.setValue(number5); so when the page is loaded so is the button value


#31

@Bundy: Good to hear! :sunglasses:

No reason to shout :grin: Just one more thing worth looking at is the use of the timers as you use a number of them and many run functions in parallel. It does not seem to be an issue as the functions do not block.

But, anyhow it’s always a good idea to have a look at @Gunner’s collection C++ Blynk - Code Examples for Basic Tasks (Work in Progress) - in this particular case I’d
recommend the topic “#12 - Timers simplified… perhaps…” -> “Staggering Timers”


#32

Sweet thank you I’ll take a look into that and make the required changes. Once iv added all my features, I’ll then go back through it all and add arrays and try to make things more compact and simplified.

Continuing on from my previous issue, I think iv found the solution.

This video shows how to store the button value within the nextion editor and then call up that variable when you change pages. Perfect! Keeps a bit of code off the arduino :smiley:

Next step is, display hour, minute and second in text boxes on the home screen


#33

Failing miserably at sending of the time to a txt box -.- I tried calling the hour by

String hour1 = String hour(); 

And then sending that as a String to the txt box but nothing happens :confused:

Not sure if I need to convert it to the buffer and then send it like I did with the temperature or what.

If anyone has any ideas or examples that may help me that would be great :slight_smile:


#34

@Bundy: What I usually do to display date and time in the app is to put everyting (with leading zeros) into a string using sprintf([…],[…]). Should work in an equivalent way in your case.
Example:

void dateTimeDisplay()
{
  char currentTime[20];
  sprintf(currentTime,"%02u.%02u.%02u / %02u:%02u",day(),month(),year(),hour(),minute());
  Blynk.virtualWrite(V10, currentTime);  
}

#35

Sorry I mean sending to the nextion, I have the time displayed on the blynk app at the moment. Another issue I have found with the buttons is that I can’t seem to change the variables I set for each button from the arduino. If I press a button on page 2, it turns a button on on page 1 like it’s suppose to for the nextion. But if I change the state or variable from the arduino it seems to ignore it. I must be setting the variable wrong.