Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raspberry Pi UART serial wont work

I am trying to send/receive data over serial connection (GPIO UART pins) between a Raspberry Pi (B model, raspian wheezy) and an STM32F4 board.

To setup the serial port, i followed all the stepts found in several tutorials like: http://elinux.org/RPi_Serial_Connection#Preventing_Linux_using_the_serial_port

When failing to get a connection to the STM32F4 board, i read that you can test the serial port locally on the pi if you just connect the TX, RX pins off the pi to eachother and it should just repeat the entered data in minicom.

sadly this does not work either.

The settings for ttyAMA0 in files 'cmdline' and 'inittab' are ok. (like described in many tutorials)

and allso tried auto configuration scrips from https://github.com/lurch/rpi-serial-console

Connecting RX to the TX pin on rpi directly does not give any output in minicom. I allso tried with a python script that repeats given input. Nothing seems to work, i'm kind of lost here.

Minicom start command should be correct(tried with different baud rates):

root@raspberrypi:/home/jef# minicom -b 9600 -o -D /dev/ttyAMA0

OPTIONS: I18n
Compiled on Apr 28 2012, 19:24:31.
Port /dev/ttyAMA0

On the bottom of minicom it allways shows status offline:

CTRL-A Z for help |  9600 8N1 | NOR | Minicom 2.6.1  | VT102 |      Offline

When checking available serial ports with python nothinig is swown:

python -m serial.tools.list_ports
no ports found

User is in dailout group so that should not be the issue(tried as root and non root):

root@raspberrypi:/home/jef# id
uid=0(root) gid=0(root) groups=0(root),20(dialout),1001(indiecity)

Verification that serial port is not used by getty anymore:

root@raspberrypi:/home/jef# ps aux | grep getty
root      2809  0.0  0.1   3740   804 tty1     Ss+  10:36   0:00 /sbin/getty --noclear 38400 tty1
root      2810  0.0  0.1   3740   804 tty2     Ss+  10:36   0:00 /sbin/getty 38400 tty2
root      2811  0.0  0.1   3740   804 tty3     Ss+  10:36   0:00 /sbin/getty 38400 tty3
root      2812  0.0  0.1   3740   804 tty4     Ss+  10:36   0:00 /sbin/getty 38400 tty4
root      2813  0.0  0.1   3740   804 tty5     Ss+  10:36   0:00 /sbin/getty 38400 tty5
root      2814  0.0  0.1   3740   804 tty6     Ss+  10:36   0:00 /sbin/getty 38400 tty6
root      3129  0.0  0.1   2012   624 pts/0    S+   11:57   0:00 grep getty

i checked for other apps using ttyAMA0, allso nothing:

root@raspberrypi:/home/jef# ps aux | grep ttyAMA0
root      3125  0.0  0.1   2012   628 pts/0    S+   11:56   0:00 grep ttyAMA0

users has correct rights to access serial port:

root@raspberrypi:/home/jef# ls -l /dev/ttyAMA0
crw-rw---T 1 root dialout 204, 64 Dec 25 11:53 /dev/ttyAMA0

Is there anything i missed? I read about 20 different tutorials and blogs on how to setup the serial port and i can't fond what causes this. Could you give me some advice i could look for please.

like image 947
Martin Law Avatar asked Dec 25 '13 11:12

Martin Law


People also ask

How do I connect Raspberry Pi to serial?

Connect the Raspberry Pi board to a +3.3V serial device. To receive data, connect the GPIO 15 (UART0_RXD) pin on the Raspberry Pi board to the TxD pin on the serial device. To transmit data, connect the GPIO 14 (UART0_TXD) pin on the Raspberry Pi board to the RxD pin on the serial device.

How does UART work on Raspberry Pi?

UART - Universal Asynchronous Receiver/TransmitterUART is commonly used on the Pi as a convenient way to control it over the GPIO, or access the kernel boot messages from the serial console (enabled by default). It can also be used as a way to interface an Arduino, bootloaded ATmega, ESP8266, etc with your Pi.


2 Answers

I just went through something similar today. I had to set minicom to disable hardware control and the looping worked for me, as well as cross connecting 2 Raspis together over UARTs.

Also, I use 115200 buad rate on my TTYAMA0 connection string minicom -b 115200 -o -D /dev/ttyAMA0

Alt A

Z

O

Serial Port Setup [enter]

F toggles hardware flow control off

*Save those settings and anything you type should show up on the screen, but is actually being transmitted via uarts.

My minicom footer looks like this as well (just diff baud rate, but shows offline also but works)

CTRL-A Z for help |115200 8N1 | NOR | Minicom 2.5 | VT102 | Offline

Good Luck!

like image 186
GDubYa Avatar answered Oct 23 '22 23:10

GDubYa


I have an Arduino connected to my Raspberry Pi serial port via a level shifter (3.3v to 5v) and was also having issues with minicom. I could receive the output from the Arduino in minicom but I couldn't get anything to send no matter what settings I tried. I also had exactly the same problem with minicom using the Arduino plugged in to the USB (/dev/ttyUSB0).

In the end I resorted to using the basic python serial console, install pyserial using pip (pip install pyserial) and execute the following command:

python -m serial.tools.miniterm -p /dev/ttyAMA0 -e
like image 27
Robert Hunt Avatar answered Oct 23 '22 21:10

Robert Hunt