Hello all… im working with Arduino Uno and Ethernet for my Iot Projects…
i have problem with state sync after the arduino loss power source
i do Blynk.syncAll( )but it didn’t work
This is my skecth
bool isFirstConnect = true;
BLYNK_CONNECTED() {
if (isFirstConnect) {
// Request Blynk server to re-send latest values for all pins
Blynk.syncAll();
// You can also update individual virtual pins like this:
//Blynk.syncVirtual(V0, V1, V4);
isFirstConnect = false;
}
}
/*************************************************************
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Blynk community: http://community.blynk.cc
Social networks: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
You can use this sketch as a debug tool that prints all incoming values
sent by a widget connected to a Virtual Pin 1 in the Blynk App.
App project setup:
Slider widget (0...100) on V1
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "58d599d309e349b49e70349f5ab23e85";
SimpleTimer timer;
const int in1 = 2;
const int in2 = 3;
const int ls = 6;
const int re7 = 7;
const int led1 = 22;
const int led2 = 24;
const int led3 = 26;
const int led4 = 28;
const int led5 = 30;
const int led6 = 32;
const int led7 = 34;
const int led8 = 36;
const int led9 = 38;
const int led10 = 40;
const int led1in = 23;
const int led2in = 25;
const int led3in = 27;
const int led4in = 29;
const int led5in = 31;
const int led6in = 33;
const int led7in = 35;
const int led8in = 37;
const int led9in = 39;
const int led10in = 41;
int v1update = 0;
int lastv1update = 0;
int lsState = 0;
int lastlsState = 0;
int lastled1State = 0;
int lastled2State = 0;
int lastled3State = 0;
int lastled4State = 0;
int lastled5State = 0;
int lastled6State = 0;
int lastled7State = 0;
int lastled8State = 0;
int lastled9State = 0;
int lastled10State = 0;
int led1State = 0;
int led2State = 0;
int led3State = 0;
int led4State = 0;
int led5State = 0;
int led6State = 0;
int led7State = 0;
int led8State = 0;
int led9State = 0;
int led10State = 0;
int gatetimer = 0;
int counter = 0;
int notifgerbang = 0;
bool isFirstConnect = true;
void setup()
{
if (isFirstConnect) {
Blynk.syncAll();
isFirstConnect = false;
}
// Debug console
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(ls, INPUT);
pinMode(re7, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);
pinMode(led10, OUTPUT);
pinMode(led1in, INPUT);
pinMode(led2in, INPUT);
pinMode(led3in, INPUT);
pinMode(led4in, INPUT);
pinMode(led5in, INPUT);
pinMode(led6in, INPUT);
pinMode(led7in, INPUT);
pinMode(led8in, INPUT);
pinMode(led9in, INPUT);
pinMode(led10in, INPUT);
digitalWrite(re7, HIGH);
Serial.begin(9600);
Blynk.begin(auth);
timer.setInterval(100L, sendls);
timer.setInterval(500L, button);
timer.setInterval(1000L, gerbang);
}
void loop()
{
Blynk.run();
timer.run();
}
You need to have corresponding widgets. Or change state via Virtual pins in that case it will work. Otherwise server don’t know that you changed any state.