@Costas can you show your final code here? I’m having some overflow issues with my esp+mega+blynk sliders
@zeeko I think the sketch below was the final version but it wasn’t with ESP. Not checked the sketch but it might help you.
/**************************************************************
Simple NANO reboot sketch 26/12/2015
**************************************************************/
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(11, 12); // RX, TX was 2 and 3
#define BLYNK_PRINT SwSerial
//#define BLYNK_DEBUG // Optional, this enables lots of prints
#include <BlynkSimpleSerial.h>
#include <SimpleTimer.h>
SimpleTimer timer;
int testval = 0; // variable to hold D3 pin status
int Changed = 0; // variable to see if D3 pin status has changed
int TestLEDPin = 3; // new ON / OFF LED PIN
int SliderValue = 0; //
char auth[] = "2120f1064e494868aa6f624c48a0ebcd";
void setup()
{
SwSerial.begin(9600);
SwSerial.println(" Nano has just rebooted");
Blynk.begin(auth);
timer.setInterval(500L, sendSlider); // send every 0.5 seconds
timer.setInterval(10000L, sendUptime); // send every 10 seconds
pinMode(TestLEDPin, OUTPUT);
digitalWrite(TestLEDPin, LOW); // set LED pin OFF
delay(50); // wait 0.15 seconds
}
//****************************************
BLYNK_WRITE(V7) //Button Widget is writing to pin V7
{
SliderValue = param.asInt();
}
void sendUptime() // send Uptime every 4 seconds
{
Blynk.virtualWrite(V6, millis()/ 1000); // StartTimer (manual) duration in minutes write to V6 every second
}
void sendSlider() // send Slider value every 0.5 seconds
{
Blynk.virtualWrite(V6, SliderValue); // StartTimer (manual) duration in minutes write to V6 every second
}
//void(* resetFunc) (void) = 0; //declare reset function @ address 0 THIS IS VERY USEFUL
void loop()
{
Blynk.run();
timer.run(); // Initiates SimpleTimer
testval = digitalRead(TestLEDPin); // pin
//delay(100);
if (testval != Changed){ // prevent looping until status of D3 pin changes
if (testval == 1){
SwSerial.println(" Pin is HIGH resetting Nano .............");
//delay(200); // pause to see LED ON prior to reset
//resetFunc(); // reset Nano
}
else{
SwSerial.println(" OK Pin is LOW");
}
Changed = testval; // prevent looping until status of D3 pin changes
}
}