0

I have a sensor which spits out information via serial and I am trying to receive that input on my Raspberry Pi 3 via the serial RX (BCM pin 15).

I'm using the wiringPi library in a C++ program to use the serial interface. I'm fairly certain that my code that reads from the serial device is correct because I was able to use USB serial devices fine.

I am trying to use /dev/ttyAMA0 in the openSerial function, which can be opened successfully. I just can't seem to get any data.

Basically:

  • I'm using the BCM pin numbers in wiringPi (wiringPiSetupGpio)
  • I have uart enabled in raspi-config
  • I have confirmed that I'm getting output from my sensor
  • I've double checked my wiring
  • I know my code works with USB serial devices

I know it could be something as simple as one wrong connection, but I've checked thoroughly and had some fresh sets of eyes look at it too, so I feel like there might be something else that I'm missing.

Not sure if related:

When I have the RX pin connected to my sensor for a few minutes, the Pi will eventually freeze. I'm not sure exactly what happens when it freezes. My ssh connection will freeze, but I can still see the ethernet light blink when I type.

I was thinking this might be caused by a short or overvoltage, but the behavior seems quite odd.

Edit: I have everything working now. I removed the console and kbdg sections from my cmdline.txt, and added dtoverlay=pi3-disable-bt to my config.txt. I have narrowed the freezing issue to the ethernet port.

  • I experienced a similar problem with freezing when I had a sensor sending data on the serial link and had forgotten to disable serial console login. The system became incredibly busy attempting and rejecting console logins on the serial link. – joan Feb 2 '18 at 8:56
  • That makes sense, I'll make sure that's disabled. If that's the case, then the freezing might be due to the huge amount of data going into /dev/ttyAMA0, which should be the bluetooth module. – sealj553 Feb 2 '18 at 16:32
0

Do NOT use /dev/ttyAMA0 which is connected to Bluetooth (by default).

Use /dev/serial0 which is connected to default serial port, even if you take any of the measures to modify behaviour.

  • I had been referencing some older guides which specified using /dev/ttyAMA0. The other reason for using that was because the only other device that I could see was /dev/ttyS0. This question clears up my understanding. It looks like the most straightforward way is just to disable bluetooth. – sealj553 Feb 2 '18 at 6:35
  • @sealj553 There is absolutely NO reason to use anything other than /dev/serial? in a recent OS. Your question is lacking any real information. I usually assume people are running the latest Raspbian (or penultimate after a new release) without undisclosed changes. /dev/serial* has existed in normal distributions and are links setup by udev on boot. See How-do-i-make-serial-work-on-the-raspberry-pi3 – Milliways Feb 2 '18 at 6:40
  • Understood. I am running a jessie image from October by the way, I'll be upgrading to stretch anyways. Last time I was using GPIO serial, I had been using a RPi 1B, so I hadn't known about the change to /dev/serial. Yeah, that's the same link I referenced. – sealj553 Feb 2 '18 at 7:09

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.