0

I'm newbie on Raspberry Pi.I have installed serial port using following conmand on raspian l os.

sudo apt-get install python-serial

I'm trying to access serial port communication on Raspberry Pi 3. I have created script using python. When I run the script, I got following error.

Error: serial device '/dev/ttyAMA0' does not exist

But When I used /dev/ttyS0, it's working fine. Why?

My script here.

import serial

port = serial.Serial("/dev/ttyAMA0", baudrate=9600)

while True:
    port.write("Hello world")
    rcv = port.read(10)
    print rcv
rsp
  • 632
  • 1
  • 6
  • 16

1 Answers1

1

You have NOT "installed serial port", although you may have installed python-serial

I don't know why you would get serial device '/dev/ttyAMA0' does not exist, because it SHOULD, although it is connected to Bluetooth, unless you have changed something.

In contrast /dev/ttyS0 SHOULD not exist, because it is disabled by default, again unless you have changed something. (It is possible installing python-serial may have done this.)

The only conclusion is that you have executed some other commands, you are not telling us about.

See How-do-i-make-serial-work-on-the-raspberry-pi3 for an explanation.

PS as outlined in the above you now use /dev/serial0, which should work on all models.

Milliways
  • 59,890
  • 31
  • 101
  • 209