Is it recommended to use the transmit pin of ESP WROOM-02to display on LED

Good day! So I am working with ESP WROOM-02 connected to an RS485 transceiver to display data on a large LED.

So while uploading the code from Arduino IDE to my ESP WROOM-02, I am using the txd (transmit) pin to the usb to ttl cable
this is the connection:

After uploading the code I want my ESP to be then connected to the transceiver module which is then connected to LED.
My question is, can I reuse the transmit pin or can is it okay to use other GPIO in order for my ESP to transmit the data to LED over the transceiver module?

Any help is appreciated, I am not that familiar with working on pins input/output and Arduino ide in general.

Yes, use one of the other UARTs available on the ESP32 (and not SoftwareSerial).
ESP32, Arduino and 3 hardware serial ports | QuadMeUp

Serial2 is the easiest --

#define RXD2 16
#define TXD2 17

void setup() 
{
  // Note the format for setting a serial port is as follows: 
  // Serial2.begin(baud-rate, protocol, RX pin, TX pin);
  Serial.begin(115200);
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
  Serial.println("Serial Txd is on pin: "+String(TX));
  Serial.println("Serial Rxd is on pin: "+String(RX));
}

void loop()
{
  while (Serial2.available()) 
  {
    Serial.print(char(Serial2.read()));
  }
}

hi, I would like to ask for some clarifications,

the serial.begin(115200) - it is for the baud rate of ESP communication right?
then the serial2.begin(9600) is for the transmission of data to RS485 transceiver?
should I include the rx pin on the parameter of serial2.begin even if I will only send the data to the transceiver? can it be that I will only use this:
Serial2.begin(9600, SERIAL_8N1, TXD2);

also, inside the loop, should I use serial.write if I wanted to send my data to the transceiver?

Serial is for SerialMonitor.
Serial2 is, yes, the peripheral.
Include both vs one or the other - Not hard to try that.
In the loop use Serial2.write or Serial2.print depending whether you're sending a number or the representation of a number (the value 100 vs "100").

As for me, I will be using ESP WROOM-02 and not ESP32 and the only thing ESP do is to send and it does not need to receive feedback from LED. And I am planning to use the TXD pin of the ESP to send a packet of data to LED.

And AFAIK, Serial.begin is by default 8N1, but still I can declare this parameter, but my question is, Serial2.begin(baud-rate, protocol, RX pin, TX pin); in this sample code, I don't have to set my RX pin so can I just get rid of that in the parameter?

Also is this correct if I declare my TXD and set its pinMode and digitalWrite as well?

const int TX_PIN = 1; // GPIO1 of  ESP is the TXD

void setup() {
  Serial.begin(115200);
  pinMode(TX_PIN, OUTPUT);
}
void loop() {
  uint8_t header = 0xFF; // byte 0
  //set different address
  uint8_t address1 = 0xFA; // byte 1
  uint8_t address2 = 0xFB;
  uint8_t address3 = 0xFC;
  uint8_t address4 = 0xFD;
  uint8_t byte2= 0x10;
  uint8_t byte3= 0x12;
  uint8_t byte4= 0x34;
  uint8_t byte5= 0x56;
  uint8_t byte6= 0x00;

  // calculate the checksum
  uint8_t checksum1 = address1 + byte2+ byte3+ byte4+ byte5+ byte6;
  uint8_t checksum2 = address2 + byte2+ byte3+ byte4+ byte5+ byte6;
  uint8_t checksum3 = address3 + byte2+ byte3+ byte4+ byte5+ byte6;
  uint8_t checksum4 = address4 + byte2+ byte3+ byte4+ byte5+ byte6;

  uint8_t data1[] = {header, address1, byte2, byte3, byte4, byte5, byte6, checksum1};
  uint8_t data2[] = {header, address2, byte2, byte3, byte4, byte5, byte6, checksum2};
  uint8_t data3[] = {header, address3, byte2, byte3, byte4, byte5, byte6, checksum3};
  uint8_t data4[] = {header, address4, byte2, byte3, byte4, byte5, byte6, checksum4};

  digitalWrite(TX_PIN, HIGH); // set the RS485 transceiver to transmit mode

  Serial.write(data1, sizeof(data1)); // send data1 over serial
  Serial.write(data2, sizeof(data2));
  Serial.write(data3, sizeof(data3)); 
  Serial.write(data4, sizeof(data4)); 

  delay(100); // wait for "n" millisecond before sending the next data
}

I thought, mistakenly, that a WROOM02 is a ESP32.

I have this as my connections. I just came to realize that the Serial is for the computer and arduino communication mainly and using it to let my ESP send data to transceiver might be tricky.

So I will be trying to use Serial1 or Serial2 instead.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.