amarchionne97
Posts: 1
Joined: Mon Jul 23, 2018 3:49 pm

RPi 3 B+ Connecting an ultrasonic sensor with serial?

Mon Jul 23, 2018 4:12 pm

Hi,

I'm trying to have my pi read an ultrasonic sensor (Maxbotix HRLV-EZ4) using the serial interface, but I can't seem to get it to work. Here's the wiring diagram:
Image
Note: Pin 10 is the RXD pin.

Here is the module and the script that utilizes the module I'm using. Disclaimer: I did not write either of these. The only thing I have done with it is test out different inputs for the (portName) input, as I was (and am) not sure what to put there. Consider it unedited in any way.
https://www.maxbotix.com/wp-content/upl ... raspPi.txt

The error is keep getting, 'Expected serial data not received', is defined at the end of the first script. The sensor uses a TTL protocol, or an optional RS232 protocol (but I'll have to break out the solder). 8-bit, 9600 baud. I have already activated the ttyAMA0 and ttyS0 UARTS by altering the /boot/config.txt file: enabling the UART, and disabling bluetooth to be able to use ttyAMA0.

If anyone can help walk me through this, it would be greatly appreciated. If I have left out any critical information, please let me know.

klricks
Posts: 6437
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: RPi 3 B+ Connecting an ultrasonic sensor with serial?

Wed Jul 25, 2018 12:13 am

This data sheet says RS232 is default and TTL is optional: https://www.maxbotix.com/documents/HRLV ... asheet.pdf

The RPi uses 3V3 TTL only and not 5V and not RS232 without appropriate adapters.
This means that your sensor must be set to TTL and the VCC power pin on the sensor must be connected to 3V3 and not 5V.
There must be ground wired between RPi and sensor.

To test your config you can do a loopback test. Connect pin 10 to pin 8 with a wire or 'berg' jumper.
Use a serial terminal program such as minicom. Typed characters should be echoed to the screen.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

paceaux
Posts: 1
Joined: Mon Jan 21, 2019 4:43 am

Re: RPi 3 B+ Connecting an ultrasonic sensor with serial?

Mon Jan 21, 2019 4:58 am

I've got the same hardware and I still can't get it working

It's the LV-MaxSonar-EZ4 Ultrasonic Range Finder.

I'm using 3v instead of 5.

Wiring the sensor
  • Sensor GND => pin 14 (ground)
    Sensor +5 => pin 1 (3.3v)
    Sensor TX => pin 10 (GPIO 15)
I've tried testing this sucker with the code they've given https://www.maxbotix.com/wp-content/upl ... raspPi.txt. I've tested that code using ttyAMA0 and ttyS0.

I have also set up uart as recommended.

I'm brand new to Raspberry Pi, this is my first experiment with a sensor; I'm already thinking I'm in way over my head. I could use some help

Return to “Beginners”