[SOLVED] Bridge widget arduino to arduino on local server

I might need some help on this one. I am trying to set up bridge function between two arduinos that both connect via ethernet w5100 shields to a local server on Raspberry Pi. If it makes any difference I use an IOS device for the Blynk app.

My goal is to send an Analog value from one arduino to the other. My questions are;

  1. Is the bridge widget required on the app, I have read in the forum that it is not required but I would like some clarification on this please. If it is required, is it required just on the sending project or both projects?

  2. What does this statement do?
    WidgetBridge bridge1(V1);
    Also does it need to be placed in the receiving arduino sketch as well as the sending?

  3. Is this a valid command to try and send to my other arduino?
    bridge1.virtualWrite(V25, LightValueScaled);
    where LightValueScaled is an integer and the command is executed 1 time per second
    I’m expecting to see my LightScaledValue arrive on V25 on the receiving arduino but its not happening.

I have read many other posts and looked at the example sketches, I have made sure in my code I am using the while (Blynk.connect() == false) { // Wait until connected }in setup routine.
immediately after that in setup i run bridge1.setAuthToken("ReceivingArduinoToken");

I’d appreciate any pointers as to where I’m going wrong or what I’m missing.

That’s true.

Assigns virtual pin 1 to bridge variable.

No.

No. Only 1 virtual pin available for bridge1 - V1. So you could do only bridge1.virtualWrite(V1, LightValueScaled); But via bridget you may send digitalWrite, analogWrite on any pin.

Thanks, great support. I’ll try again tomorrow and report back.

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