I first connected two raspberry pi, one is Model 4B(transmitter) and another Model 3 B+(receiver) via Uart. Done all uart enable steps (sudo raspi-config>Interfacing Options>Serial>Serial Interface is enabled). Connected TXD-RXD, RXD-TXD,GND-GND of transmitter and receiver pi respectively. Below is my code
Code in Transmitter Raspberry Pi
import time import serial ser = serial.Serial(port='/dev/serial0',baudrate = 9600, parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS,timeout=1) while 1: ser.write('Hello \n'.encode())
Code in Receiver Raspberry Pi
import time import serial ser=serial.Serial(port='/dev/serial0',baudrate=9600, parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS,timeout=1) while 1: x=ser.readline().decode()[:-2] print(x)
Output at receiver side:
Hello Hello Hello Hello Hello Hello...
Everything Works fine till here. But on trying same code with model of transmitter raspberry pi changed (from 4B to 3 B+) and receiver side pi same, output is not as expected. Looks like something is being printed but is blank. P.S. Done all uart enabling steps when pi was changed. Not getting Why I am not getting output when uart enbaling steps are done same way, code is the same.