2

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 [email protected]", "sudo systemctl disable [email protected]"

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
asked Aug 12, 2022 at 13:40
2
  • 2
    Why use Ubuntu? What advantage do you expect over the working and optimised and suggested RasPiOS? Commented Aug 12, 2022 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 ^^ Commented Aug 12, 2022 at 17:13

3 Answers 3

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)
answered Aug 13, 2022 at 18:06
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.

answered Aug 13, 2022 at 0:13
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? Commented Aug 13, 2022 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 Commented Aug 13, 2022 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! Commented Aug 13, 2022 at 12:12
  • added my workflow Commented Aug 13, 2022 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? Commented Aug 13, 2022 at 17:49
0

I was facing this issue with Ubuntu 22.04 LTS on my Raspberry Pi 3 for the past two days. Eventually, I realized that I had edited the wrong config.txt file. Instead of modifying the one in /boot/, I should have made changes to the config.txt located in /boot/firmware/. Every solution I and you guys found was for Raspberry Pi OS, sadly. I hope this information helps others who might encounter a similar problem!

answered Mar 5, 2024 at 16:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.