Today I was away on business a lot and did not come to rest until about 11 pm. I would like to use the time now to quickly share with you my python script, which I use to ensure communication between my Raspberry Pi and my arduinos.
To enable communication between computers or a computer and a microprocessor we need a serial interface. This interface transfers data line by line between to computers. For this we need the serial library of python.
The baudrate determines how many characters per second are exchanged between the two systems. This number must be the same between the sender and the receiver to ensure error-free communication. I set the baudrate on the Arduino standard of 9600.
Finally, we let the system read the serial information in a continuous loop.
ser = serial.Serial('/dev/ttyACM0')
ser.baudrate = 9600
ser_bytes = ser.readline()