[SOLVED] Bridge widget arduino to arduino on local server

That is a bit weird, I use bridge.virtualWrite(V24, HIGH) and it works flawless. It turns on a light on my secondary ESP, it is received on V24 on the ESP (main thing is Mega connected via Ethernet).

-edit-

Ow wait, you mean you can only send out 1 int via V1? Using a HIGH/LOW would work on any Vpin?

Ok, I’m not having fun now… Deep breaths, everything will be ok.:wink:

So I changed my sketch to send the integer on V1 as suggested and I’m still not having any luck. I’ve stripped down my code and am wondering if anyone can have a look at it and spot what I’m doing wrong.
I’m expecting the integer value of 44 to be sent to V1 of the receiving end node (arduino). But It doesn’t work for me.

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

char auth[] = "YourAuthToken";
WidgetBridge bridge1(V1);
SimpleTimer timer;
int LightValueScaled = 44;  //fixed value at the moment for testing 'bridge'

byte arduino_mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress arduino_ip (192,168,0,202);
IPAddress dns_ip (192,168,0,1);
IPAddress gateway_ip (192,168,0,1);
IPAddress subnet_mask (255,255,255,0);


void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, IPAddress(192,168,0,201), 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);  
  while (Blynk.connect() == false) {
    // Wait until connected
  }
 bridge1.setAuthToken("OtherAuthToken");    //bridge widget setup for comms to salon
 timer.setInterval(1000L, onesecondtimer);  // Setup a function to be called every second
}

void onesecondtimer()
{
   bridge1.virtualWrite(V1,LightValueScaled);
   Serial.println (LightValueScaled);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates SimpleTimer
}

Have you tried:

BLYNK_WRITE(V1) {
    param.asInt(); //here is 44
}

on receiving device?

I’m not sure but it may be to do with what device powers ip first. Have you tries powering up the slavendevice first, let it connect and than bring the arduino online? Sometines that seems to help me.

Thanks for the ideas but sadly I am still not having any success with bridge.

@Dmitriy - I didn’t have this in my receiving device but I have now, didn’t seem to help me. Is it required?

BLYNK_WRITE(V1) {
    param.asInt(); //here is 44
}

@Lichtsignaal - Thanks for the idea, I tried rebooting the sending Arduino so it was last to power on but this didn’t help me either.

I must be missing something, feel free to throw more ideas at me if you have any.

Is there anything in the Local Server that I need to enable/change?

Could I possibly diagnose the fault by looking for something in the local server log files?

Sure. How do you suppose to read values from Virtual Pin otherwise? You sending virtualWrite so you should have a handler to process it.

Are you able to control both devices via Blynk app?

At the moment I’m just looking for the sent integer to show up on a display widget. I didn’t realise that I needed any code in the receiving end node for that. I do have it in there now and still cannot see the sent integer in the display widget associated with V1

Yes, both devices work perfectly from the Blynk app. They are both connected to my local server running on a Raspberry Pi 2, over LAN.

You don’t. Until you start using virtual pins. Virtual pins need handler.

Hm… Indeed it is not supposed to be like that =). In other words bridge.virtualWrite is not the same as Blynk.virtualWrite. So what I’m trying to say is - if you want to see value on value display you need to do additional Blynk.virtualWrite(). Bridge is just for device-device, no app. involved.

1 Like

Thankyou very much! Ill go and try it now, ill let you know in a few minutes:grin:

1 Like

@Dmitriy Thanks again, it is now all working great. I didn’t fully understand how the bridge function worked.

When it worked… I did a happy dance!

2 Likes

Thank you for clearing the point …
just made my (working) bridge from one mega to another but can able to make a bridge to send data in the opposite direction (ie, to the transmitting mega) … OR in plain words , i can not make a two way connection between them !

and please explain the bridge function in detail in the documents section .

Regards ,
Ahsan…

You can make a bridge on you second Mega to the first, that should work just fine?

not working !
can we have example sketches ?

Can you post the sketches of both devices? Something like “it doesn’t work” is not much help to anyone :slight_smile:

1 Like

@NickMurray Can you post your bridge code? Some of us still need enlightenment…

I have bridge working by sending an integer from one Arduino Uno to another Arduino Uno on the same Local Server which I have running on a Raspberry Pi. I have not tried setting up a Bridge to send data in the opposite direction but I imagine it would be done in the same way.

To get the bridge working;
On the sending Arduino

  1. You do not need the bridge widget on any dashboard, it is just not required
  2. Before the setup loop —> WidgetBridge bridge1(V1);
  3. Include in the setup loop —> while(Blynk.connect() == false){/*wait until connected*/}
  4. Next in the setup loop—> bridge1.setAuthToken("the_receiving_arduinos_auth_token");
  5. I have a loop that runs one time every second setup using ‘SimpleTimer’ Library
    6)In the one second loop I have —>bridge1.virtualWrite(V1,44);

So for my example I send the value of 44 to Virtual pin1 (V1) of my receiving arduino uno. Obviously I don’t just send a static value of 44 in my actual code but I used that value here to keep it simple.

In the receiving Arduino

  1. Outside of any other loop —>BLYNK_WRITE(V1) {LightValue = param.asInt();}
  2. Inside a 1 second loop —>Blynk.virtualWrite(V25,LightValue);

The value of 44 is handled by the BLYNK_WRITE function where it is written to an integer that I have labelled LightValue then inside a loop that is executed one time every second the LightValue is written to the Blynk App with Blynk.virtualWrite. I display the LightValue on a Value Display Widged that is associated with Virtual Pin V25. In this example it will show the value of 44 on my dashboard

This does work for me. I would like to use the Bridge function more but I have not yet dedicated any more time to it. I would like to send an array of values using the bridge function which I believe is possible but I have not yet been successful in doing that. I hope my description helps you out.

1 Like

Hi there!
Thanks all people involved helping in this topic, I’ve got my first bridge working!!!

A happy dance in honor of you all!! :wink:

2 Likes