Esp32 serial communication via max3232

Hello all,
I am trying to establish communication between my pcb equipped with esp32 and my pc to validate the serial.comunication.

I am usign the second uart channel of esp32 for this purpose. Having max3232 ic db9.connector, a rs232 to usb cable I am trying to access my windows machine.

The code is quite simple, just constantlt printing a message like hello world.

The problem should be in the hardware somewhere I think, but cannot see it honestly.

My pc recognize the device plugged in, using mobaxterm or uart assistant terminals for this purpose and there are no any messages nor errors. Uart assistant behaves like something is prited but ...

I would like to ask you for schematic review please.


Here is the sketch:


#include <HardwareSerial.h>

HardwareSerial mySerial(2);  // UART2 (GPIO 16 RX, GPIO 17 TX)

void setup() {
    mySerial.begin(9600); 
}

void loop() {
    mySerial.println("hello world"); 
    delay(2000);  
}

Nothing immediately jumps out at me in the MAX3232 part of the circuit. Connections there all look reasonable; RS232 pins are going to the DE9 and logic level pins are going to the processor and not vice versa. I'll take your word that the serial pins on the ESP32 are the right ones and the sketch shows the proper way to access them.

One thing... did you use the matching footprint for your DE-9 connector gender? A male is bass ackwards to a female connector in terms of pin placements.

If you've got an RS-232 checker and some DB-25 to DE-9 adapters, now would be the time to deploy them.

@maxpower1919 because 16 & 17 are the default pins for hardware uart 2 there is no need to use the HardwareSerial.h library.

Try the following for your test code.

const byte RXD2 = 16;
const byte TXD2 = 17; 

void setup() 
{
  
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2); 
}

void loop() {
    Serial2.println("hello world"); 
    delay(2000);  
}
2 Likes

First, is your MAX3232 powered by 3.3 V?

If you got a multimeter, drive the serial pins HIGH and measure the corresponding pins from MAX3232. If that's fine, measure the other side.

That's your problem.
Are you using a crossover cable sometimes called null-modem?

Hello, looking at max3232 datasheet it says that can be powered from 3.0 to 5V.

I will try to measure the levels.
Thanks!

Hello @jim-p,
I know of the straight thru and null modem cable, but since it is rs232 to usb, how can i identify which type it is.

Here is a picture of the cable


The datasheet should say.

Well, i agree with you, only if I know the manufacturer or the order code, just have the cable itself, the box is missing, but it should be a general made in china one, it should not be hard to find it!

Thanks

Since it has a male connector, it's probably correct and you can just plug it into the female connector on your board.
Why don't you write a simple sketch that just reads the RX pin and lights an LED. Then just send a bunch of characters from the terminal program.

Do you know if your ESP32 actually works?

2 Likes

Good idea!
Yes the esp32 is working for sure, as I am testing a few other sketches.

Sounds good, I will try to send something from my pc to the esp32, le's say will start with somethink like "k", if this symbol is send the esp32 will light an led. Got it!

Thanks

This way it is working,
Thanks @sumguy.

So it seems to be the way of initializing the second uart channel.

You may have to jumper, connect, RTS to CTS (7 and 8 on the DTE / DE9-to-USB).

1 Like

Yes, you need everything specified there.

1 Like

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