0

Please help me find problem in this code:

import serial
ser=serial.Serial("/dev/ttyACM0",9600)
ser.baudrate=9600
ser1=serial.Serial("/dev/ttyUSB0",9600)
ser1.baudrate=9600
ser2=serial.Serial("/dev/ttyUSB1",9600)
ser2.baudrate=9600

while True: 

 read_ser=ser.readline()
 read_ser1=ser1.readline()
 read_ser1=ser2.readline()
 print(read_ser)
 print(read_ser1)
 print(read_ser2)

I expect that it will show me message from connected Arduino. Arduino send it when I apply card to RFID reader. But, it send only from first ser

Update:

I connect 3 Arduino Uno to Raspberry Pi 3 via USB. Each Arduino connect with RFID-RC522.

ls -l /dev/ttyACM*  
crw-rw---- 1 root dialout 166, 0 Oct 18 19:17 /dev/ttyACM0

But Arduinos connect to /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyACM0

0
0

This code works as I expected

import serial
ser=serial.Serial("/dev/ttyACM0",9600,timeout=1)
ser.baudrate=9600
ser1=serial.Serial("/dev/ttyUSB0",9600,timeout=1)
ser1.baudrate=9600
ser2=serial.Serial("/dev/ttyUSB1",9600,timeout=1)
ser2.baudrate=9600
while True: # Run forever

 read_ser=ser.readline()
 if (read_ser != ""):
        print(read_ser)
 read_ser1=ser1.readline()
 if (read_ser1 != ""):
         print(read_ser1)
 read_ser2=ser2.readline()
 if (read_ser2 != ""):
         print(read_ser2)

Thank you @jasonharper

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.