Close

Enabling Serial on a RPi3 via the GPIO pins

A project log for K-9

Raspberry Pi powered K-9 GUV with a NES controller style remote

Andrew BillsAndrew Bills 03/29/2016 at 06:210 Comments

So there are some updates for this but the short version is the uart of the RPi3 doesnt work exactly the same as the RPi2. For my project I dont need BTE (but I like having wireless) and a lot of solutions for this problem involve changing clock speeds which id rather not.

Fortunately the following is a working solution to get the serial ports working from the GPIO on the RPi3. I thought id include the steps because I had some trouble getting to this point and maybe someone else will benefit (though I did leave the solution on reddit too).

1. For the RPi3, install Jessie build from raspberrypi.org version +2016-03-16 on an appropriate speed & size SD Card (Class 10)

2. Power up the RPi with the SD in and probably a mouse and kb so you can setup the wifi and locale settings. I did that and checked what the ip address was (ifconfig) at the cmd line so I could use SSH for the rest of these steps. Up to you.

3. Reboot with the network settings if you need to, I did it because I set it to boot to CLI

4. Connect to the RPi and do a 'sudo raspi-config' to expand the file system and reboot (you can change other stuff if you want).

5. Reboot. Else the FS wont expand and you wont have room for the following

6. Run 'sudo apt-get update'

7. Run 'sudo apt-get upgrade'

8. Run 'sudo apt-get dist-upgrade'

9. Run 'sudo rpi-update'

10. As I dont need BTE you can enable an overlay that will mean the RPi3 will work like the 2.... do a 'sudo nano /boot/config.txt' then at the bottom of the file add 'dtoverlay=pi3-disable-bt'

11. Do a 'sudo systemctl disable hciuart' for good measure

12. Reboot

At this point serial should work, if not check the tx/rx pins are connected correctly (and not accidentally reversed as I did that once).

If you want you can install either 'screen' or 'minicom' to test, ive been using 'sudo screen /dev/ttyAMA0 115200' as the speed I have set on the xbee connected via serial on a sparkfun xbee explorer breakout. What I need to figure out now is how to make it run reliably as connected to a xbee on a usb breakout on my PC using XCTU I dont lose any data but when testing via the RPi after 30+ seconds the data starts to drop like the buffer is full or struggling to keep up (I wouldnt of thought it would). Currently the xbee on the arduino controller is sending out current state every 100ms (I upped it from 50ms) but it is still a bit off.

I will play around with the settings on the xbee or the RPi with screen to try and figure this out. Currently I enabled both RTS & CTS on the xbee in K9 and I no longer receive data... so I think it's about flow control. Hopefully I can solve this without having to use more pins.

Anyway, just in case anyone googling has problems with the serial to get to this point too.

Discussions