[SOLVED] The extra virtual pins don't appear to work with buttons and sliders

Android
Cloud
Wemos D1 Mini

With buttons or sliders set to virtual pins > 31 they don’t respond.
Value displays do respond but are referenced without the V prefix.

When I switch the value displays that were < 32 to > 31 and move the buttons and sliders to the vacated pins < 32 they work ok.

Problem is I have run out of value displays that I can move to > 31.

What happens if you reverence with V prefix?

@vshymanskyy as far as I know there is no response for any widget type if V is used > 31.

The value displays on virtual pins > 31 don’t appear to be syncing either.

you should always use V prefix, it should work for pins > 31.

@vshymanskyy confirmation of the bug. Pressing V1 button turns the LED on and off, pressing V41 button doesn’t.

// Buttons in Switch mode on V1 and V41, LED on V2

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "xxxxxxxxxxxxxxxxxx";

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, "Office", "xxxxxxxxxx");
  while (Blynk.connect() == false) {
    // Wait until connected
  }
  Blynk.syncAll();
  
}

BLYNK_WRITE(V1) 
{
  int V1test = param.asInt();
  if (V1test == 1){
    Blynk.virtualWrite(V2, 255);
  }
  else{
    Blynk.virtualWrite(V2, 0);  
  }
}

// V2 LED

BLYNK_WRITE(V41) 
{
  int V41test = param.asInt();
  if (V41test == 1){
    Blynk.virtualWrite(V2, 255);
  }
  else{
    Blynk.virtualWrite(V2, 0);  
  }
}

void loop()
{
  Blynk.run();
}

Could you try this?
Blynk.virtualWrite(V42, 0);

@vshymanskyy not sure where you want that line but changing V2 to ‘42’ gives the same results, V1 ok to LED on V42 but nothing from V41 button.

If I use V42 the sketch fails to comply with ‘V42’ was not declared in this scope so I have to use 42 and from my main sketch I can do virtualWrite’s to 42 for Value Displays (but all the other widget types I have tried fail, including syncing).

// Buttons on V1 and V41, LED on "42"

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "xxxxxxxxxxxxxxxxx";

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, "Office", "xxxxxxxxxxxxx");
  while (Blynk.connect() == false) {
    // Wait until connected
  }
  Blynk.syncAll();
  
}

BLYNK_WRITE(V1) 
{
  int V1test = param.asInt();
  if (V1test == 1){
    Blynk.virtualWrite(42, 255);
  }
  else{
    Blynk.virtualWrite(42, 0);  
  }
}

// V42 LED

BLYNK_WRITE(V41) 
{
  int V41test = param.asInt();
  if (V41test == 1){
    Blynk.virtualWrite(42, 255);
  }
  else{
    Blynk.virtualWrite(42, 0);  
  }
}

void loop()
{
  Blynk.run();
}

see here for reply: 128 Virtual Pins for some boards!

@Dave1829 tried changing from SWITCH to PUSH and back again numerous times and still no joy.

Are you using an Android device and which hardware are you connecting to the Blynk server?

@vshymanskyy
I think my problem relates to the fact that I can’t compile a sketch if I refer to a virtual pin over 31 with the V prefix.

I have the latest libraries as confirmed by Serial Monitor and I have tried with board settings in the app of Wemos D1 Mini and ESP8266. Serial Monitor output with debug messages below.

[6246] Connected to WiFi
[6246] IP: 192.168.10.178
[6246] Blynk v0.3.6 on ESP8266
[6246] Connecting to blynk-cloud.com:8442
[6408] <[02|00|01|00] xxxxxxxxxxxxxxx
[6563] >[00|00|01|00]È
[6563] Ready (ping: 2ms).
[6563] <[11|00|01|00]Gver[00]0.3.6[00]h-beat[00]10[00]buff-in[00]256[00]dev[00]ESP8266[00]build[00]May 23 2016 13:56:10[00]
[6752] <[10|00|02|00|00]
[7513] >[00|00|01|00]È
[7514] >[14|00|02|00|06]
[7514] >vw[00]1[00]0
[7515] <[14|00|02|00|06]vw[00]2[00]0
[7662] <[14|00|02|00|0C]vw[00]43[00]V1 OFF
V2 OFF from V1 BUTTON
[7810] >[14|00|02|00|07]
[7810] >vw[00]41[00]0
[17811] <[06|00|03|00|00]
[17975] >[00|00|03|00]È
[21763] >[14|01]Ô[00|06]
[21763] >vw[00]1[00]1
[21764] <[14|01]Ô[00|08]vw[00]2[00]255
[22072] <[14|01]Ô[00|0B]vw[00]43[00]V1 ON
V2 ON from V1 BUTTON
[25021] >[14|01]Õ[00|06]
[25021] >vw[00]1[00]0
[25021] <[14|01]Õ[00|06]vw[00]2[00]0
[25170] <[14|01]Õ[00|0C]vw[00]43[00]V1 OFF
V2 OFF from V1 BUTTON
[27145] >[14|01]Ö[00|07]
[27145] >vw[00]41[00]1
[29852] >[14|01]×[00|07]
[29852] >vw[00]41[00]0
[35321] <[06|00|04|00|00]
[35480] >[00|00|04|00]È
[45477] <[06|00|05|00|00]
[45828] >[00|00|05|00]È
[55828] <[06|00|06|00|00]
[56068] >[00|00|06|00]È
[66069] <[06|00|07|00|00]
[66308] >[00|00|07|00]È

Latest sketch which allows me to write to pin 43 from pin 1 but not pin 44 from 41.

// Buttons on V1 and V41, LED's on V2 for V1 button and V42 for V41 button
// Value displays on V43 for V1 and V44 for V41 button
#define BLYNK_DEBUG
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "xxxxxxxxxxxxxxxx";

BLYNK_WRITE(V1) 
{
  int V1test = param.asInt();
  if (V1test == 1){
    Blynk.virtualWrite(V2, 255);
    Blynk.virtualWrite(43, "V1 ON");
    Serial.println("V2 ON from V1 BUTTON");
  }
  else{
    Blynk.virtualWrite(V2, 0);
    Blynk.virtualWrite(43, "V1 OFF");
    Serial.println("V2 OFF from V1 BUTTON");  
  }
}

// V2 LED

BLYNK_WRITE(V41) 
{
  int V41test = param.asInt();
  if (V41test == 1){
    Blynk.virtualWrite(42, 255);
    Blynk.virtualWrite(44, "V41 ON");
    Serial.println("V42 ON from V41 BUTTON");
  }
  else{
    Blynk.virtualWrite(42, 0);
    Blynk.virtualWrite(44, "V41 OFF");
    Serial.println("V42 OFF from V41 BUTTON"); 
  }
}

// V42 LED

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, "Office", "xxxxxxxxx");
  while (Blynk.connect() == false) {
    // Wait until connected
  }
  Blynk.syncAll();
}

void loop()
{
  Blynk.run();
}

Screenshots of app in design and play mode.


Sony Z3C with Mega 2560 clone and W5100 Ethernet

Is anyone successfully using an ‘ESP’ with more than 32 virtual pins for anything more than the Value Display widget?

@vshymanskyy when it was announced that virtual pins had been extended to 128 there was an indication that is might not initially be available for “ESP’s”. This infers that it might only initially be for Arduino’s like @Dave1829’s Mega even though most ESP’s are MUCH more ‘powerful’ than the Arduino’s.

Can you confirm 128 virtual pins are fully functional, sliders, button, Timer widgets etc, for ESP’s as the only widget that works for me is the Value Display.

@Costas please check with the latest master branch.
Hope this helps. The issue appeared for some boards and should be fixed now.

2 Likes

@vshymanskyy the latest version of BlynkSimpleEsp8266.h has fixed the problem, thanks.

Still not working for me…

Local Server 0.16.1
Blynk v0.3.7
Android Version 1.21.1

@psoro, what hardware are you using?

@psoro you need the latest master branch if you are trying with your WeMos or another ESP.

Alternatively edit BlynkSimpleEsp8266.h as shown at https://github.com/blynkkk/blynk-library/commit/fcc0f0944ba85b7e6a5d49992faa3b6d3ccd61ae (just delete the existing rows 18 to 21 from Blynk version 0.3.7)

@vshymanskyy, Wemos mini D1

I will try and come back to you…thanks!

Perfect mates!! The latest master branch did the trick…
I assume this file will be into next release… Am I right @vshymanskyy?

BR

@vshymanskyy since I made the changes at https://github.com/blynkkk/blynk-library/commit/fcc0f0944ba85b7e6a5d49992faa3b6d3ccd61ae my WeMos D1 Mini projects have become very unstable.

When I say unstable I mean dropping the connection to the Blynk cloud server and reconnecting.

Initially I just removed the 3 or 4 lines from BlynkSimpleEsp8266.h to get the virtual pins > 31 working rather than using the full master branch. Same result of constant disconnects with the latest full master branch.

A few observations for you:

A. When the WeMos D1 Mini connects it now states:

Blynk v0.3.7 on NodeMCU

With earlier versions it was just Blynk v0.3.X and then Blynk v0.3.X ESP8266

I have the WeMos D1 Mini selected from the board manager. Is the reference to NodeMCU the problem as the WeMos is quite different to a NodeMCU?

B. I have noticed that if the Blynk app is ‘running’ in the background the disconnects from the server stop. This is a temporary fix for the project to continue processing the sketch but as soon as I return to the Blynk app the disconnects restart. The disconnects occur without any buttons being pressed in the app. When I refer to running in the background I mean simply going to the Android home page, not stopping the app.

@psoro does your Mini now join the server as an NodeMCU?