Values of different types in Bridge

I use a Bridge widget to send from A to B the values that on B are interpreted as int. And everything works perfectly.

I need to send “also” values that should be interpreted as string and I would not like to create another Bridge on A. Someone can suggest a method to save on B in two different variables (int and string) the data of different type that send to ?

All Blynk vPin data is typically sent as strings anyhow, it is how it is interpreted/converted by the param.as???() command.

If only using one device at the receiving end, you don’t need to create a new WidgetBridge myBridgeName(vPin)… You just use another myBridgeName.virtualWrite(vpin) to send to that vPin on the receivers device.

And on the receivers side, use the BLYNK_WRITE() function and the afore mentioned param command to convert to Int, Str, Double, Float… Exactly the same as if the data came from a widget on the App (which is basically what the bridge emulates).

I try to explain myself better:
I want to send from A to B two values, one as int and one as string.

transmission side (A)
bridge1.virtualWrite(V0,wattBilancio, flagCount);
where wattbilancio is an int and flagcount is a string.

reception side (B)
can I extract the two different types of values this way?

 BLYNK_WRITE(V0){
   dataIn = param[0].asInt();
   dataPing = param[1].asString();
 }

I don’t know… have you tried?

However…

…This will need to be…

dataPing = param[1].asStr(); with dataPing previously declared as a String, as per normal variable rules.

I answer myself: :rofl:

transmission side (A)

bridge1.virtualWrite(V0,String(wattBilancio),String(flagCount));

reception side (B)

BLYNK_WRITE(V0){
   dataIn = param[0].asInt();
   dataPing = param[1].asString();
}

everything works perfectly. The trick is that before being sent via bridges, they must be converted into strings. Receiver side the received values can be used both as numerical values (int) and as strings (string)

So as not to confuse others reading this, this conversion is unnecessary… as I already pointed out above.


image


I have sent float data over a bridge and pulled it out on the receiving end as a string

1 Like