4

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 ?

  • What type of Uno? Clone? Check what USB bridge is used on your board. – Mikael Patel Jul 21 '17 at 9:48
  • Cheap Chinese clone. The chip seems to be a CH340G. – Thesaurus Rex Jul 21 '17 at 9:51
  • 2
    CH340G does not support 250 Kbps. See page 5, insidegadgets.com/wp-content/uploads/2016/12/… – Mikael Patel Jul 21 '17 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 ? – Thesaurus Rex Jul 21 '17 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. – Mikael Patel Jul 21 '17 at 12:07
6

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);
}
  • 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. – Thesaurus Rex Aug 1 '17 at 6:46
0

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.

  • 1
    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. – Greenonline Sep 24 '18 at 5:15

protected by VE7JRO Sep 4 at 18:08

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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