Can't Get ESP8266 with Blynk to Read Serial Data

Hello, I would like some help with my project !!!

I have an Arduino board doing a certain job and displaying some data on an LCD. All fine up to that.
What I would like, is to also display that data on my phone over the Internet.

I’ve used Blynk before to control and read hardware pins, but what I want to now is this:

I need a way to SEND DATA (specifically 3 or 4 float numbers) from my Arduino to my ESP8266 over SERIAL. Then I want to Write that data on a VIRTUAL Pin so I can display them on my Blynk app.

I’ve searched online and found a way of reading Serial Data.
This is how far I’ve gotten up till now…:

#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

const byte numChars = 32;
char receivedChars[numChars];
boolean newData = false;
int dataNumber = 0;

char auth[] = "***************************************";
char ssid[] = "*********";
char pass[] = "********";
int test;

BlynkTimer timer;

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(500L, recvWithStartEndMarkers);
  timer.setInterval(500L, showNewNumber);
}

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

void recvWithStartEndMarkers() {
  static boolean recvInProgress = false;
  static byte ndx = 0;
  char startMarker = '<';
  char endMarker = '>';
  char rc;
  while (Serial.available() > 0 && newData == false) {
    rc = Serial.read();
    if (recvInProgress == true) {
      if (rc != endMarker) {
        receivedChars[ndx] = rc;
        ndx++;
        if (ndx >= numChars) {
          ndx = numChars - 1;
        }
      }
      else {
        receivedChars[ndx] = '\0'; // terminate the string
        recvInProgress = false;
        ndx = 0;
        newData = true;
      }
    }
    else if (rc == startMarker) {
      recvInProgress = true;
    }
  }
}


void showNewNumber() {
  if (newData == true) {
    dataNumber = 0;
    dataNumber = atoi(receivedChars);
    newData = false;
    Blynk.virtualWrite(2, dataNumber);
  }

  /* test=random(50, 200);
    Blynk.virtualWrite(1, test);
    Serial.println("hi");  */

  /* This is actually used for testing. The VirtualWrite works flawlessly, but the SerialPrint does not print most of the time on my Serial Monitor. */
}

Most of the time, I can’t get the Serial.println(); commands to actually print something on my serial monitor, and I can’t get the ESP8266 to actually read Serial Data no matter what.
The Virtual Write command though, works as it should. Giving me a random number every run.

I’m quite new to programming and Arduinos so my knowledge is quite limited.
I’ve searched all night for this with no luck.
I would greatly appreciate your help ! <3

PS. I tried typing values through my Serial Monitor while the ESP8266 was connected and I also tried connecting it to a second Arduino that Serial Printed values in this format: where x is a number.

Look at somthing like EasyTransfer

1 Like

Hello, GunnerTechTools.

I think I kinda figured out how to use EasyTransfer.
I connected everything again using Serial, and used the code and libraries supplied on GitHub EasyTransfer’s page.

Seems to be working very well. I
Thanks a lot ! I appreciate it ! <3

Now I am going to try if I can Send AND Receive Data from both devices. A two-way communication.

Moreover, I found a new problem ! My Blynk App keeps saying it disconnected, but It all works after I changed the WiFi from my home’s router to my phone’s hotspot.
I suppose there is some problem with my router or its settings. I will figure that out on a next step !

I will post my code here later !!!

THANKS AGAIN !!!
Cheers !