I'm testing serial communication with Python
pyserial module. I try to communicate some strings between two Raspberry Pi's ...
I tested transmitter and receiver code at same device connecting it's TXD to the RXD pins. It worked as expected...
import serial from time import sleep port = serial.Serial("/dev/ttyAMA0", baudrate=115200, timeout=None) while 1: pin = raw_input("Activate pin: ").strip("\r\n") port.write(pin) sleep(0.1)
import serial from time import sleep port = serial.Serial("/dev/ttyAMA0", baudrate=115200, timeout=None) while 1: try: data_chunk = port.read() time.sleep(0.1) remaining_bytes = port.inWaiting() data_chunk += port.read(remaining_bytes) print data_chunk except Exception, e: print str(e) pass
Once connecting transmitter device's TXD pin to receiver device's RXD pin, it will detect the transmission but it will only print garbage. How could it work if connected to own pins and not with other Raspberry!?
Just in case:
- I did all proper setups to use UART at each device
- Transmitter it's a Raspberry B+ and receiver is a B revision 2.