The stock Debian image for the Raspberry Pi uses the UART as a serial console. I was able to connect to it from my Ubuntu laptop via my 3.3-volt USB FTDI TTL-232 cable. I connected Raspberry Pi’s ground pin to the ground pin of the FTDI, the Rasberry Pi’s TX pin to the FTDI’s RX pin and vice versa. (The Raspberry Pi’s pinout is available here.) Then on my Ubuntu laptop I installed minicom (sudo apt-get install minicom) and fired it up with:
minicom -b 115200 -o -D /dev/ttyUSB0
After typing in a username, I got a password prompt and was able to log in. Also, the serial console allowed me to see all the kernel output during boot, which could be handy someday.
But I wanted to use the Raspberry Pi’s UART for my own purposes, not as a serial console. To achieve that, I did the following.
First, I made a backup of the /boot/cmdline.txt file, which contains the kernel parameters:
sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
Then I edited it:
sudo vi /boot/cmdline.txt
Originally it contained:
dwc_otg.lpm_enable=0 rpitestmode=1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
I deleted the two parameters involving the serial port (ttyAMA0) to get the following:
dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
I rebooted (sudo reboot) to confirm that kernel output was no longer going to the serial port. But the serial console was still available. So I edited /etc/inittab:
sudo vi /etc/inittab
I commented out the following line:
2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Finally, I rebooted again and confirmed that nothing was touching the serial port anymore. Then, to test it out I installed minicom on the Raspberry Pi:
sudo apt-get install minicom
And ran it:
minicom -b 115200 -o -D /dev/ttyAMA0
After firing up minicom on my Ubuntu laptop again, I was able to send data in both directions!
Now to get the Raspberry Pi talking to an Arduino…
Pingback: More on Raspberry Pi serial ports | LAVA: The Source for Ports - Serial Port Experts
Pingback: Raspberry Pi’s onboard Serial connection « Random Hacks
Hi there, great write-up that is accessible to linux n00bs like me. I wonder if you can help me at all further please?
I want to attach a serial mouse systems mouse to my Pi.
I have a RS232 breakout board, and have swapped a MAX3232CPE chip in to make sure it’s 3V3 friendly.
I followed all of the above to help me detach the console from ttyAMA0
I learned about apt-get and installed inputattach and ldattach.
Set ldattach -s 1200 MOUSE /dev/ttyAMA0
Set inputattach –mousesystems /dev/ttyAMA0 &
sadly this does not seem to have resulted in, as I hoped, a working mouse
Out of ideas – all of the above was new to me!!! Can you offer any pointers please?
Cheers, Alex
hmmm? don’t your mouse directly after plugging into the USB port? :O
Pingback: Interfacing RFM12B to Raspberry Pi for cheap | Martin's corner on the web
Pingback: Bald Wisdom » Blog Archive » Preparing for à la mode: Raspberry Pi and Arduino
Thanks for that info. Now my little project works as it should!
http://www.youtube.com/watch?v=_W1WXnL9MeA&feature=youtu.be
Most serial mouses “steal” power from the other datalines (RTS/CTS etc.) to power themselves.. the RS232 breakoutboard you are using does not support these lines so the mouse is probably just not getting enough power to work.
Great post
Can you maybe give me an advice how to enable the RPi serial port adapter (USB) to send data from the RPi to a device with FTDI chip attached (connected to RPi USB)?
Thanks
Mitja
Hi, I have the RPi serial port working as a console connected to my PC. Like you, I wish to use the serial port for another purpose, sending and receiving ascii words to control off the shelf I/O cards.
I tried to edit the RPi’s cmdline.txt file; however, could not. Opening it in vi, I get one line of code “datadev=mmcblk0ps”. Then there are 21 lines with only the tilda character and then one line:
“/boot/cmdline.txt” [Incomplete last line] 1 line, 17 characters
Any help would be much appreciated!
Found my faults. Had installed Raspi using berry bootloader. This did load and run; however, there were discrepancies.
After loading the OS image using wind32diskimager, all is fine. Now looking at serial communication!
Thanks for the great info.
Pingback: Using the UART « Raspberry Pi Projects
Pingback: Raspberry Pi as an Xbee Wireless Sensor Network Gateway « Tinaja Labs
Pingback: Raspberry Pi Serial Communication: What, Why, and a Touch of How | Jeff's Skinner Box
I did follow the above instruction but still i am not able to use the uart;
I get the error as “Read failed- : Resource temporarily unavailable”
Can you please help me solve the same.
Regards
Suman
Have you tried running your command or program as root (by putting “sudo” at the start)?
Ya i did but did not help me.
Unfortunately I’m out of ideas, and I won’t have my Pi on hand again for another couple weeks so I can’t try anything out. I’d suggest asking on the Raspberry Pi forums. Let me know if you find a solution so I can add it to my article.
The project I’m working on requires inputting ASCII strings from two separate RS232 serial interfaces (operating at different speeds). My current thinking is to just MUX them into GPIO 15 (RxD) one at a time (with the MUX selector being one of the other GPIO pins). The data strings are repeating, and no transmit from the RPI to either of the other devices is required.
I’m curious – is there a simpler way to interface these two RS232 inputs to the RPI than to have the external MUX logic?
Any and all input is appreciated – Thanks!
I tried commenting out “2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100″
as you said but the my line was not exactly like this, it was TO:2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100″
and was right at the end of the file
i did the sudo reboot ( the first time i ever did this command)
now my pi said “cannot Restart”
now it wont start at all even if I turn it off and on again
After I put the soft float os then installed JDK Java
Compiled all the programs in the PI4j
now I have to start all over again
Pingback: Serial communication between Raspberry Pi and Arduino
I have done the same thing as you said and I also use the C code from the website http://www.raspberry-projects.com/pi/programming-in-c/uart-serial-port/using-the-uart#more-482
However the receive does not for my Pi. the sending is working to be fine.
However when I use screen /dev/ttyAMA0 57600, it pops up the window and close it.
Then I try my code it works. I do not know why, could you help please
Hey there. how do i get back the serial console ?
i followed through your tutorial without realizing what i need is actually to communicate with my computer through the UART…
i followed this guide http://www.savagehomeautomation.com/projects/raspberry-pi-installing-a-rs232-serial-port.html but i could not get any reply from R-Pi… so i doubt thats the problem. what should i do now??
Great stuff, am able to talk to my XBee after disabling both of those… Another site only mentioned disabling the first one, so I battled for awhile.
Pingback: Raspberry PI + Xbee « Michael's Blog
Pingback: The JES / JavaFX Application, Part 3. | Vernon Breet's Blog