Serial port on Raspberry Pi 3


#1

I’d like to use the serial port on a Raspberry Pi 3. I understand that to make this work reliably I will need to make some changes to the device tree as described here: http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two i.e. set dtoverlay=pi3-miniuart-bt

Is this possible to achieve with the resin.io Device OS?


Serial port issues on Raspberry Pi 3
#2

Hi @tjc42,

What serial are you trying to do on the serial? There are two solutions. One would be the one you found and that is currently not supported by resin as we don’t provide yet this dtb (but we will do soon). Another option would be to set core_freq=250 in config.txt (see https://resin.io/blog/updating-config-txt-remotely/ on how to do it). As well you would need to change (manually) the cmdline.txt and make sure that console=tty1 so kernel will not use the serial port. And this should set you up.

Regards,
Andrei


#3

Thanks that’s great. Look forward to the device tree support on Resin, but will try the core_freq setting for now.


#4

Hi @tjc42, @andrei,

I’m having the same issue.
I try to attach a module from www.openenergymonitor.org onto the Raspberry Pi 3, but I’m not able to receive the right data via /dev/ttyAMA0.
(There’s also a thread at their site, but they were able to solve it with a kernel overlay and systemctl disable hciuart ( https://openenergymonitor.org/emon/node/12311 ).

I’ve tried a few settings already:
dtoverlay=pi3-diable-bt or:
dtoverlay=pi3-miniuart-bt-overlay
as well as:
core_freq=250
enable_uart=1
etc. etc. in all different combinations

But I’m not able to receive the data I should be able to receive.

I’m trying with:
$ minicom -b 38400 -o -D /dev/ttyAMA0

I receive data, but not what I’d like to receive. I’ve no idea what I’m receiving; it looks like this:

? 51 195 95 173 5 145 193 203 89 200 251 194 177 167 23 235 150 159 164 33 141 (-95)
? 158 226 226 148 45 31 246 251 99 148 47 236 78 50 45 140 98 9 216 190 117 (-97)

but I should look different (something like that):
OK 11 0 1 0 1 210 4 0 0 72 1 0 0 97 3 0 0 74 16 0 0 8 0 20 0 0 0 0 (-84)
OK 11 0 1 0 1 210 4 0 0 73 1 0 0 122 3 0 0 60 8 0 0 0 0 0 0 8 0 10 0 0 0 0 (-81)

(that’s what I receive on my Raspberry Pi 2).

Maybe the “wrong” data is still coming from some bluetooth traffic??

Do you have any hints for me? I’m not a specialist in this hardware stuff, I need to concentrate on the software that runs on top, so, sorry if this question seems stupid or so :wink:

Thanks a lot,
best regards
Fritz


#5

Hi @fritz

I got serial on the Raspberry Pi 3 working by using the following in /boot/config.txt:
enable_uart=1
dtoverlay=pi3-disable-bt

The device I’m using is 115200 baud, so I can read it using:
minicom -D /dev/serial0 -b115200

Not sure if /dev/ttyAMA0 is the same as /dev/serial0, so you might want to try changing that as /dev/serial0 definitely works for me.

Toby.


#6

This looks like an issue with the default baudrate of the UART port. Which is, if nobody configured otherwise, 9600. You can use stty to change the baudrate as needed. This used to be 115200 on old resin OSs when we were having console argument in the kernel cmdline.


#7

Hi Toby, hi Andrei,

thanks for your replies.

Unfortunately, both options did not work as expected.

root@raspberrypi3-b4f1bd8:/# stty
speed 38400 baud; line = 0;
-brkint -imaxbel

so, stty shows the right baudrate already

and /dev/serial0 is not existing (just /dev/ttyAMA0 or /dev/ttyS0 if pi3-disable-bt is used)

Any more ideas?

Thanks!
Fritz


#8

Hi,
we got it working.
The issue was that the RFM module was not set to the right node_id. After fixing that, messages could be retrieved again

BTW: we’ve just set core_freq=250 and enable_uart=1

Thanks!


#9

This is doing the trick for us:

Set dtoverlay=pi3-miniuart-bt-overlay as variable in the Device Configuration