Blank screen On The Serial Monitor

How could a hardware serial port fix this problem ?

It may not fix the problem but it would remove one of the possible causes of the problem

Thanks for the extra advice, but nobody seems to know what the real problem is :frowning:

This does not work, even such a simple example. (The link that you sent doesn't cover this)

I've been stuck for days :confused:

I ran your code on a Wemos D1 and an Arduino Uno. I placed a delay after the print statement and I see correct values in the monitor connected to the Uno.

NodeMCU.print("Hello"); 
    delay(1000);

cattledog:
I ran your code on a Wemos D1 and an Arduino Uno. I placed a delay after the print statement and I see correct values in the monitor connected to the Uno.

NodeMCU.print("Hello"); 

delay(1000);

I just tried the exact same thing and still nothing happend.

Here is how I send serial from a ESP32:

this is the declare code:

#include <HardwareSerial.h>

HardwareSerial SerialTFMini( 1 );
HardwareSerial SerialController( 2 );
////// serial(1) = pin27=RX green, pin26=TX white
////// serial(2) = pin16=RXgreen , pin17=TX white

#define SerialDataBits 115200

this is the setup code:

Serial.begin( SerialDataBits );
  SerialController.begin( SerialDataBits );
  SerialTFMini.begin(  SerialDataBits, SERIAL_8N1, 27, 26 );

Hre is the send code

void fSendSerialToController( void *pvParameters )
{
  struct stu_LIDAR_INFO pxLIDAR_INFO;
  xSemaphoreGive ( sema_SendSerialToController );
  for (;;)
  {
    xEventGroupWaitBits (eg, evtSendSerialToController, pdTRUE, pdTRUE, portMAX_DELAY);
    if ( xSemaphoreTake( sema_SendSerialToController, xZeroTicksToWait ) == pdTRUE ) // grab semaphore, no wait
    {
      String sSerial = "";
      sSerial.reserve ( 300 );
      int CellCount = 1;
      xSemaphoreTake( sema_LIDAR_INFO, xSemaphoreTicksToWait );
      xQueueReceive ( xQ_LIDAR_INFO, &pxLIDAR_INFO, QueueReceiveDelayTime );
      xSemaphoreGive( sema_LIDAR_INFO );
      sSerial.concat( "<!," ); //sentence begin
      sSerial.concat( String(ScanPoints) + "," );
      for ( CellCount; CellCount <= ScanPoints; CellCount++ )
      {
        sSerial.concat( String(pxLIDAR_INFO.Range[CellCount]) + "," );
      }
      sSerial.concat( ">" ); //sentence end
      // Serial.println ( sSerial );
      SerialController.println ( sSerial );
      //  
      xEventGroupSetBits( eg, evtSendLIDAR_Info_For_ALARM );
      xSemaphoreGive ( sema_SendSerialToController );
    }
  }
  vTaskDelete( NULL );
} // void fSendSerialToController( void *pvParameters )

I figure the ESP's are of the same family.

Why use software serial when there are hardware options?

The ESP has several hardware options. Serial, (0), (1), and (2). The ESP does not use Serial1, Serial2, using those will not result in an error nor will it result in data transfer.

Till you have some experience with the ESP do not use serial port (0). That leaves (1) and (2). (2) is a port that you can use at the assigned pins or remap to use any other pins. (1) should be remapped from the default pins to ones of your own choosing.

Pins of the ESP matrix above 32 are receive (input) only. Don't expect to map pin 33 as rx and actually send data.

Here is code to receive serial for the ESP:

void fReceiveSerial_LIDAR( void * parameters  )
{
  bool BeginSentence = false;
  sSerial.reserve ( StringBufferSize300 );
  char OneChar;
  for ( ;; )
  {
    EventBits_t xbit = xEventGroupWaitBits (eg, evtReceiveSerial_LIDAR, pdTRUE, pdTRUE, portMAX_DELAY);
    if ( LIDARSerial.available() >= 1 )
    {
      while ( LIDARSerial.available() )
      {
        OneChar = LIDARSerial.read();
        if ( BeginSentence )
        {
          if ( OneChar == '>')
          {
            if ( xSemaphoreTake( sema_ParseLIDAR_ReceivedSerial, xSemaphoreTicksToWait10 ) == pdTRUE )
            {
              xQueueOverwrite( xQ_LIDAR_Display_INFO, ( void * ) &sSerial );
              xEventGroupSetBits( eg, evtParseLIDAR_ReceivedSerial );
              //
            }
            BeginSentence = false;
            break;
          }
          sSerial.concat ( OneChar );
        }
        else
        {
          if ( OneChar == '<' )
          {
            sSerial = ""; // clear string buffer
            BeginSentence = true; // found begining of sentence
          }
        }
      } //  while ( LIDARSerial.available() )
    } //if ( LIDARSerial.available() >= 1 )
  }
  vTaskDelete( NULL );
} // void fReceiveSerial_LIDAR( void * parameters  )

The code to receive serial works great when triggered from .25mS to 1mS. It is important to note this line: if ( LIDARSerial.available() >= 1 ). Note a 1 is used instead of a 0. I found a 1 is more reliable for data reception then a 0 for the Due, STM32, and ESP32. The received code does not parse the serial, that is done with another task.

I have changed to using the CAN buss for 2 wire data transfers. The ESP has a built in CAN buss transceiver, a single frame can carry 8*8 bits of info at 1Mb, works well with multiprocessor operations, data receive/send queuing, and handles multiple devices.

JasperJP:
Thank you but I have already made a project where I send data FROM my Arduino TO my ESP using seperators.

I don't understand - if the system works in one direction it should also work in the other direction.

If you have tried using the code from my Tutorial and it is not working as it should then please post the two programs that you uploaded to your ESP28266 and to your Mega and tell us in as much detail as possible what happens when you run the programs.

...R

Please don't cross post.
http://forum.arduino.cc/index.php?topic=607800

Duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes writing a detailed answer on this thread, without knowing that someone else already did the same in the other thread.

In the future, take some time to pick the forum section that best suits the topic of your question and then only post once to that forum section. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum section. It contains a lot of other useful information. Please read it.

Please don't cross post.
http://forum.arduino.cc/index.php?topic=607800

Duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes writing a detailed answer on this thread, without knowing that someone else already did the same in the other thread.

In the future, take some time to pick the forum section that best suits the topic of your question and then only post once to that forum section. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum section. It contains a lot of other useful information. Please read it.

Besides TX and RX do you have a common GROUND ?

Common mistake and easy to fix.

Hello JasperJP

I tried with a nodemcu esp-12e V2 amica and Arduino Uno with the 2 codes below. It runs fine.

ESP 1 :

//Emetteur nodemcu esp-12e V2 amica vers Arduino Uno
//ESP D8 connectée à Arduino pin 2
#include <ESP8266WiFi.h>;
#include <ESP8266HTTPClient.h>;
#include <SoftwareSerial.h>

SoftwareSerial NodeMCU(D7,D8);  //RX,TX

char car[4] = {'a','z','e'}; 
void setup () {
//   pinMode(D7,INPUT);
//   pinMode(D8,OUTPUT);  
   Serial.begin(57600);
//   while(!Serial);
   delay(50);         //nécessaire 50 ms mini
   Serial.println("ESP émetteur started");
  
   NodeMCU.begin(57600);
   delay(2);
}
void loop() {
  for (int i = 0; i<3; i++){  
    NodeMCU.print(car[i]);
    delayMicroseconds(2000);  //nécessaire 2 ms mini
    Serial.print(car[i]);
    delayMicroseconds(2000);  //nécessaire 2 ms mini
  }   
}

Uno :

//lecture par Arduino Uno données émises par ESP8266 nodemcu esp-12e V2 amica
//ESP D8 connectée à Arduino pin 2
#include <SoftwareSerial.h>
SoftwareSerial Arduino(2,3);  //RX,TX

String txt;

void setup() {
  Serial.begin(1000000);
  Arduino.begin(57600);
  Serial.println("Uno récepteur started");  
}
void loop() {
   while (Arduino.available() > 0 ) {
        txt = txt + Arduino.read();
        Serial.println(txt);
        txt = "";
   }
}

Only ESP D8 connected to UNO pin 2. And ,of course, a common ground.

[Modified] :

This code runs fine too :

ESP 2 :

//Emetteur nodemcu esp-12e V2 amica vers Arduino Uno
//ESP D8 connectée à Arduino pin 2
#include <ESP8266WiFi.h>;
#include <ESP8266HTTPClient.h>;
#include <SoftwareSerial.h>

SoftwareSerial NodeMCU(D7,D8);  //RX,TX
String car = "Hello";
//char car[4] = {'a','z','e'}; 
void setup () {
//   pinMode(D7,INPUT);
//   pinMode(D8,OUTPUT);  
   Serial.begin(500000);
//   while(!Serial);
   delay(50);         //nécessaire 50 ms mini
   Serial.println("ESP émetteur started");
  
   NodeMCU.begin(57600);
   delay(2);
}
void loop() {
//  for (int i = 0; i<3; i++){  
    NodeMCU.print(car);
    delayMicroseconds(2000);  //nécessaire 2 ms mini
    Serial.println(car);
    delayMicroseconds(2000);  //nécessaire 2 ms mini
//  }   
}

Regards,
bidouilleelec

bidouilleelec:
Hello JasperJP

I tried with a nodemcu esp-12e V2 amica and Arduino Uno with the 2 codes below. It runs fine.

ESP 1 :

//Emetteur nodemcu esp-12e V2 amica vers Arduino Uno

//ESP D8 connectée à Arduino pin 2
#include <ESP8266WiFi.h>;
#include <ESP8266HTTPClient.h>;
#include <SoftwareSerial.h>

SoftwareSerial NodeMCU(D7,D8);  //RX,TX

char car[4] = {'a','z','e'};
void setup () {
//  pinMode(D7,INPUT);
//  pinMode(D8,OUTPUT); 
  Serial.begin(57600);
//  while(!Serial);
  delay(50);        //nécessaire 50 ms mini
  Serial.println("ESP émetteur started");
 
  NodeMCU.begin(57600);
  delay(2);
}
void loop() {
  for (int i = 0; i<3; i++){ 
    NodeMCU.print(car[i]);
    delayMicroseconds(2000);  //nécessaire 2 ms mini
    Serial.print(car[i]);
    delayMicroseconds(2000);  //nécessaire 2 ms mini
  } 
}





Uno :


//lecture par Arduino Uno données émises par ESP8266 nodemcu esp-12e V2 amica
//ESP D8 connectée à Arduino pin 2
#include <SoftwareSerial.h>
SoftwareSerial Arduino(2,3);  //RX,TX

String txt;

void setup() {
  Serial.begin(1000000);
  Arduino.begin(57600);
  Serial.println("Uno récepteur started"); 
}
void loop() {
  while (Arduino.available() > 0 ) {
        txt = txt + Arduino.read();
        Serial.println(txt);
        txt = "";
  }
}




Only ESP D8 connected to UNO pin 2. And ,of course, a common ground.

[Modified] :

This code runs fine too :

ESP 2 :



//Emetteur nodemcu esp-12e V2 amica vers Arduino Uno
//ESP D8 connectée à Arduino pin 2
#include <ESP8266WiFi.h>;
#include <ESP8266HTTPClient.h>;
#include <SoftwareSerial.h>

SoftwareSerial NodeMCU(D7,D8);  //RX,TX
String car = "Hello";
//char car[4] = {'a','z','e'};
void setup () {
//  pinMode(D7,INPUT);
//  pinMode(D8,OUTPUT); 
  Serial.begin(500000);
//  while(!Serial);
  delay(50);        //nécessaire 50 ms mini
  Serial.println("ESP émetteur started");
 
  NodeMCU.begin(57600);
  delay(2);
}
void loop() {
//  for (int i = 0; i<3; i++){ 
    NodeMCU.print(car);
    delayMicroseconds(2000);  //nécessaire 2 ms mini
    Serial.println(car);
    delayMicroseconds(2000);  //nécessaire 2 ms mini
//  } 
}





Regards,
bidouilleelec

Thank you but still I only receive "Uno récepteur started", not the loop data.

JasperJP:
Thank you but still I only receive "Uno récepteur started", not the loop data.

Have you tried different pins?

Are you sure that there is some signals on D8?

bidouilleelec:
Have you tried different pins?

Yes but no difference.
I believe it doesn't work because of the pins layout.

  • Arduino Pin 2 is connected to ESP Pin D8.

  • Arduino Pin 3 is connected to ESP Pin D7.

  • ESP 3.3V is connected to 3.3V external power supply.

  • ESP GND is connected to GND external power supply.

(I have also connected the arduino's GND to the external GND, but that doesn't make any difference)

Is there something wrong with this layout ?

JasperJP:
Yes but no difference.
I believe it doesn't work because of the pins layout.

  • Arduino Pin 2 is connected to ESP Pin D8.

  • Arduino Pin 3 is connected to ESP Pin D7.

  • ESP 3.3V is connected to 3.3V external power supply.

  • ESP GND is connected to GND external power supply.

(I have also connected the arduino's GND to the external GND, but that doesn't make any difference)

Is there something wrong with this layout ?

I have only ESP D8 connected to UNO pin 2. And ,of course, a common ground.
Are you sure that there is some signals on D8?
Here, both ESP and UNO are powered by USB.

bidouilleelec:
I have only ESP D8 connected to UNO pin 2. And ,of course, a common ground.
Are you sure that there is some signals on D8?
Here, both ESP and UNO are powered by USB.

Yes but it just won't work :frowning:

Frankly I have lost track of what you have tried, but the ESP is a 3.3V device whilst the Uno is a 5V device. Have you tried a voltage converter between the two of them on both serial lines ?

UKHeliBob:
Frankly I have lost track of what you have tried, but the ESP is a 3.3V device whilst the Uno is a 5V device. Have you tried a voltage converter between the two of them on both serial lines ?

No I don't have that. (I am using seperate power supplies)
Sending data from the Arduino to the ESP works fine. But sending data back just won't work.

Hello UKHeliBob

UKHeliBob:
Frankly I have lost track of what you have tried, but the ESP is a 3.3V device whilst the Uno is a 5V device. Have you tried a voltage converter between the two of them on both serial lines ?

It's working fine here.

The only difference I see is that , here, my ESP and my UNO (not a Mega 2nd difference) are powered by USB.

Regards,
bidouilleelec

bidouilleelec:
Hello UKHeliBob

It's working fine here.

The only difference I see is that , here, my ESP and my UNO (not a Mega 2nd difference) are powered by USB.

Regards,
bidouilleelec

Your example also works with a 2nd gen NodeMcu board. While I use a 3th gen, but I don't see that being the problem.