1

I am trying to read data from a LV-MaxSonar-EZ0's TX pin connected to the RX pin on a Raspberry Pi Zero W. The problem I'm running into is that the data I'm getting does not fit what the sensor's datasheet is specifying. According to that I should be receiving data in all ASCII. An ASCII 'R' followed by three ASCII numbers and a carriage return (ASCII 13).

When I fire up minicom with the command minicom -b 9600 -w -o -H -D /dev/serial0 I get the following:

00 00 00 00 00 00 00 00 00 00 00 00 d8 05 c0 06 f6 ac 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 05 c0 06 f6 ac 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 05 c0 06 f6 ac 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 05 c0 06 f6 ac 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 05 c0 06 f6 ac 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 05 c0 06 f6 ac 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 05 c0 06 f6 ac 0f 00 00 00 00 00 00 00 00 00 00 00

The output is uniform, so I guess that's good. However I am not seeing anything that corresponds to ASCII characters. Any tips?

I am running Raspbian Stretch Lite release from 2017-11-29 and connect to it over ssh.

4
  • You could try to capture the output with an oscilloscope if you can get your hands on one. Also, what's the output like without using -H option? Commented Jan 5, 2018 at 10:17
  • Have you disabled the serial console using sudo raspi-config or the GUI preferences dialog. You will get junk data on the serial interface if that isn't disabled.
    – Dougie
    Commented Oct 21, 2019 at 9:29
  • I would start by getting that sensor to work with a USB-to-UART dongle (perhaps on a laptop or on a full-size Pi) before trying the internal UART. This has an added benefit: if you connect something wrong, you'll only burn the dongle, not the pi. Commented Oct 21, 2019 at 12:43
  • Do you have the right baud rate and start/stop/parity bit settings? Are you sure it's 8,N,1?
    – Dougie
    Commented Nov 14, 2020 at 14:40

2 Answers 2

0

If you don't have a scope you sure are in a world of pain.

With a few clicks I've found this on the manufacturer's documentation. Comparing their procedures to yours, what differences can you see?

One difference I see is they read /dev/ttyS0 and /dev/ttyAMA0 whereas you use /dev/serial0. According to rpi documentation, this is primary uart, usually reserved to console. Are you sure about your configuration?

In case nothing above helps, check out your cables. My experience with jumper cables has been very nice so far but be aware bad cables, cold solder joints, excessive length will flip your bits.

2
  • /dev/serial0 is indeed the correct way to refer to the user-accessible UART. And jumper cables can't have "cold solder joints" because they are not soldered. Perhaps you meant to say "poor electrical contact"? Commented Oct 21, 2019 at 12:29
  • @DmitryGrigoryev the link [b]you provided[/b] explains in more detail /dev/serial0 works as the user-accessible UART after configurations have been carried out. Rpi documentation "/dev/serial0, which always refers to the primary UART (if enabled)". I do not know if OP is using jumpers or soldering (you're building upon a supposition I made).
    – MaxDZ8
    Commented Oct 21, 2019 at 16:57
-1

As I know, the output of the LV-MaxSonar-EZ series is analog, however the Raspberry pi is unable to read analog data. So the solution is to use a analogue/digital decoder, I suggest the MCP 3008.

2
  • That sensor does have an analog interface, but I'm pretty certain the OP is using the digital one. Commented Oct 21, 2019 at 12:36
  • @DmitryGrigoryev, The same what I said. The sensor has an analog interface and no digital interface, but the problem is that the Raspberry does not read analog data. So the solution is to use an analog to digital converter (ADC) to convert analog data (the output of the sensor) to digital data that can be interpreted by the Raspberry.
    – singrium
    Commented Oct 21, 2019 at 13:47

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.