View Second Board Blynk Bridge Virtual Pin Question

Dear all Blynk friends,

I am new and doing some project which required to used Blynk bridge to connect two Arduino-Ethernet Board.

I follow the demo code given by Blynk-Doc and it work that second board LED in Pin 9 flash every second. :slight_smile:

On the other hand, I want to view the result from Virtual Pin V5 in Second Board, but try the using demo code also not success:

BLYNK_WRITE(V5){
int pinData = param.asInt(); // pinData variable will store value that came via Bridge
}

Could I know which line I should insert in my Second Board (Slave) program?

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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = β€œMy-Code”;

void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
// You can also specify server.
// For more options, see Transports/Advanced/CustomEthernet example
//Blynk.begin(auth, β€œserver.org”, 8442);
//Blynk.begin(auth, IPAddress(192,168,1,100), 8888);
}

void loop()
{
Blynk.run();
}

My First (Master) Board Program:

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = β€œYourAuthToken”;

// Bridge widget on virtual pin 1
WidgetBridge bridge1(V1);

// Timer for blynking
SimpleTimer timer;

static bool value = true;
void blynkAnotherDevice() // Here we will send HIGH or LOW once per second
{
// Send value to another device
if (value) {
bridge1.digitalWrite(9, HIGH); // Digital Pin 9 on the second board will be set HIGH
bridge1.virtualWrite(V5, 1); // Sends 1 value to BLYNK_WRITE(V5) handler on receiving side.

/////////////////////////////////////////////////////////////////////////////////////////
// Keep in mind that when performing virtualWrite with Bridge,
// second board will need to process the incoming command.
// It can be done by using this handler on the second board:
//
//    BLYNK_WRITE(V5){
//    int pinData = param.asInt(); // pinData variable will store value that came via Bridge
//    }
//
/////////////////////////////////////////////////////////////////////////////////////////

} else {
bridge1.digitalWrite(9, LOW); // Digital Pin 9 on the second board will be set LOW
bridge1.virtualWrite(V5, 0); // Sends 0 value to BLYNK_WRITE(V5) handler on receiving side.
}
// Toggle value
value = !value;
}

void setup()
{
Blynk.begin(auth);

// Call blynkAnotherDevice every second
timer.setInterval(1000L, blynkAnotherDevice);
}

BLYNK_CONNECTED() {
bridge1.setAuthToken(β€œOtherAuthToken”); // Place the AuthToken of the second hardware here
}

void loop()
{
Blynk.run();
timer.run();
}

Thanks in advance if someone could help.

:grinning:

Code snippets should be formatted. Please edit your initial post:

How to do that:


 ``` cpp <--put 3 backticks BEFORE your code starts  //("cpp" means C++ language) 

   //Put your code here
   //..................
   //..................

 ``` <--insert 3 backticks AFTER your code

**This makes your code readable and with highlighted syntax, like this

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//comment goes here 
void helloWorld() { 
   String message =  "hello" + "world"; 
}
1 Like

Is there any way to detect codes automatically and format it,it can make our life simplier :slight_smile:

You can help is with developing such plugin for
discourse.org - we’d be happy to use it :wink: