5

With an Arduino-like board using a CH340 USB Serial chip, I'd like to send text lines as fast as possible to a Raspberry Pi through USB using the Serial.println() function. The problem is that when I set the serial speed to values above 230 400 with the Serial.begin(speed) function, the Arduino console crashes and the C program on the Rapsberry Pi displays garbage in its console, even though I set the same serial speed.

Short examples :

Serial.begin(230400);
Serial.println("Test !"); // Works fine.

Serial.begin(250000);     // Or any speed above 250 000.
Serial.println("Test !"); // Doesn't work at all.

This answered question states that 2 Mbauds is possible, so I'm a bit lost.

The Arduino IDE console offers various speed from 300 to 2 000 000 bauds, so why don't speeds above 230 400 work ?

8
  • What type of Uno? Clone? Check what USB bridge is used on your board. Commented Jul 21, 2017 at 9:48
  • Cheap Chinese clone. The chip seems to be a CH340G. Commented Jul 21, 2017 at 9:51
  • 2
    CH340G does not support 250 Kbps. See page 5, insidegadgets.com/wp-content/uploads/2016/12/… Commented Jul 21, 2017 at 9:53
  • Thank you for the datasheet and this information. But according to the document, speeds like 460 800 bauds and 2 000 000 bauds should work, so why would this not be the case with my board ? Commented Jul 21, 2017 at 10:55
  • 1
    Please remember that the baudrate is not the USB transfer rate. It is between the MCU and the USB bridge. Also the max sustained baudrate is approx. 100-200 Kbps with the Arduino HardwareSerial implementation. Commented Jul 21, 2017 at 12:07

2 Answers 2

8

CHG340 supports common baud rates: 50, 75, 100, 110, 134.5, 150, 300, 600, 900, 1200, 1800, 2400, 3600, 4800, 9600, 14400, 19200, 28800, 33600, 38400, 56000, 57600, 76800, 115200, 128000, 153600, 230400, 460800, 921600, 1500000, 2000000 baud.

250 000 baud isn't supported by that IC.

The Baud steps is either 200% or 150% of the previous value (There is exceptions).

Tested and working Baud rates.

I used putty as serial monitor since the built in monitor didn't have all baud rates preprogrammed.

SpeedTest.ino

// Serial port Baudrates:
// const int Speed = 115200;
// const int Speed = 128000;
// const int Speed = 153600;
// const int Speed = 230400;
// const int Speed = 460800;
// const int Speed = 921600;
// const int Speed = 1500000;
const int Speed = 2000000;

void setup() {
  // Initialize serial:
  Serial.begin(Speed);

  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}


void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
  Serial.print("Speed :  ");
  Serial.println(Speed);
}
4
  • This helped me, thanks ! Actually, I've found that my problem is due to serial latency, but I still managed to communicate at 1 Mbaud. Commented Aug 1, 2017 at 6:46
  • I have tested 3000000, which worked for me. See also eevblog.com/forum/microcontrollers/ch340-usb-uart-speed-tests
    – Adam
    Commented Jan 22, 2022 at 8:41
  • the windows driver only goes to 128000 Commented Oct 14, 2022 at 10:39
  • I have seen commenst that speeds abowe 115200 is "unstable" in both windows and linux
    – MatsK
    Commented Oct 14, 2022 at 15:01
-1

There may just be a workaround to allow this adapter to operate at 250000 baud (at least in the Raspberry Pi). The author of this article: http://dmxpi.blogspot.com/2014/04/dmx-on-raspberry-pi-start-here.html has modified the linux driver and claims it works. I hope this helps.

2
  • 2
    Please edit your answer to include the method/steps employed in the link. If the link dies then your answer will not be as useful as it could be. Commented Sep 24, 2018 at 5:15
  • i agree with @Greenonline Commented Dec 25, 2021 at 10:51

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