-1

I've got a device (actually an arduino) that's sending serial data at 2400baud, 8N1. It's connected to my Pi Zero through optocouplers onto pin 8 and 10 (UART TX and UART RX). I've verified i'm seeing 3.3v signals onto the RX pin using a scope, it looks like i'd expect, a square wave representing digital data. For the software I'm using Java and the jSerialComm library to try and receive this data, but i'm having problems.

I'm opening port ttyAMA0 and setting the baud rate, stop bits etc correctly. When i try to read the first byte i get the exception This port appears to have been shutdown or disconnected.

Honestly I'm a bit confused about how to configure the Pi Zero correctly. I've got this at the end of boot.config:

[all]
enable_uart=1
dtoverlay=disable-bt
  1. Is this appropriate? My searching so far seems to indicate that by default the bluetooth hardware uses the UART, and I need to turn it off?

  2. I keep seeing mention of a "second UART" on the Pi, but I only see a single one listed when i enumerate the ports. Is that what i'd expect? Where is the second one? If i run my program as root then i see another port, ttyS0, but that has the same result

EDIT: Optocouplers are to isolate the two devices from each other as they operate at different potentials and I don't want ground loops. They are SFH617A, and they are not inverting the signal:

isolated serial

Stik
  • 99
  • 2

1 Answers1

0

As alluded in the comments, and due to non-disclosure of the opto-couplers used & circuitry details, the most likely suspect is your opto-couplers. Since you have an oscilloscope, you can verify this:

  • on one channel, display the Arduino's serial output;
  • on the second channel, display the output of the optocpupler

If the two channels show a logic inversion, you may replace the optocoupler with a voltage divider - which should resolve your issue. Note that a level-shifter will also restore the correct phasing.

If my assumption re the optocoupler is incorrect, please let us know what part # you are using, and how you have it wired.

Seamus
  • 21,900
  • 3
  • 33
  • 70
  • Thankyou for your input. I did not include details on the circuitry because i believed this to be a software question. I have updated the question. The optocouplers are not inverting the signal. – Stik Nov 21 '22 at 18:03
  • @Stik: Thanks for the clarification; FYI, there are lots of grounded emitter optocouplers around. For purposes of eliminating possibilities, have you tested the serial stream with "standard" serial port software?... or another device? – Seamus Nov 22 '22 at 06:07