Trying to send a message from my Pi to the Arduino via serial communication and I'm receiving this error despite having installed pyserial ImportError: cannot import name 'Serial' from 'serial' (/home/pi/serial.py)
When I change my code to import serial
instead of from serial import Serial
, the same error presents.
Wondering if anyone else has had this issue and you resolved it.
from serial import Serial
import time
if __name__ == '__main__':
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)
ser.flush()
while True:
ser.write(b"Hello from Raspberry Pi!\n")
line = ser.readline().decode('utf-8').rstrip()
print(line)
time.sleep(1)