Enable serial port ttyAMA0

How do I enable the ttyAMA0 serial port on Raspberrypi?

I searched for this online and found tons of recommendations to edit the /boot/config.txt file. However this file does not exist on my system. This file is normally found on raspbian and my OS here seems to be Alpine.

cat /etc/os-release
NAME=“Alpine Linux”

Has HA changed to Alpine recently explaining the numerous documentation that does not match up anymore?

How can I enable ttyAMA0? I have an arduino connected to this and managed to setup the yaml and that. The port does not seem to work.

Any help appreciated.

1 Like

Are you using HassOS?
Did it work before (and before what)?
What are you trying to achieve?

Hi Chris,
You will probably be able to tell me which OS I have. I just went on the HA website → installation → raspberrypi and followed the instructions. (rpi4 64bit)

I have an arduino connected to ttyAMA0 and sending data streams of sensors in space separated values (text obviously):
X1 X2 X3

I have setup my yaml file as indicated on this page below.

That works well to see the the sensor in the overview pane but no data are received. (the arduino works well. no problem here as it does work using another OS).

Any documentation I find on the web does not match with what I see here. Looks like everything is out of date somehow. They all mention config.txt and cmdline.txt but that does not exist on here.

I am using the Terminal & SSH add-on to enter my commands. (I am still trying to figure out how to ssh natively to the box. Somehow wondering if the add-on is giving me a shell with its own specific environment? How do you ssh to it natively? (i.e. no web interface just ssh command from my ubuntu computer). Maybe a question for another thread.

First thing first I need to get the serial port working. ANy help?

yaml file below in case this is relevant. ( I doubt).

sensor:
  - platform: serial
    name: "RPICT"
    serial_port: /dev/ttyAMA0
    baudrate: 38400

  - platform: template
    sensors:
      arduino_t:
        friendly_name: Temperature
        unit_of_measurement: "C"
        value_template: "{{ states('sensor.serial_sensor').split(' ')[1] | float }}"

Shutdown your pi. Take the SD card out. Insert in PC. Modify config.txt. Reinsert in Pi.

Config.txt is definitely there.

Thank you Francis. That did the trick. I can read the ttyAMA0 now. Still having to tune the yaml somehow.

I took the opportunity to include a ssh file inside the boot partition in the hope to have native ssh working but that failed.

Not a fan of these web terminals. Just give us a proper ssh access!

What modifications did you make to config.txt?

What did you change to make this work? I’m trying to use /dev/ttyS0

I still can’t get the UART working on the Raspberry Pi 5, running Home Assistant OS.

I can at least get the /dev/ttyAMA0 node to show up by following the Enabling Serial Console | Adafruit's Raspberry Pi Lesson 5. Using a Console Cable | Adafruit Learning System. Specifically, the dtparam=uart0 line was ultimately what make the AMA0 node appear/stay during runtime.

You can edit the config.txt by using the HDMI + keyboard, typing login and editing the /mnt/boot/config.txt file. That being said, this AMA0 doesn’t seem like the correct uart. IIRC, I though the default uart for raspberry pi was /dev/ttyS0 with an extra node/link from /dev/serial0 or something like that.

It is worth pointing out that the kernel does talk about registering ttyS0 and serial0 during boot time (dmesg), but then I can’t find these nodes anywhere during runtime.