Virtual Pin problem

Oh right. I hadn’t realised that.

So

int singleserve = param.asInt();

becomes

singleserve = param.asInt();

Is that right? I hadn’t realised that fundamental piece of information as I relied too much on copy and paste from another script rather than learning how the code functions.

Is there any major reason why I can’t remove all the “int” declarations from the virtual pin functions? So they are all global?

Yes, and the same for multiserve.

Some variables are only required locally so it would be a waste of memory to declare them globally. For a small project like yours you shouldn’t have any issues with memory so you could have them all globally but it’s best if you consider the purpose of each variable and that will determine if it needs to be global or not.

Makes sense. Thanks for your help.

Without that key detail, I’m not sure I would have realised the problem. It makes sense now though.

I will re-write it again in the next few weeks, likely after my next project seeing this is all working now.

Well that didn’t fix the problem… BUT I think I found the problem. Those pins are above V31 so looks like that could be the problem.

I did think about this but I was expecting a compiler error when using virtual pins that don’t exist with your shield system.

Just checked and with an Uno board selected in the app it will not let you select a V pin > 31.

Do you have Uno as the board in the app?

Which Arduino are you using as the Mega has 128 virtual pins?

There’s my problem. I set the auth token up as arduino uno / esp8266 combo in the template thingy… But I noticed in the blynk app that I have it listed as a esp8266 only.

I didn’t think it would be a problem for virtual pins, and as I don’t use the digital pins in the app, so I didn’t bother changing it…

I’ll be sure to set the correct boards for this arduino/esp826 combo from now on and change that correctly.

1 Like

It still might limit your vPins unless you add this line into your UNO sketch:

#define BLYNK_USE_128_VPINS

It does.

It’s not recommended to add 128 Virtual pins for the lowly Uno / Nano with ESP shield.

That’s ok. I’m only using something like 10 vpins, just I had them spaced out in their functions so 40’s were distribution amounts etc.

I’ve moved them all below 31 and everything works fine. Such a small thing that wasted so much time. I notice where the problem lied as I sent the vpin value back to the Blynk app when I changed the slider and noticed that pin didn’t return a change but the lower number vpins did.

I realised that the board wasn’t set right in Blynk a few days ago but didn’t think much of it as I wasn’t using the hardware pins in Blynk. Lesson learnt.

Thanks again for the great support here.

It works just fine… within the processor limits, aka don’t expect to use ALL 128 :slight_smile: but I have used it, without issues, to allow bridging compatibility from a Nano to a Mega (due to the bridge referenced vPins on the Mega being in the higher range).