[SOLVED] How to send data from One Arduino to others Arduinos

Hi, I want to send some value from one Arduino to other Arduinos, I run sketch Bridge ok, but I dont know how to send value to the second Arduino, it read and println the value. The code I use is https://github.com/blynkkk/blynk-library/blob/master/examples/Widgets/Bridge/Bridge.ino#L33. The code for second Arduino is https://github.com/blynkkk/blynk-library/blob/master/examples/BoardsAndShields/Arduino_Ethernet/Arduino_Ethernet.ino

Please show your sketch. Maybe problem in it?

here is my code for transmit

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * Control another device using Bridge widget!
 *
 * Bridge is initialized with the token of any (Blynk-enabled) device.
 * After that, use the familiar functions to control it:
 *   bridge.digitalWrite(8, HIGH)
 *   bridge.analogWrite(3, 123)
 *   bridge.virtualWrite(1, "hello")
 *
 * WARNING :
 * For this example you'll need SimpleTimer library:
 *   https://github.com/jfturcot/SimpleTimer
 * Visit this page for more information:
 *   http://playground.arduino.cc/Code/SimpleTimer
 *
 *
 **************************************************************/
#define BLYNK_PRINT Serial
#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[] = "585f1a7c3f92406490f57a377ac18e7a";
byte arduino_mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x03 };
IPAddress arduino_ip ( 192,   168,   1,  13);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 192,   168,   1,   1);
IPAddress subnet_mask(255, 255, 255,   0);  
// Bridge widget on virtual pin 1
WidgetBridge bridge1(V1);

// Timer for blynking
SimpleTimer timer;
int value1;
void setup()
{ Serial.begin(9600); // See the connection status in Serial Monitor

   Blynk.begin(auth, "cloud.blynk.cc", 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);

 while (Blynk.connect() == false) {
    // Wait until connected
  }

  bridge1.setAuthToken("2a70b4f685224db185ada22994035b46");


  // Call blynkAnotherDevice periodically
  timer.setInterval(1000, blynkAnotherDevice);
}

static bool value = true;
void blynkAnotherDevice()
{
  // Send value to another device
  if (value) {
 int value1=1234;
    bridge1.digitalWrite(9, HIGH);
    bridge1.virtualWrite(V22,value1);
  } else {
    bridge1.digitalWrite(9, LOW);
    bridge1.virtualWrite(V22,value1);
  }
  // Toggle value
  value = !value;
}

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

here is my code for receive

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * You can use this sketch as a debug tool that prints all incoming values
 * sent by a widget connected to a Virtual Pin 1 in the Blynk App.
 *
 * App dashboard setup:
 *   Slider widget (0...100) on V1
 *
 **************************************************************/

#define BLYNK_PRINT Serial
#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[] = "2a70b4f685224db185ada22994035b46";
WidgetBridge bridge1(V1);
SimpleTimer timer;
byte arduino_mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
IPAddress arduino_ip ( 192,   168,   1,  12);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 192,   168,   1,   1);
IPAddress subnet_mask(255, 255, 255,   0);  
void setup()
{
  Serial.begin(9600);
 Blynk.begin(auth, "cloud.blynk.cc", 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
while (Blynk.connect() == false) {
    // Wait until connected
  }

  bridge1.setAuthToken("2a70b4f685224db185ada22994035b46");


  // Call blynkAnotherDevice periodically
//  timer.setInterval(1000, blynkAnotherDevice);
}

// This function will be called every time
// when App writes value to Virtual Pin 1
static bool value = true;
void blynkAnotherDevice()
{
  // Send value to another device
  if (value) {
 int value1=1234;
   // bridge1.digitalWrite(9, HIGH);
   // bridge1.virtualWrite(V22,value1);
  } else {
  //  bridge1.digitalWrite(9, LOW);
   // bridge1.virtualWrite(V22,value1);
  }
  // Toggle value
  value = !value;
}
void loop()
{
  Blynk.run();
  timer.run();
yield();
}
//BLYNK_WRITE(V20)

BLYNK_WRITE(V21)
{
int value1 = param.asInt();
Serial.print("slider val v21 = ");
Serial.println(value1);
Blynk.virtualWrite(24,value1);
}
/*
BLYNK_WRITE(V22)
{
int slidV22val = param.asInt();
Serial.print("slider val v22 = ");
Serial.println(slidV22val);
Blynk.virtualWrite(23,slidV22val);
}
*/

This is doesn’t look like code from our bridge snippet. It should be :

while (Blynk.connect() == false) {
// Wait until connected
}
bridge1.setAuthToken(“OtherAuthToken”);

Same for second part. It must have while (Blynk.connect() == false))

1 Like