Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By EdZamper
#69800 Hello there friends,

Question: Can somebody confirm if it is possible to communicate a couple of ESP8266-01 modules using Serial pins (not Wifi). I have an application where I need this configuration. In order to test if possible, I wired 2 ESPs using SoftwareSerial library and trying to send a message to each other via TX and GPIO2 pins.
In order to verify if it was successful, I send the received message via UDP to a 3rd ESP configured as AP, that will monitor traffic between these 2 ESPs (configured as Stations or STA).
UDP comm is working perfect, but I cannot manage to receive the string via the HW Serial, no matter how many different configurations I try. This latest one is even faulting my ESPs with some weird memory overflow that throws an exception.
Here's my STA configuration (loaded in both target ESPs:

Code: Select all//Test Serial transmission through hardwired pins using two ESP8266-01s (ESP1/ESP2)
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <SoftwareSerial.h>

WiFiUDP Udp;
unsigned int localPort = 9000;
const char *ssid = "TEST_SERIAL_AP"; 
const char *password = "00000001";
SoftwareSerial ESPSerial(3,2);                 //Use TX as 3, GPIO2 as 2 on both chips
IPAddress StaticIP(192, 168, 4, 12);         //Address of the target GATEWAY     
IPAddress Target_AP(192, 168, 4, 3);         //Address of THIS AP
IPAddress Subnet(255, 255, 255, 0);
char c;
char conversion[255];
String inputString;


void setup() {
  // Open Serial communications
  delay(5000);
  //Serial.begin(115200);                     //Not sure if I can start the HW and SW serials so I disabled SW
  ESPSerial.begin(115200);
  WiFi.disconnect();  //disconnect to attempt credentials clearance
  WiFi.setAutoConnect(true); //reconnect if WiFi lost
  WiFi.mode(WIFI_STA);
  WiFi.config(StaticIP, Target_AP, Subnet);
  WiFi.begin(ssid, password);
  Serial.print("Attempting connnection to AP");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print("|");
    delay(500);
  }
  Udp.begin(localPort); 
  delay(1000);
 }

void loop()
  { 
    ESPSerial.println("Message from ESP2!"); //Send through HW serial pins 3,2 from ESP1 --> ESP2
    delay(50);     
      if(ESPSerial.available())         //Wait from response from ESP2 --> ESP1
      {         
         while(c != '\n')  //While message has no new line character
          {
            c = ESPSerial.read();             //read the port and store on a single char
            inputString += c;                 //May not be neeeded as string since will be ported to char array but I need this elsewhere
          }
      }
           
            inputString.toCharArray(conversion, 255);  //Convert and buffer
            Udp.beginPacket(Target_AP,localPort);    //Send to AP to display                                                                                                                                     
            Udp.write(conversion);   // Send to 3rd chip as AP to prove that message was received
            Udp.endPacket();
            delay(200);   
   }         
   



I just need to be sure that Serial communication can in fact be established between 2 ESP8266-01, and if at 115200 bauds, even better.
If you can confirm the right direction or share working code, I would appreciate it.

Thanks!
-EZ