0

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 serial-getty@ttyAMA0.service)

-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.

  • If you happen to have a USB - TTL adapter, you could try to send out data via the USB and receive it via the GPIO pin RX (and/or vice versa) and see if the problem persists. if this experiment is successful, it might give a clue where the problem lies. – Shreyas Murali Oct 19 '16 at 18:33
1

Check the serial port settings with stty -F /dev/ttyAMA0. You might try piscope to check for activity on GPIO 14/15.

0

Apparently it was a faulty wire. Can't believe I didn't suspect that all these hours. Sorry for the time and thank you!!

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.