1

I am trying to configure the UART on the Pi 4. I have entered enable_uart=1 into /boot/config.txt and I have

sudo systemctl disable [email protected]

and removed console=serial0,115200 from /boot/cmdline.txt.

Here is the C code I got fromwiringPi:

include <stdio.h>
#include <string.h>
#include <errno.h>

#include <wiringPi.h>
#include <wiringSerial.h>

int main ()
{
  int serial_port ;
  char dat;
  if ((serial_port = serialOpen ("/dev/ttyAMA0", 115200)) < 0)  /* open serial port */
  {
    fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
    return 1 ;
  }

  if (wiringPiSetup () == -1)   /* initializes wiringPi setup */
  {
    fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ;
    return 1 ;
  }

  while(1){

        if(serialDataAvail (serial_port) )
   {
                //dat = serialGetchar (serial_port); /* receive character serially*/
                //printf ("%c", dat) ;
                //fflush (stdout) ;
                serialPutchar(serial_port, '@');  /* transmit character serially on port */
                  }
        }

}

What did I not do?

1 Answer 1

1

Don't bother with trying to manually configure UART - use the menu in raspi-config which gets it right. You have disable the serial port by trying to do it manually (probobly by following some obsolete instructions).

/dev/ttyAMA0 is connected to Bluetooth - use dev/serial0

See How do I make serial work on the Raspberry Pi3 , Pi3B+, PiZeroW

3
  • I did so. No Joy. this is what my /boot/config.txt looks like,
    – Tony
    Commented Oct 9, 2019 at 13:27
  • #dtoverlay=vc4-fkms-v3d dtoverlay=pi3-miniuart-bt enable_uart=1
    – Tony
    Commented Oct 9, 2019 at 13:27
  • This type of advice is unhelpful for anyone not running raspbian.
    – ave
    Commented Apr 18 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.