I am getting this error whenever I am trying to run this code:
import serial
from time import sleep
ser = serial.Serial ("/dev/ttyS0", 9600) #Open port with baud rate
while True:
received_data = ser.read() #read serial port
sleep(0.03)
data_left = ser.inWaiting() #check for remaining byte
received_data += ser.read(data_left)
print (received_data) #print received data
ser.write(received_data)
Error: Could not open port /dev/ttyS0: Errno 13: Permission denied: '/dev/ttyS0'
I referred This link for configuring my RPI model 3B+
I also tried This link for this problem but not successful.
My user "pi" is already the member of the dialout
group.
pi@raspberrypi:~ $ groups pi
pi : pi adm tty dialout cdrom sudo audio video plugdev games users input netdev spi i2c gpio
Still, whenever I am trying to run this code, this error pops up. Would be thankful for any help and suggestion.
ls -l /dev/ttyS0
into your question.udevadm info -a -n /dev/ttyS0
command show?