Bridge data and array indicies

Hi all,
I’m looking for some help with using the widget bridge to communicate arrays.
I’m making a project that has one main device that will remotely communicate with several remote devices. The remote devices will hold several arrays, each pretty big, containing information like current air temp, max air temp parameter, and min air temp parameter. The main device will need to pull individual indices from those arrays to use in some of it’s functions.
I’m using an Arduino mega with an esp8266 as a WiFi antenna for the main device and esp8266’s for the remote devices.

I’ve come up with some pseudo-code that I’ve boiled down to near actual code, but I only have about two years of scattered coding experience, so I’ve got to imagine it’s unnecessarily overcomplicated and verbose. My main confusion I suppose is that I don’t understand how the “BLYNK_WRITE( bridgePin ) { pinData = param.asint; };” stores data. I want to store array values, I’ve read that virtual pins have no problem with this, but is the data loaded into “pinData” stored as an array? I need to refer to specific indicies in the data, so I’m not sure how I’d do this if the data in “pinData” is stored as something like a string.

Any help making sense of this would greatly appreciated.

Thanks for your time and consideration.

try to put your data in a string like this

WidgetBridge bridge1(V1);

String Data="155,555,544,24,544,544"
bridge1.virtualWrite(V1, Data);

Somewhat confusingly, the BLYNK_WRITE function doesn’t write data to the server, it’s triggered when data is received by the server.
You’ll use this function on your master device (Arduino Mega). When one of your slave devices sends data to the server (using the bridgex.virtualWrite command), the BLYNK_WRITE function on your master device will automatically be triggered and give you that data.

As @Blynk_Coeur says, I think I’d use a string with a delimiter (a comma in his example) then parse the string to give you the various parameters.


1 Like

Thanks for your replies,
I understand that a virtual pin can store arrays, and that “BLYNK_WRITE” is a function performed on the master device.
What I’m fuzzy on is how the data is stored on the master device. If the data is stored as an array on the aforementioned pinData variable, can I do something like:

string aVariable = pinData [3];     //store the fourth indice of pinData in aVariable.

on the master?

Here’s a short pseudo-example what I’m trying to do:

//*** SLAVE 1 ***:
string array1 = [a,b,c,d]; 
string array2 = [q,w,e,r,t,y];
//further functions for recognizing the masters requests for an upload of a specific array and storing it in a virtual pin. 

//*** MASTER ***:
int bridgePin; 
//function for the master to call for the upload of specific indices from a specified array from a specified slave.
BLYNK_WRITE( bridgePin ) { pinData = param.asint; };
masterFunction1(pinData[3])      //{function based on data stored in the 4th index of pinData.

all I can say is that you can’t write
bridge1.virtualWrite(Vx, array1);
invalid type this may be helpful


yes it’s a good example !

This looks like it’ll work for what I want to do. I guess I don’t need to use the widget bridge at all then, and I’ll be using “Blynk.syncVirtual()” instead for the bulk of my communications. I’ll try it out, thank so much!

1 Like