I'm trying to set up a Maxbotix Ultrasonic Rangefinder (LV-EZ0) with a Raspberry Pi 3 B+.

I've tried all the tips I could find:


disable serial interfacing for shell, but keep it on for port hardware


I made sure that those lines were there or I added them myself:

dtoverlay=disable-bt (also tried dtoverlay=pi3-miniuart-bt)

# services
Stopped / Disabled bluetooth, serial-getty@ttyAMA0

I also tried to: sudo cat /dev/serial0 > catReading.txtin one ssh window and sudo echo -en "test\n" > /dev/serial0in another one, but catReading.txt stays empty because I get a "Permission denied" to write anything to serial0.

Command outputs

sudo dmesg | grep tty => [ 0.000901] console [tty1] enabled [ 1.023127] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 81, base_baud = 0) is a PL011 rev2

ls -l /dev/* =>

lrwxrwxrwx  1 root root           7 Jan 31 16:57 serial0 -> ttyAMA0
lrwxrwxrwx  1 root root           5 Jan 31 16:57 serial1 -> ttyS0

cat /boot/cmdline.txt =>
console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait


  • Sensor VCC to 5V pin on raspi
  • Sensor GND to GND on raspi
  • Sensor TX to TX on raspi (I tried to plug it to Raspi's RX as well, because I simply don't know what I'm doing here 😁. When I did that, I can read a few bytes, none of them starting with 'R' once decoded to utf-8, so probably not data sent by the sensor).

I looked up to see if there was any way to read a PWM input on the Raspi 3, but it's apparently not possible unless I add extra hardware.

Any suggestion from there?

  • \$\begingroup\$ Welcome to EE.SE, garys. I tried to fix the markdown in your post as best I could. Can you review? There's a help button on the editor toolbar that gives most of the common syntax. \$\endgroup\$
    – Transistor
    Commented Jan 31, 2020 at 22:30
  • \$\begingroup\$ Thanks for fixing the markdown it’s all good nothing to add. \$\endgroup\$
    – garys
    Commented Feb 2, 2020 at 5:05

1 Answer 1


First of all, sensor TX pin is transmit output so it must be connected to RasPi RX pin which is a receive input - Connecting TX to TX is usually wrong. But in this case is not that simple, so don't do that just yet.

The sensor TX output voltage levels are same as it's supply voltage, so it uses 5V logic levels. RasPi RX pin does not tolerate 5V logic levels, it must use 3.3V logic levels, so some conversion is needed. Fortunately the output might be so weak that the RasPi RX pin can tolerate it, but this is definitely not good to drive 5V signals to things expecting 3.3V signals.

Finally, the sensor TX output is actually directly compatible with RS232 voltage level receivers, which means it must be inverted before connecting it to a UART without RS232 voltage receiver such as RasPi. This is the reason you don't receive correct characters.

Solutions are to connect a USB-RS232 adapter to RasPi, or add a voltage-level converting inverter in between. For example a 74LVC04 is an inverter, it can be used with 3.3V supply voltage to drive RasPi RX input with 3.3V logic level, and it can tolerate 5V logic levels on inputs.

However, those are not the only solutions. The sensor can be used with 3.3V supply voltage, so you can use the sensor and inverter both at 3.3V, so any inverter that runs with 3.3V can be used, such as 74HC04. You could also get a RS232 to 3.3V TTL/CMOS level receiver board that runs at 3.3V to do the inversion and level conversion.

  • \$\begingroup\$ Very clear explanation about the RS232 voltage, I hadn’t realized the sensor was outputting an AC signal through TX, not to mention the logic difference 3V vs 5V. Thanks! \$\endgroup\$
    – garys
    Commented Feb 2, 2020 at 5:17
  • \$\begingroup\$ @garys It does not output AC. Inverting means swapping 5V level to 0V, and 0V level to 5V, to make the sensor output directly compatible with standard RS232 receivers (which will invert the signal). \$\endgroup\$
    – Justme
    Commented Feb 2, 2020 at 8:23
  • \$\begingroup\$ Ok, another misunderstanding on my end, thanks again for the clarification. \$\endgroup\$
    – garys
    Commented Feb 2, 2020 at 18:46

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.