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'
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.