I am trying to establish a communication between Arduino Uno ( Master) and ESP32 (Slave) using RS485 protocol (using MAX485 module). I have successfully done this between two Arduino Unos. SoftwareSerial library is what i am using between two Arduino Unos, now trying with ESP32 and Arduino Uno (using MAX485 module) . For ESP32 i have used SoftwareSerial (https://github.com/akshaybaweja/SoftwareSerial) library.

After reading the library and making connection i am not be able to establish a communication between them. Sharing my code below.


#include <SoftwareSerial.h>

SoftwareSerial softwareSerial(9, 10);
String str;

void setup()



void loop()

  while (softwareSerial.available() > 0) {

    char inChar = softwareSerial.read();

    if (inChar == '$') {

        Serial.println("received command" + str);
        memset(&str, 0, sizeof(str));
    else {
        str = str + inChar;




#include <SoftwareSerial.h>

SoftwareSerial swSer1(22, 23, false, 256);
String str;

void setup() {



void loop() {

  String sendCmd = "MSG1$";
  Serial.println("Sending ");
  Serial.println(sendCmd );
  char copy[50];
  sendCmd.toCharArray(copy, 50);


Here my question is where i am going wrong in this project. Please guide me.

Note : DE AND RE PINS are connected to high for sender device and to low for receiver device as given in the RS485 documentation.

2 Answers 2


Maybe you have already solved this but in any case, have you tried working with the hardware serial ports? You have three of them in the ESP32. I read sowhere else that there may be some interrupt issues using the SoftwareSerial library on the ESP devices, especially at higher baud rates.

  • I havent solved yet , i changed the circuit itself other than what i was using.. also i have tried but those are not so helping me in my application. Commented Jul 18, 2019 at 20:48
  • @dejoo Where you read about some interrupt issues? I work in Arduino Libraries and I'll like receive this information. Thanks!:) Pd. I can't comment because I just registered Commented Oct 28, 2020 at 14:59

I don't think you can use pins 9 and 10 they are connected to the internal mSPI flash, uart0 is connected to FTDI usb chip, use uart2 on 16 and 17.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.