Comments on: MicroPython: HC-SR04 Ultrasonic Sensor with ESP32 and ESP8266 (Measure distance) https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Thu, 17 Oct 2024 13:15:56 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Sara Santos https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-973065 Thu, 17 Oct 2024 13:15:56 +0000 https://randomnerdtutorials.com/?p=104589#comment-973065 In reply to Alexandre.

Hi.
There’s probably an issue with the wiring.
Regards,
Sara

]]>
By: Alexandre https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-973036 Thu, 17 Oct 2024 11:14:58 +0000 https://randomnerdtutorials.com/?p=104589#comment-973036 It did not work for me. I made no changes to the library or provided code. Yet I keep getting the that distance is -0.03436426 cm

any tips on fixing it?

]]>
By: Sara Santos https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-878489 Mon, 18 Dec 2023 10:52:59 +0000 https://randomnerdtutorials.com/?p=104589#comment-878489 In reply to kevin holm.

Hi.
Thanks for your comment.
Can you be a little more specific?
I don’t see the typo? Can you guide me?
Regards,
Sara

]]>
By: kevin holm https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-878473 Mon, 18 Dec 2023 08:32:58 +0000 https://randomnerdtutorials.com/?p=104589#comment-878473 Hi thanks for a great article. It seems that the input and output for trigger and echo has been reversed in the table at the “HC-SR04 Ultrasonic Sensor Pinout” section.

Best regards,

Kevin

]]>
By: Sara Santos https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-802932 Tue, 13 Dec 2022 20:15:49 +0000 https://randomnerdtutorials.com/?p=104589#comment-802932 In reply to Collins Abraham.

Hi.
Yes. You can build a web server that displays the results.
Then, you just need to access the IP address to get access to those results using any browser.
Learn how to build a web server: https://randomnerdtutorials.com/micropython-esp32-esp8266-dht11-dht22-web-server/
Instead of the DHT readings, you should use the readings from the ultrasonic sensor.
Regards,
Sara

]]>
By: Collins Abraham https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-802124 Sun, 11 Dec 2022 06:51:05 +0000 https://randomnerdtutorials.com/?p=104589#comment-802124 ]]> In reply to Intense.

Wow cool, I’m looking for something similar. Did you wirelessly interface the Esp32 with the IDE on the computer? If you did please how did you go about it? 🙏

]]>
By: Collins Abraham https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-802123 Sun, 11 Dec 2022 06:48:54 +0000 https://randomnerdtutorials.com/?p=104589#comment-802123 In reply to Sara Santos.

Hello Sara,
thanks a lot for the tutorial, it’s exactly what I’ve been looking for. If I understand it correctly, after the flashing and uploading to the esp32 board, the main code is run on the Esp32, the results are only printed in the Arduino IDE right? So it means we can use those results printed in the IDE to perform other calculations right?

Now the main question, please is it possible to implement the same setup as above but making the Esp32 to wirelessly send those results to the IDE?
So that the Esp32 with the sensor can be made independent and deployed where necessary, but without need for a physical connection to a computer. Please what do you think?

]]>
By: Harri https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-787204 Fri, 30 Sep 2022 18:10:14 +0000 https://randomnerdtutorials.com/?p=104589#comment-787204 Hi,
I had the same question about 5V on my mind.
I think I try to drive HC-SR04 with 3.3V or use some cheap logig level converter.

]]>
By: Madhav https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-736841 Sat, 09 Apr 2022 06:27:10 +0000 https://randomnerdtutorials.com/?p=104589#comment-736841 In reply to Sara Santos.

Hi,
can we code for water flow sensor Yf-S201 in micropython . please help us

]]>
By: Carl Hage https://randomnerdtutorials.com/micropython-hc-sr04-ultrasonic-esp32-esp8266/#comment-729946 Fri, 04 Mar 2022 04:11:04 +0000 https://randomnerdtutorials.com/?p=104589#comment-729946 In reply to Michael Rogulla.

The ESP data sheets don’t specify maximum injection current or which pins are 5V tolerant. Depending on which ESP32 any 5V tolerance could be different. But we could assume maximum injection of .5ma from other microcontroller that does have this in the data sheet. If you connect the echo output to the GPIO input via a 4.7K (or 10K) resistor, then if the GPIO is not 5V tolerant, then the resistor should limit the current from 2V overvoltage to a safe level. If you are using some other processor (e.g. ESP32C3) or other GPIO, I would insert the resistor.

You can also use 2 resistors to make a voltage divider to reduce the 5V to 3.3, but it’s not really necessary, as a 4.7K-10K resistor will work on 5V tolerant or not. But this still violates what is in the data sheet since it doesn’t specify max injection current.

Apparently, Rui and Sara chose a 5V tolerant GPIO18, maybe by luck, since she says it worked fine. You could replicate the test in the link above in my prior post to check for 5V tolerant pins, e.g. connect an input to a variable power supply via 10K resistor, then measuring the voltage at the input, gradually increase the power supply until the input voltage stops rising. (Fiwidev measured 6.4V on 5V tolerant pins.)

]]>