Hello Blynkers!
I am finalizing my project based on an Arduino Mega+Ethernet board+ 16 relay board (yes, 5v external power source), but I stumbled upon some strange behavior.
the basic test platform is this:
- create an app with one button switch ON-OFF, attached to a “normal” Pin, let’s say D24
- create a simple program for aduino, containing Blynk.syncAll() in BLYNK_CONNECTED()
- launch the blynk application
- switch on the blynk button (the relay will activate)
- switch off or reset the arduino board (the relay will deactivate)
- switch on the arduino board (wait10 sec if you disconnect dc power)
the board re-sync at reconnect
but
SyncAll() won’t update the status of the button (while is perfectly functioning with buttons attached to virtual pin), and on the relay board the relay is OFF while the Blynk button is ON.
how can I resync this, in one way or on the other?
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "x7wv1gNXpg_qPPjBYUOEUNQmCfs4IZfa";
#define W5100_CS 10
#define SDCARD_CS 4
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
Blynk.begin(auth, IPAddress(192,168,1,199), 8080);
}
BLYNK_CONNECTED() {
Blynk.syncAll();
}
void loop()
{
Blynk.run();
}
void(* resetFunc) (void) = 0;//declare reset function at address 0
void reset() {
asm volatile ("jmp 0");
}
BLYNK_WRITE(V0) {// soft Reset
if (param.asInt() == 1) {
delay(3000);
resetFunc(); //call reset
delay(5000);
}
}