Hello,
I use the bridge widget and i will to use virtual write with multiple params like this:
bridge1.virtualWrite(V2, 1, 2, 3);
That’s doesn’t work. With only one param is works fine. What ist the problem? I use blank server 0.3.4.
Best regards,
schittl
Hello.
You probably mean Blynk libraries? Please try to update to latest one. I do not remember in which version we added support of multiple params.
I already use library 0.3.4. which Version is the newest? On github 0.3.4 is the newest.
Ok, I’ve read that since 0.3.3 multiple params are supported. But i try The version 0.3.7 and i tell here if it’s work fine or not. Thanks for now.
I use the Link from the “getting-startend” page. There is the link to version 0.3.4.
Sorry for that.
@Pavel please fix. Do not put link to concrete version. Just to latest.
I tested now on new version 0.3.7 and is also doesn’t work. I’ve read that since 0.3.3 multiple params are supported. Here is my code example:
Transmitter
bridge1.virtualWrite(V28, 3, 5);
or
bridge1.virtualWrite(V29, 1, 2, 3);
Receiver
BLYNK_WRITE(V28) { Serial.print(F("BLYNK_WRITE(V28)")); Serial.println(param[0]. asInt()); Serial.print(F(" - ")); Serial.println(param[1]. asInt()); } BLYNK_WRITE(V29) { Serial.print(F("BLYNK_WRITE(V29)")); Serial.println(param[0].asInt()); Serial.print(F(" - ")); Serial.println(param[1].asInt()); Serial.print(F(" - ")); Serial.println(param[2].asInt()); }
What is the problem? It’s only work with blynk.virtualWrite and not with bridge1.virtualWrite?
@schittl oh, just saw it. Blynk operates with strings, while you are sending ints. You need to change
bridge1.virtualWrite(V28, 3, 5);
to
bridge1.virtualWrite(V28, "3", "5");
@vshymanskyy right? Maybe it make sense to add overloaded methods?
Single params as int works. I will send variables int or boolean. It’s only a example. I check if strings works. That int or boolean not work is not good because in docs example of blynk were int use 
I’m not sure, this is just a suggestion. To be honest I do not remember. @vshymanskyy should know better.
Could you be more specific? What happens?
You can enable BLYNK_DEBUG on both sides to see what happens.
I’ve tested with String and is also doesn’t work. My Code Example:
Transmitter:
boolean Var1 = 0; boolean Var2 = 0; Serial.println("V28"); ... bridge1.virtualWrite(V28, Var1, Var2); Serial.println("V29"); bridge1.virtualWrite(V29, "1", "0", "1");
Receiver:
BLYNK_WRITE(V28) { Serial.print(F("BLYNK_WRITE(V28)")); Serial.println(param[0].asInt()); Serial.print(F(" - ")); Serial.println(param[1].asInt()); } BLYNK_WRITE(V29) { Serial.print(F("BLYNK_WRITE(V29)")); Serial.println(param[0].asString()); Serial.print(F(" - ")); Serial.println(param[1]. asString()); Serial.print(F(" - ")); Serial.println(param[2]. asString()); }
BLYNK_DEBUG on Transmitter:
V28 [47510] <[14|00|0F|00|0E] [47511] <31[00]vw[00]28[00]10[00]29 V29 [47664] <[14|00|10|00|0E] [47665] <31[00]vw[00]29[00]1[00]0[00]1 [47821] <[0F|00|11|00]% [47822] <31[00]i[00]***AuthToken****
BLYNK_DEBUG on Receiver (only showing something like this:
[696349] <[06|00]F[00|00] [696388] >[00|00]F[00|C8]
I don’t understand what is wrong
Have you a example that’s working with the bridge widget?
@schittl The first problem is, that Bridge Auth token init should happen before you send virtualWrite!
Please see the Bridge example, it uses Blynk.connect()
in the setup()
@vshymanskyy ymanskyy That i think is not the reason because the following example works fine:
Transmitter:
bridge1.virtualWrite(V29, 1);
Receiver:
BLYNK_WRITE(V29)
{
Serial.print(F(“BLYNK_WRITE(V29)”));
Serial.println(param[0].asInt());
Serial.print(F(" - “));
Serial.println(param[1]. asInt());
Serial.print(F(” - "));
Serial.println(param[2]. asInt());
}
BLYNK_DEBUG on Transmitter:
[275122] <[0F|00]b[00|0A] [275123] <31[00]vw[00]29[00]1 [275274] <[0F|00]c[00]% [275275] <31[00]i[00]***AuthToken****
BLYNK_DEBUG on Receiver:
[412661] >[0F|00]P[00|07]
[412663] >vw[00]29[00]1
BLYNK_WRITE(V29) - 1
Only the multiple params doesn’t work.
bridge1.virtualWrite(V29, 1, 0, 1);
I also add the following and is also doesn’t work.
BLYNK_CONNECTED() { bridge1.setAuthToken("***AuthToken****"); }
@vshymanskyy Is it possible that are the wrong command in the “WidgetBridge.h” at virtualWrite lines? Need not be “BLYNK_CMD_HARDWARE” replaced by “BLYNK_CMD_BRIDGE”?
Maybe wrong
template
void virtualWrite(int pin, const T& data) {
…
Blynk.sendCmd(BLYNK_CMD_BRIDGE, 0, cmd.getBuffer(), cmd.getLength()-1);
}
template <typename T1, typename T2>
void virtualWrite(int pin, const T1& data1, const T2& data2) {
…
Blynk.sendCmd(BLYNK_CMD_HARDWARE, 0, cmd.getBuffer(), cmd.getLength()-1);
}
Maybe right
template
void virtualWrite(int pin, const T& data) {
…
Blynk.sendCmd(BLYNK_CMD_BRIDGE, 0, cmd.getBuffer(), cmd.getLength()-1);
}
template <typename T1, typename T2>
void virtualWrite(int pin, const T1& data1, const T2& data2) {
…
Blynk.sendCmd(BLYNK_CMD_BRIDGE, 0, cmd.getBuffer(), cmd.getLength()-1);
}
@schittl Yes, you’re right. The bug appeared after small re-factoring.
I’ve pushed the fix to the latest master branch.
Please be aligned with the latest bridge example - Bridge Auth Init should happen before you send the data.
Hi, i used your advise and it turned out this way for me, it works!
BLYNK_WRITE(V4){
Code = param[0].asInt(); //pinData variable will store value that came via Bridge
Uur = param[1].asInt(); //pinData variable will store value that came via Bridge
Minuut = param[2].asInt(); //pinData variable will store value that came via Bridge
}