---
title: "Comment by Mariusz Białończyk on \"ESP32 Embedded Rust at the HAL: Timer Ultrasonic Distance Measurement\" | Hashnode"
description: "Hi, First of all, much thanks for sharing this! I was planning to use it in my application using pure ESP32 and JSN-SR04T. I found samples/examples but not in R"
url: "https://hashnode.com/posts/esp32-embedded-rust-at-the-hal-timer-ultrasonic-distance-measurement/6465e8f538c36ad305c2c12f/comment/64bf5564453a851c7eb95de9"
---

[Discussion](https://hashnode.com/posts/esp32-embedded-rust-at-the-hal-timer-ultrasonic-distance-measurement/6465e8f538c36ad305c2c12f)

Comment [ESP32 Embedded Rust at the HAL: Timer Ultrasonic Distance Measurement](https://hashnode.com/posts/esp32-embedded-rust-at-the-hal-timer-ultrasonic-distance-measurement/6465e8f538c36ad305c2c12f)

[Mariusz Białończyk](https://hashnode.com/@manio)

[Jul 25, 2023](https://hashnode.com/posts/esp32-embedded-rust-at-the-hal-timer-ultrasonic-distance-measurement/6465e8f538c36ad305c2c12f/comment/64bf5564453a851c7eb95de9)

Hi, First of all, much thanks for sharing this! I was planning to use it in my application using pure ESP32 and JSN-SR04T. I found samples/examples but not in Rust - and suddenly I encounter this site! :) A working implementation will help me a lot, thanks!

I have one doubt/question regarding the wiring: You are powering up the sensor from 5V. This means that the internal logic on the ECHO and TRIGGER pins is also 5V, right?

I saw on several applications the same wiring as yours, but isn't it, that the `echo` should go via some level shifter?, eg like here: https :// camo.githubusercontent.com/aef16862dcee3db4696e1d14a25ed97a27f16ed6ada8edf5de1c8b1d06859323/68747470733a2f2f692e696d6775722e636f6d2f384f4a395451432e706e67

I don't know - maybe the ESP32 pins are capable of handling this (if so - it is probably not preferred during long run?), but I am only asking what is the proper way of doing the wiring...

[Omar Hiari](https://hashnode.com/@omarhiari)

[Jul 25, 2023](https://hashnode.com/posts/esp32-embedded-rust-at-the-hal-timer-ultrasonic-distance-measurement/6465e8f538c36ad305c2c12f/comment/64bf5564453a851c7eb95de9#reply-64bf7a50c6ba3a1b3898617a)

Thank you for reading [Mariusz Białończyk](https://hashnode.com/@manio)! Your doubt is in its place. Since I hooked up the sensor to 5V power then the TTL output levels of the ECHO pin will reach 5V. While pins typically have internal protection, this would still expose them to potential damage. No need to mention, it didn't matter in the simulation. As such, there are two options to address this; either a voltage divider like you indicated to shift the 5V range to a 3.3V range or use a 3.3V compatible device. However, for the latter, I think the accuracy is not as good as the 5V sensors. I adjusted the diagram in Wokwi to include the voltage divider.

[Mariusz Białończyk](https://hashnode.com/@manio)

[Jul 25, 2023](https://hashnode.com/posts/esp32-embedded-rust-at-the-hal-timer-ultrasonic-distance-measurement/6465e8f538c36ad305c2c12f/comment/64bf5564453a851c7eb95de9#reply-64bf81c0453a851c7eb965f4)

[Omar Hiari](https://hashnode.com/@omarhiari) Great! Thank you, Omar :)
