2

I had hooked up the Arduino Uno to the RPi through USB connection. The Arduino contains a light sensor and it will transfer data to the RPi. The baud rate used was 115200. This baud rate was used due to the program in Arduino.

When I connect the Arduino to my laptop, the data received was fine. But when I connect it to the RPi, there were some data loss when transferring data through USB. I tried to transfer simple data across and it was ok. But with higher data load, the data received at the RPi end is not complete.

A similar problem was faced by E.Lee :How can I ensure all data sent from an Arduino is received by a Raspberry Pi?

I need help in overcoming this issue here. Any way to improve the efficiency of data transfer? Any help is much appreciated. Thank you.

2
  • Are you powering the Arduino from the RPi? Have you tried with an external power supply for the arduino?
    – Craig
    Apr 10, 2014 at 15:38
  • Hi there, I had tried with and without an external power supply and the results are still the same. My received data is still not complete. Will overclocking the RPi help in this situation?
    – wengzhe
    Apr 11, 2014 at 2:42

3 Answers 3

1

Since you're not using full UART handshaking, it's your responsibility to make sure you are clearing the serial buffer before it overflows.

If you're not going to change the sender to use handshaking (RTS/CTS or XON/XOFF) or lower the baudrate. The only avenue left for you is to read from the buffer really really often.

I'm not sure what size the hardware buffer is - but assuming 8 bytes, you'll need to be polling it at minimum of 115200/8 = 14400Hz.

I don't think the scheduler will give you a guarantee of a slice every 70 microseconds

1
  • Thanks for your feedback. I got a better understanding on this situation now. Are there any simple ways of implementing a handshake or if I want to read from the buffer more often, how do I go about it?
    – wengzhe
    Apr 10, 2014 at 14:42
0

You don't give any details of the data protocol or the program code you are using to receive it, so the following is speculation.

You have no chance of logging continuous 115200 baud data using polling on the Pi. If you use flow control it can be done, but this, of course reduces the overall throughput.

Assuming the kernel driver buffers the data (I know the normal serial input does, but not how it is handled by USB drivers) you should be able to handle it by processing lines or buffers of data. I have written such code in c using the normal serial drivers in the kernel (and the wiringPi library).

2
  • Hi there, thanks for your reply. My setup is based on: doctormonk.com/2012/04/raspberry-pi-and-arduino.html The output from the Arduino is continuous as a string of numbers. Are there any good examples of flow control available?
    – wengzhe
    Apr 10, 2014 at 14:45
  • This example sends a string followed by a 1sec delay - this is not what you claim to be doing. If you want further help post your code.
    – Milliways
    Apr 11, 2014 at 12:14
0

Are you using USB at both ends?

The Pi's UART (pins P1-8/10) work quite happily at 115200 and beyond. Linux has something like a 60KB serial buffer so you have to write particularly shoddy code for that buffer to overflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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