1

I am trying to read data from a Blynk widget via ESP8266 and Arduino UNO and trying to send it to another slave Arduino UNO. But, the problem is the data is taking some time to reach to the slave Arduino for further processing and I need it to be fast as it is needed for controlling a drone.

If any one can help, please help. I am a tenth grader and a newbie. So, I don't have a lot of experience.

Here is the code for the master Arduino:

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>   //We are using software serial so as not to conflict with serial download and monitor

SoftwareSerial mySerial(5,6); // RX, TX

int of=0;
int throttle=0;

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "wifi_name";
char pass[] = "wifi_pass";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&Serial);
WidgetLED l(V3);

void setup()
{
 // Debug console
 Serial.begin(9600);
 delay(10);
 // Set ESP8266 baud rate
 Serial.begin(ESP8266_BAUD);
 delay(10);
 Blynk.begin(auth, wifi, ssid, pass);
 mySerial.begin(9600);
}

void loop()
{
 Blynk.run();
 l.on();
 mySerial.write(of);
 mySerial.write(throttle);
}

BLYNK_WRITE(V1)
{
  of = 100+param.asInt();
}

BLYNK_WRITE(V2)
{
  throttle = param.asInt();
}
7
  • 1
    how do you know that the bottleneck is the baud rate? ... the slave code could easily be running slow – jsotola Jan 16 at 17:01
  • 1
    If the distance (wires) between the 2 processors is short enough, you might consider I2C or SPI. Also, for speed you should make sure you are using all the hardware support available and not emulating serial ports using software. If there are not enough hardware resources on the processors used on the Arduino boards you picked out - consider using a more capable processor on a different Arduino board. – st2000 Jan 16 at 18:44
  • A practical answer to the maximum baud of SoftwareSerial is non-trivial and probably not as helpful to you as you might expect in solving the fundamental problem of getting information from Blynk through to whatever in your project actually needs that information timely. Typically in aerial (I presume) drone applications, people are concerned about weight as well. So, I'm curious: are all three of these things going to be mounted on the drone? (Why) do you need all three? – timemage Jan 17 at 20:25
  • Yes all three are mounted on the drone... but i have quite powerful motors and 10*4.5 blades @timemage – coder-ari Jan 18 at 9:00
  • @jsotola yeah that was the problem....thank you for ur help but now there is another problem it is tipping over :) – coder-ari Jan 18 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.