mizba
Posts: 7
Joined: Sun Apr 26, 2020 6:25 pm

Read data from serial port with raspberry pi 4 [UBUNTU]

Mon May 04, 2020 11:23 pm

Hi All,

I have installed ubuntu on raspberry pi 4. I want pi to read data from the serial port. I am connecting the Tx, RX, GND pins from serial to Rx, Tx, GND respectively on the raspberry pi. But I am not able to read the data on ttyS0. Is it the right way to do it or do I have to make any other changes? It would be of great help if someone can help me out. Thank you.

HvdW
Posts: 75
Joined: Tue Jun 17, 2014 12:41 pm

Re: Read data from serial port with raspberry pi 4

Tue May 05, 2020 12:06 am

You did follow this guide or similar?

When ubuntu acts similar as raspbian you can check several things.

cat /dev/ttyUSB1
ls -l /dev/ttyUSB* to find your devices
or lsusb to get some info

so in your case
cat /dev/ttyS0
ls -l /dev/ttyS0 to find your devices
Who knows knows
Who doesn't doesn't

mizba
Posts: 7
Joined: Sun Apr 26, 2020 6:25 pm

Re: Read data from serial port with raspberry pi 4

Tue May 05, 2020 12:45 am

when I run "ls -l /dev/ttyS0", this is what I get. Also, I have added username to group tty
crwxrwxrwx 1 root tty 4, 64 May 5 00:30 /dev/ttyS0.
but still, I am unable to read from the serial.

Also, this is what I get when I try to read the active serial ports on pi
$dmesg | grep tty
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 cma=64M bcm2708_fb.fbwidth=0 bcm2708_fb.fbheight=0 bcm2708_fb.fbswap=1 smsc95xx.macaddr=DC:A6:32:68:09:94 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 net.ifnames=0 dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=LABEL=writable rootfstype=ext4 elevator=deadline rootwait fixrtc
[ 0.000531] printk: console [tty1] enabled
[ 3.127417] fe201000.serial: ttyAMA0 at MMIO 0xfe201000 (irq = 19, base_baud = 0) is a PL011 rev2
[ 3.128693] printk: console [ttyS0] disabled
[ 3.128728] fe215040.serial: ttyS0 at MMIO 0x0 (irq = 22, base_baud = 62500000) is a 16550
[ 4.701601] printk: console [ttyS0] enabled

I tried following the same link you sent me, but I couldn't find /boot/cmdline.txt on ubuntu to configure the pi.


HvdW wrote:
Tue May 05, 2020 12:06 am
You did follow this guide or similar?

When ubuntu acts similar to raspbian you can check several things.
couldn't
cat /dev/ttyUSB1
ls -l /dev/ttyUSB* to find your devices
or lsusb to get some info

so in your case
cat /dev/ttyS0
ls -l /dev/ttyS0 to find your devices

HvdW
Posts: 75
Joined: Tue Jun 17, 2014 12:41 pm

Re: Read data from serial port with raspberry pi 4

Wed May 06, 2020 12:07 am

Why do you prefer Ubuntu over raspbian?
It's there a special need?
Raspbian is very well documented and I haven't met any challenge that raspbian cannot cope with.
@home I'm running raspbian on RPI and Ubuntu on AMD64.
Who knows knows
Who doesn't doesn't

Return to “Ubuntu”