OLIMEX ESP32 EVB Blynk Bridge

OLIMEX ESP32 EVB with Ethernet
• Smartphone OS (iOS or Android) + version
• Local Blynk server
• Blynk Library version 6.1

Good day!
I got a problem sending a command across a bridge between two OLIMEX ESP32 EVBs. ESP32 # 1
should turn the relay on and off on ESP32 # 2 every second. but nothing happens. Controlling the same relay from the phone via the button widget works fine. The controller is connected by twisted pair. All other controller functions work. Blynk server connection is connected.
If you send values ​​across the bridge from the Arduino Mega, then everything works fine. The signal comes to both OLIMEX ESP32 EVBs. From here I concluded that the problem is precisely with sending from OLIMEX ESP32 EVB through the bridge.

Добрый день!
У меня появилась проблема с отправкой команды через мост между двумя OLIMEX ESP32 EVB. ESP32 №1
должна включать и выключать реле на ESP32 №2 каждую секунду. но ничего не происходит. Управление этим же реле с телефона через виджет “кнопка” работает отлично. Контроллера подключены витой парой. Все остальные функции контроллера работают. Связь с сервером блинк подключена.
Если отправлять значения через мост с Arduino Mega, то все работает отлично. Сигнал приходит на оба OLIMEX ESP32 EVB. Отсюда я сделал вывод что проблема именно с отправкой с OLIMEX ESP32 EVB через мост.

#define BLYNK_PRINT Serial

#include <ETH.h>
#include <BlynkSimpleEsp32.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "658675647";


WiFiUDP udpClient;
// Your WiFi credentials.
// Set password to "" for open networks.


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

// Timer for blynking
BlynkTimer timer;
static bool eth_connected = false;
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(33, HIGH);  // Digital Pin 9 on the second board will be set HIGH
    
    /////////////////////////////////////////////////////////////////////////////////////////
    // 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(33, LOW); // Digital Pin 9 on the second board will be set LOW
   
  }
  // Toggle value
  value = !value;
}

BLYNK_CONNECTED() {
  bridge1.setAuthToken("509857756"); // Place the AuthToken of the second hardware here
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  WiFi.onEvent(WiFiEvent);
  ETH.begin();
  Blynk.config(auth, IPAddress(10, 250, 4, 110), 8080);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

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

void WiFiEvent(WiFiEvent_t event)
{
  switch (event) {
    case SYSTEM_EVENT_ETH_START:
      Serial.println("ETH Started");
      //set eth hostname here
      ETH.setHostname("esp32-ethernet");
      break;
    case SYSTEM_EVENT_ETH_CONNECTED:
      Serial.println("ETH Connected");
      break;
    case SYSTEM_EVENT_ETH_GOT_IP:
      Serial.print("ETH MAC: ");
      Serial.print(ETH.macAddress());
      Serial.print(", IPv4: ");
      Serial.print(ETH.localIP());
      if (ETH.fullDuplex()) {
        Serial.print(", FULL_DUPLEX");
      }
      Serial.print(", ");
      Serial.print(ETH.linkSpeed());
      Serial.println("Mbps");
      eth_connected = true;
      break;
    case SYSTEM_EVENT_ETH_DISCONNECTED:
      Serial.println("ETH Disconnected");
      eth_connected = false;
      break;
    case SYSTEM_EVENT_ETH_STOP:
      Serial.println("ETH Stopped");
      eth_connected = false;
      break;
    default:
      break;
  }
}


void loop()
{

  if (eth_connected) {
    Blynk.run();
  }
  timer.run();
}

sorry for my english. translated via google translator

Hopefully both EVBs are connected to your network, via the router and a switch if necessary.
Are both devices showing as online in the Blynk app?

Pete.

1 Like

Yes, both devices are online in the Blynk app, connected via a switch. All other blynk functions work.

Shouldn’t your static variables be declared within the blynkAnotherDevice() function?

Pete.

Эти переменные объявлены глобальными. Я думаю это ничего не изменит

I think you should read-up on static variables.

Pete.

Мне это не помогло(( в blynk example browser statistic bool тоже объявлены в глобальных переменных
Проблема 100% связана с отправкой сообщения с моей платы на другую плату через мост.
Отправка сообщения с контроллера на приложение в телефоне работает отлично.
Прием сообщений с arduino mega на любую из моих esp32 через мост тоже хорошо работает.

Maybe you should share both sets of code, and details of the widgets you have set up in the app.

Pete.

Код загруженный в esp32 есть в моём первом посте. Виджеты в программе на телефоне: кнопка с настройками D33 (она работает нормально).
На второй esp32 код аналогичный, разница только в char auth[] и bridge1.setAuthToken(). На обоих контроллерах они введены верно. Их я проверил первым делом.

I think that’s your problem.

It’s difficult to piece together from what you’ve written exactly what your second board is doing, but it doesn’t sound like you are correctly processing the incoming bridge command on the second board.

If you are trying to do two-way bridging between the two boards then similar code on each board would be needed, but one way bridging would need significantly different code (without the second bridge Auth code).

There are several good bridge tutorials on the forum from @Gunner and others.

Pete.

Пит, данный код не должен требовать обработки на принимающей стороне.
Для проверки принимающего esp32 я временно отправлял на него команду с arduino mega (стандартный код из примера) в этой ситуации esp32 принял команду через мост. Отсюда я сделал вывод что проблема именно с отправкой с esp32. Может быть библиотека blynk для esp32 некорректно отрабатывает функцию мост через витую пару?

Unless you’re prepared to share both sets of code, plus the code you ran on the Arduino, it’s not really possible to comment any further, as it would just be guesswork.

Pete.

Arduino Mega 2560, Ethernet shield w5100 отправляет сообщения через мост на esp32(2). Эта связка работает отлично.
код Arduino Mega 2560:

    /*************************************************************
      Download latest Blynk library here:
        https://github.com/blynkkk/blynk-library/releases/latest

      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
        Sketch generator:           http://examples.blynk.cc
        Blynk community:            http://community.blynk.cc
        Follow us:                  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.digitalWrite("A0", LOW) // <- target needs to support "Named pins"
        bridge.analogWrite(3, 123)
        bridge.virtualWrite(V1, "hello")
     *************************************************************/

    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial


    #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[] = "5647654321";

    #define W5100_CS  10
    #define SDCARD_CS 4

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

    // Timer for blynking
    BlynkTimer 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(33, HIGH);  // Digital Pin 9 on the second board will be set HIGH
        
        /////////////////////////////////////////////////////////////////////////////////////////
        // 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(33, LOW); // Digital Pin 9 on the second board will be set LOW
       
      }
      // Toggle value
      value = !value;
    }

    BLYNK_CONNECTED() {
      bridge1.setAuthToken("509857756"); // Place the AuthToken of the second hardware here
    }

    void setup()
    {
      // Debug console
      Serial.begin(9600);

      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

      //Blynk.begin(auth);
      // You can also specify server:
      //Blynk.begin(auth, "blynk-cloud.com", 80);
       Blynk.config(auth, IPAddress(10, 250, 4, 110), 8080);

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

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

код esp32 (2)

       #define BLYNK_PRINT Serial

    #include <ETH.h>
    #include <BlynkSimpleEsp32.h>
    #include <ESPmDNS.h>
    #include <WiFiUdp.h>

    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "509857756";


    WiFiUDP udpClient;
    // Your WiFi credentials.
    // Set password to "" for open networks.


    // Timer for blynking
    BlynkTimer timer;
    static bool eth_connected = false;





    void setup()
    {
      // Debug console
      Serial.begin(9600);
      WiFi.onEvent(WiFiEvent);
      ETH.begin();
      Blynk.config(auth, IPAddress(10, 250, 4, 110), 8080);
      // You can also specify server:
      //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
      //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);


    }

    void WiFiEvent(WiFiEvent_t event)
    {
      switch (event) {
        case SYSTEM_EVENT_ETH_START:
          Serial.println("ETH Started");
          //set eth hostname here
          ETH.setHostname("esp32-ethernet");
          break;
        case SYSTEM_EVENT_ETH_CONNECTED:
          Serial.println("ETH Connected");
          break;
        case SYSTEM_EVENT_ETH_GOT_IP:
          Serial.print("ETH MAC: ");
          Serial.print(ETH.macAddress());
          Serial.print(", IPv4: ");
          Serial.print(ETH.localIP());
          if (ETH.fullDuplex()) {
            Serial.print(", FULL_DUPLEX");
          }
          Serial.print(", ");
          Serial.print(ETH.linkSpeed());
          Serial.println("Mbps");
          eth_connected = true;
          break;
        case SYSTEM_EVENT_ETH_DISCONNECTED:
          Serial.println("ETH Disconnected");
          eth_connected = false;
          break;
        case SYSTEM_EVENT_ETH_STOP:
          Serial.println("ETH Stopped");
          eth_connected = false;
          break;
        default:
          break;
      }
    }


    void loop()
    {

      if (eth_connected) {
        Blynk.run();
      }
      timer.run();
    }

При отправке сообщения через мост с esp32 (1) на esp32 (2) сообщения с esp32 (1) не отправляются.
Код esp32 (1) в моём первом сообщении.
Проводил эксперименты:
Отправка с Arduino Mega сообщений через мост на esp32 (1), в этом случае мост работает.
Менял местами esp32 (1) и esp32 (2), результат не изменился.
Отправка с esp32 (1) сообщений через мост на Arduino Mega, сообщения не пришли(((
Отправка с esp32 (2) сообщений через мост на Arduino Mega, сообщения тоже нет(((

What board type did you choose in the Arduino IDE when you compiled this code, and what board type is selected in the Blynk app for the board running the code in post #1 ?

Have you tried the code using a lower numbered digital pin?

Pete.

В Arduino IDE для моих плат я выбираю OLIMEX ESP32 EVB, in the Blynk app я установил ESP32 Dev Board (Ethernet)

да пытался. Еще я пытался и через VPin, с обработкой сообщения на принимающей стороне через BLYNK_WRITE(V…) результат отрицательный

я думаю что проблема с библиотекой BLYNK. Я очень расстроен что вы не можете мене помочь
=((

Any evidence??

The library is the essentially same base commands for all types of devices… and time tested true over many years.

As for the Blynk Bridge command, it is just a way for your code to emulate a virtual pin action, as normally done from the App. The Server is just acting as if the commands came from the App… AKA it doesn’t know the difference between an App command and a Bridge command, thus if an App widget does the job correctly, so will a properly coded Blynk Bridge command, regardless of the device used on either end.

Устройства находятся на одном сервере и на одной учетной записи. Все функции кроме моста работают исправно. Код я выложил. В чем тогда по вашему мнению проблема, если не в библиотеке?

I don’t spend nearly as much time here as I used too… so when I do, I don’t usually spend that time troubleshooting others code… But… while you have bridge commands such as this in the supposed “transmitting” code:

… I don’t see the requisite pinMode() settings for the digital pin in the supposed “receiving” code. While it sometimes seems unnecessary (a “feature” within Blynk for use with direct GPIO manipulation from the App), it is a better practice to follow proper Arduino coding and use it with all needed GPIO pins

I also had to correct your post with the two codes so that it could be properly interpreted :slight_smile:

Blynk - FTFC