Menu & Slider Widget Values not updating to Arduino, on Startup

I use three BLYNK_WRITE functions for Virtual pins 29, 30 & 31…

V29 with a Slider
V30 with a Menu
V31 with a Button

Button:- (I use this “Button” to Enable/Disable Alarm)
Arduino uses an initial value declared in the sketch…
Once Arduino connects to Blynk App, it promptly updates the value to Virtual Pin V31… (Immediately after the message, “[6108] Ready (ping: 219ms).”

Menu: (I use this “Menu” to set the Smoke Sensor’s Threshold Value)
Arduino uses an initial value declared in the sketch…
Once Arduino connects to Blynk App, the threshold value in the slider doesn’t get updated and it still uses the same initial value declared in the sketch…

Slider: (I use this “Slider” to set the Fire Sensor’s Threshold Value)
Arduino uses an initial value declared in the sketch…
Once Arduino connects to Blynk App, the threshold value in the slider doesn’t get updated and it still uses the same initial value declared in the sketch…

To set the threshold from the menu, I had to open the menu and press “OK”…

To set the threshold from the slider, I had to touch the slider…

The issue i’m reporting here, is somewhat similar to the one in this link: http://community.blynk.cc/t/slider-widget-values-reset-to-zero-on-launch/4406

BLYNK_WRITE(V31)
{
  // You can also use:
  // int i = param.asInt() or
  // double d = param.asDouble()
  if (param.asInt())
  {
    Alarm = LOW;
    digitalWrite(buzzPin, LOW);
    Blynk.virtualWrite(1, 0); // Smoke LED
    Blynk.virtualWrite(2, 0); // Fire LED
    Blynk.virtualWrite(3, 0); // Temperature LED
    Blynk.virtualWrite(4, 0); // Humidity LED      
  }
  else
  {
    Alarm = HIGH;
  }
}

BLYNK_WRITE(V30)
{
  Serial.println(param.asInt());
  switch (param.asInt()) {
  case 1:
    SmokeThreshold = 110;
    break;
  case 2:
    SmokeThreshold = 130;
    break;
  case 3:
    SmokeThreshold = 160;
    break;
  case 4:
    SmokeThreshold = 180;
    break;
  case 5:
    SmokeThreshold = 200;
    break;
  }
}

BLYNK_WRITE(V29)
{
  Serial.println(param.asInt());
  FireThreshold = (param.asInt());
}

have you tried sync code?

  bool isFirstConnect = true; // Keep this flag not to re-sync on every reconnection

  BLYNK_CONNECTED(); // This function will run every time Blynk initial connection is established
  {
    if (isFirstConnect) {
      Blynk.syncAll();
      isFirstConnect = false;
    }
  }
1 Like

btw - you should post your whole code…

@ilak2k hello. @Dave1829 is right. please have a look into http://docs.blynk.cc/#blynk-main-operations-state-syncing

It worked! Synced Virtual Button States! Thank you @Dave1829
Thanks @Dmitriy