been fiddling with this for hours and get understand what is going on. I've been having problems with the Pi serial Uart communication.
I've tried this on 2 Raspberry Pi 2s, First one Jessie version 4.4.11 and second one Jessie version 4.4.21
I ran an Arduino code:
void setup() {
Serial.begin(9600);
}
void loop() {
int incomingByte;
Serial.println(Serial.available());
if(Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// echo
Serial.write(incomingByte);
}
}
And ran it with the minicom -b 9600 -o -D /dev/ttyAMA0 , but nothing appears on the screen when I type anything on the pi. I also realised the Serial.available() is always false. (No matter which serial pins I placed, Serial1,serial2)
Next, I decided to test the Pi. I connected the TXD pin and the RXD pin to each other and ran this program:
import serial
ser = serial.Serial(‘/dev/ttyAMA0’, 9600, timeout=1)
ser.write(“testing”)
try:
while 1:
response = ser.readline()
print response
except KeyboardInterrupt:
ser.close()
I was expecting the "testing" to be printed out, however what it prints is just new blank line every loop, without the "testing" at all. Seems to me that the Pi is having some problems, but strangely, both PIs are having the same output and problems with minicom.
I was wondering if I am missing out any settings, here is what I have done: -Made sure there is no ttyAMA0 in /boot/cmdline.txt
-Disabled getty (systemctl disable [email protected])
-Did these steps as found in another forum:
sudo raspi-config -> Advanced Options -> Serial -> No
Add enable_uart=1 to \boot\config.txt
Reboot
-Made sure the mode of TxD and RxD is on ALT0
Any help would be appreciated.