1

I have equipment transmitting data via uart with a baud rate of 1382400 and I would like to read this information through the Serial2 port of the ESP32. I've tried to set this high baud rate using Serial2.begin(1382400) but I can't read anything. Using the function below to detect the baud rate I can read a maximum of 922190 bauds. Below is the sketch I used to check the baudrate:

void setup() {

     Serial.begin(115200);
     delay(100);
     Serial.println();
     // Passing 0 for baudrate to detect it, the last parameter is a timeout in ms
     Serial2.begin(0, SERIAL_8N1, -1, -1, true, 11000UL);  
     
     unsigned long detectedBaudRate = Serial2.baudRate();
     if(detectedBaudRate) {
       Serial.printf("Detected baudrate is %lu\n", detectedBaudRate);
     } else {
       Serial.println("No baudrate detected, Serial2 will not work!");
     }
   }

void loop() {
  // put your main code here, to run repeatedly:

}

The answer I get is as follows: Detected baud rate is 922190

I managed to communicate between the equipment and the esp32 using a baud rate of 115200. I changed the baud rate to 230400 and I couldn't communicate anymore. From 230400 no baud rate worked.

The transmitting equipment uses pic 18F4520 and engineering sent me the following information:

The crystal of the equipment is 11.0592 MHz The PLL quadruples this frequency, so the pic's clock is 44.2368 MHz I connect the tx with the rx , I interconnect the GND. As far as I understand it is not a connection problem because in 115200 it works. Unfortunately I can't change it to 115200 definitively because it changes other functions of the equipment.

Is this a limitation of ESP32? Could I do something else to test? Sorry for the long post and language mistakes as English is not my main language .

4
  • ESP32 can operate up to 922190 bps without any problem. I use it all the time. In fact, it is default upload speed every time you update code to the ESP32. If there is any something that doesn't work, it is more likely that your PIC18F4520 can't support it.
    – hcheung
    Mar 9 at 0:40
  • @hcheung - I asked to set the speed of the pic to 922190 and even then I couldn't communicate. Using the code in the question I realized that the baudrate difference detected exceeds 3%, could this be the source of the problem? Another curiosity, using Realterm for windows and setting it to 922190 I also can't read anything in esp. Mar 9 at 1:06
  • Well, maybe you should ask whoever ask you to run PIC at 922190, why he/she think the PIC can run at that speed according to table 18-3 (page 196) of 18F4520 datasheet?
    – hcheung
    Mar 9 at 2:57
  • @hcheung - yes according to the manual 115200 would be the maximum but in the equipment the current speed is 1382400 bps. This equipment communicates at this high speed with an hc-06 module. So I believe it could be something with the ESP32. The hardware developer makes it available via bluetooth , command to change the communication speed going up to 1382400. If you want I can detail the calculation he explained to me to see it clarifies something. Mar 9 at 4:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.