3

UART on my pi cannot send data, I can receive data from another machine, but I cannot send any data using the 'tx' pin of UART. I also try to connect 'tx' and 'rx' on my pi, but still no data is sent or received.

I think it's a software problem, because I tried to burn a fresh image of Raspbean to my SD card, UART works fine. But with my existing system image, it cannot send data. I have made a lot of changes on my current system and want to keep it, but I don't know what I should do to make UART work correctly.

I have followed this blog, and still does not work. http://www.irrational.net/2012/04/19/using-the-raspberry-pis-serial-port/

UPDATE:

I have run gpiotest from here http://abyz.me.uk/rpi/pigpio/examples.html#Shell_code

And the result is good as shown below.

Skipped non-user gpios: 0 1 28 29 30 31
Tested user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Failed user gpios: None
  • Could you download/install pigpio and then run this gpio test. – joan Nov 11 '14 at 14:52
  • Sure. The result is good. I have added results above. – Jiechao Li Nov 12 '14 at 4:19
  • That shows the gpios can be set high and low and that the internal pull-up/downs are working properly. That means the UART is probably OK. TX is pin 8 (gpio14), RX is pin 10 (gpio15). Can you link the TX/RX. Then stty -F /dev/ttyAMA0 9600 (to set 9600bps). In one window cat </dev/ttyAMA0 (to read UART), in another window ls -R / >/dev/ttyAMA0 (to do a file list). – joan Nov 12 '14 at 8:06
2

I have solved my problem. The reason is that I used gpio14, which is TX, as an input in another script. So it won't send anything, because it'a already configured for other use, and I forget about that.

Thanks

  • 1
    For those who don't know. Each gpio can be in one of eight modes - INPUT, OUTPUT, ALT0, ALT1, ALT2, ALT3, ALT4, or ALT5. To work as the UART gpios 14/15 must be in mode ALT0. If you set them as inputs or outputs they will be in the wrong mode and will need to set to mode ALT0 for the UART to work. – joan Nov 12 '14 at 13:53

Your Answer

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

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