1

Can someone tell me the steps what I need to do tu get a serial communication to work?

I have a raspberry pi 3 model b rev 1.1 with Ubuntu Server 20.04. I need to communicate with a sensor via serial communication. I tried a lot of stuff found on the internet but cannot get it to work with a simple loopback setup.

What I tried so far:

  • I connected UART pins (8 and 10)
  • removed "console=/dev/ttyAMA0,115200" from cmdline.txt
  • added "dtoverlay=pi3-disable-bt" to /boot/config.txt
  • also tried "dtoverlay=disable-bt"
  • and "pi3-miniuart-bt"
  • and "enable_uart=1"
  • entered "sudo systemctl disable hciuart", "sudo systemctl stop serial-getty@ttyAMA0.service", "sudo systemctl disable serial-getty@ttyAMA0.service"

then tried with "minicom -D /dev/ttyAMA0", nothing happens, also tried python scripts, writing seems to work but reading just gives a timeout.

Anybody has an idea?

Kind regards

Edit 1:

I tried again with Raspberry Pi OS 64-bit, here are my steps:

  • sudo apt update && sudo apt upgrade -y
  • sudo raspi-config -> serial port -> disable login shell |enable serial port hardware
  • reboot
  • sudo apt install python3-pip
  • pip3 install pyserial
  • add "dtoverlay=disable-bt" to /boot/config.txt to disable bluetooth
  • test with small python script (from here: Rpi Python Serial Test Program)

this is the output:

    Begin serialPortLoopBack() [Remember to connect Tx to Rx!] , ...
    bytes written =  b'AT\r\n'
    bytes read    =  b''
    End   serialPortLoopBack(), ...

It doesn't read anything. Pins 8 and 10 are connected via cable. I changed the cable and both pins have something about 3-3.3V.

lrwxrwxrwx 1 root root 7 Aug 13 14:33 /dev/serial0 -> ttyAMA0
lrwxrwxrwx 1 root root 5 Aug 13 14:33 /dev/serial1 -> ttyS0

the groups where I am in:

 adm dialout cdrom sudo audio video plugdev games users input render netdev gpio i2c spi
2
  • 2
    Why use Ubuntu? What advantage do you expect over the working and optimised and suggested RasPiOS?
    – joan
    Aug 12 at 15:22
  • I want to use ROS2 and for raspian i have to build it or use docker, also on raspian I also didn't get it to work ^^ Aug 12 at 17:13

2 Answers 2

1

OK seems like I did everything right (at least for raspberry pi os), today a colleague gave me his pi to test it and there it worked, seems the pi is broken, so for others:

take these steps:

  • sudo apt update && sudo apt upgrade -y
  • sudo raspi-config -> serial port -> disable login shell |enable serial port hardware
  • reboot
  • sudo apt install python3-pip
  • pip3 install pyserial
  • add "dtoverlay=disable-bt" to /boot/config.txt to disable bluetooth
  • test with small python script (from here: Rpi Python Serial Test Program)
0
0

Ubuntu Server is perfectly adequate (although IMO it offers no advantage over Raspberry Pi OS Lite). It is however designed to be a server, and as such does not include support for peripherals (it doesn't even have WiFi support).

You CAN include these in Ubuntu Server BUT you will NEED to configure it manually (which is simple enough if you determine current configuration and install needed modules). I don't know which (if any) UART is connected to the unused Bluetooth peripheral. One thing is clear - attempting to follow Raspberry Pi OS tutorials is futile.

See How do I make serial work on the Raspberry Pi3 or later may help BUT note the warning about Raspberry Pi OS tutorials.

5
  • I also tried several tutorials for Raspberry PI OS (with the OS installed), they also didn't work... looks like there are also several different instructions, but none of them worked for me :/ Do you think Ubuntu Core (advertised as optimised for IoT) would be a better option? Aug 13 at 10:39
  • what I did on Ubuntu i wrote in my initial post ;) or do you need more information? just tell me what you need Aug 13 at 12:09
  • I will install raspian 64 bit again and try it, I also will write all steps I took here in my post! Aug 13 at 12:12
  • added my workflow Aug 13 at 12:39
  • raspberry pi os 64 bit: raspberrypi.com/news/raspberry-pi-os-64-bit I wrote everything I did in the question, and I tried my own diagnostics if you read the edit, ...measured the pins, edited several config files etc. and the reason I am asking here is because I am out of ideas and I think I understood what I have done, disabled BT because it uses one of the uart-connections, disabled serial console so that it is not blocked by the login shell, what else do you need to know? Aug 13 at 17:49

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.