Button lock with Numeric Input Widget

This is the weirdest thing…I have created a Button widget with a Numeric Input widget. The Numeric Input widget settings are 0 - 3 in 0.01 steps. The code comes from Gunner. The function og these 2 Widgets is as follows switch button off adjust the numeric input switch on the button numeric input is locked. I have created 2 identical set of this so 2 buttons 2 numeric inputs. all works fine but at reboot 1 set always resets itself to 0. the other does not. And i mean they are identical (copies)
Any explanations as to why?

BLYNK_WRITE(V91)
{
  if (PH4Butt == 1)
  {
    Blynk.virtualWrite(V91, Cal_4);
  }
  else
  {
    Cal_4 = param.asFloat();
  }
}

BLYNK_WRITE(V92)
{
  if (PH7Butt == 1)
  {
    Blynk.virtualWrite(V92, Cal_7);
  }
  else
  {
    Cal_7 = param.asFloat();
  }
}

BLYNK_WRITE(V58)
{
  PH7Butt = param.asInt();
}

BLYNK_WRITE(V78)
{
  PH4Butt = param.asInt();
}

Any other virtual writes in your app to V91 or V92? Or any sync functions?

I will try changing Vpins

Nope same thing. 1 set Ok, 1 set zeros out at boot up. I allocated Vpins from 100 onwards as I know they are not allocated.


Before re-boot


After re-boot

What happens if you create another copy? If that works OK then try removing the one that doesn’t and see if that passes onto another etc etc. It may be that it only affects this first created or last created etc

I am not sure wht it happens though. Maybe you could call a virtualSync(V91), virtualSync(V92) etc in BLYNK_CONNECTED function to get the previous values?

I will try that

Ok I have figured out the cause. Its Blynk.syncAll(); The problem is I need this statement as part of the entire project.

1 Like

Probably better to just sync the pins you need.

Pete.

There are over 60 of them!!!

60 where you need to pull back the current values from the server and assign them to variables in your code?
If that is the case then do them individually in batches of 5 or 10.

Pete.

1 Like

OMG!!! the thought of typing all those numbers!!! Well its the only solution thanks.

:crazy_face:

Do it in a for loop.

Blockquote

Any other virtual writes in your app to V91 or V92? Or any sync functions?

proietti:

Nope same thing. 1 set Ok, 1 set zeros out at boot up.

Blockquote

That was referring to the test sketch version. I always just do small test sketch instead of messing with the larger code.

Ah OK, that doesn’t help when trying to diagnose problems though :wink:

At least you found it, no worries :smile:

@JustBertC is this what you mean in BLYNK_CONNECTED?

 for (int Vpin = 0; Vpin <= 91; Vpin++)
  Blynk.syncVirtual(Vpin);
1 Like

As I said earlier, I’d do them in batches - say 10 at a time, otherwise you could run into the same issues as using sync all.

I’m still not convinced that you really need yo sync 91 virtual pins though.

Pete.

1 Like

Well maybe not 91 exactly but pretty close

 * V0-TIME
 * V1-DATE
 * V2-TANK TEMP
 * V3-HEATING ON
 * V4-CHILLER ON
 * V5-PHLOCK BUTTON
 * V6-PH CAL7
 * V7-PH CAL4
 * V8-PH CAL DISPLAY
 * V10-MODE SWITCH (Manual/Auto)
 * V11-CH1 UV TIME SET
 * V12-CH1 UV FADEIN TIME
 * V13-CH1 UV FADEOUT TIME
 * V14-CH1 UV INTENSITY SETTING
 * V15-CH2 RBLUE/BLUE TIME SET
 * V16-CH2 RBLUE/BLUE FADEIN TIME
 * V17-CH2 RBLUE/BLUE FADEOUT TIME
 * V18-CH2 RBLUE/BLUE INTENSITY SETTING
 * V19-CH3 BLUE TIME SET
 * V20-CH3 BLUE FADEIN TIME
 * V21-CH3 BLUE FADEOUT TIME
 * V22-CH3 BLUE INTENSITY SETTING
 * V23-CH4 OCW TIME SET
 * V24-CH4 OCW FADEIN TIME
 * V25-CH4 OCW FADEOUT TIME
 * V26-CH4 OCW INTENSITY SETTING
 * V27-CH5 AMBER TIME SET
 * V28-CH5 AMBER FADEIN TIME
 * V29-CH5 AMBER FADEOUT TIME
 * V30-CH5 AMBER INTENSITY SETTING
 * V31-PH DATA FOR GRAPH
 * V32-CH1 UV LED WIDGET
 * V33-CH2 RBLUE/BLUE LED WIDGET
 * V34-CH3 BLUE LED WIDGET
 * V35-CH4 OCW LED WIDGET
 * V36-CH5 AMBER LED WIDGET
 * V37-TANK TEMP SET
 * V40-SAFELED LED WIDGET
 * V41-CH5 LIME TIME SET
 * V42-CH5 LIME FADEIN TIME
 * V43-CH5 LIME FADEOUT TIME
 * V44-CH5 LIME INTENSITY SETTING
 * V46-CH5 AMBER LED WIDGET
 * V47-STIMER1
 * V48-STIMER2
 * V49-STIMER3
 * V50-STIMER4
 * V51-MTIMER1 TIME INPUT WIDGET
 * V52-MTIMER1 DOSES/DAY WIDGET
 * V53-MTIMER1 DOSE DURATION WIDGET
 * V55-MTIMER2 TIME INPUT WIDGET
 * V56-MTIMER2 DOSES/DAY WIDGET
 * V57-MTIMER2 DOSE DURATION WIDGET
 * V60-DATA EXCHANGE S1
 * V62-BRIDGE WIDGET 1 LED UNIT 1
 * V63-BRIDGE WIDGET 2 LED UNIT 2   
 * V64-BRIDGE WIDGET 3 CHILLER/HEATER PLUGBAR
 * V65-BRIDGE WIDGET 4 STIMERS STANDARD PLUGBAR
 * V66-BRIDGE WIDGET 5 MTIMERS STANDARD PLUGBAR
 * V71-MTIMER3 TIME INPUT WIDGET
 * V72-MTIMER3 DOSES/DAY WIDGET
 * V73-MTIMER3 DOSE DURATION WIDGET
 * V75-MTIMER4 TIME INPUT WIDGET
 * V76-MTIMER4 DOSES/DAY WIDGET
 * V77-MTIMER4 DOSE DURATION WIDGET
 * V79-STIMER1 LED
 * V80-STIMER2 LED
 * V81-STIMER3 LED
 * V82-STIMER4 LED
 * V83-MTIMER1 LED
 * V84-MTIMER2 LED
 * V85-MTIMER3 LED
 * V86-MTIMER4 LED
 * V87-MTIMER1 BUTTON
 * V88-MTIMER2 BUTTON
 * V89-MTIMER3 BUTTON
 * V90-MTIMER4 BUTTON
 */

To my way of thinking, that’s just poor programming.

Pete.

??? How can you say that when you don’t know the entire project? Or what it is I have made?