-1

I'm using and ESP8266 with HC-SR04 ultrasonic sensor. The sensor requires 5v input and will also output to the GPIO pins at 5V.

ESP8266 has a strong recommendation to use 3.3V into the GPIO pins. I've found some setups online with people using voltage dividers to bring the ECHO pin voltage down.

Example on a PI: https://tutorials-raspberrypi.com/raspberry-pi-ultrasonic-sensor-hc-sr04/

I'm using a basic multimeter that i've found to be pretty accurate. When I put the BLACK cord on the ECHO and RED on the GROUND (of sensor pins), I get variable voltage readings. I'm trying to ensure a 3.3V coming from the ECHO into my ESP. Questions:

  1. Am I putting the black and red cords on the appropriate areas?
  2. If yes to question 1, then why am i get such a variable of readings?
  3. How can I test to ensure only 3.3V coming out of ECHO?
1

As Majenko already wrote, the black cord goes always to ground, so you have the leads backwards (though this just means, that your multimeter will report a negative voltage, if it is able to do so).

But besides that you cannot easily measure the echo pulse with a multimeter. A multimeter is build to measure either a DC voltage or a constant AC voltage. It is not build to measure the peak signal of a pulsed line. Some good multimeters may be able to do that, but it most of them (an definitely the basic ones) cannot do this. They are measuring the voltage over a relatively long period of time (longer than an echo pulse) with multiple measurements (to average out the noise). Also you cannot control, when exactly each measurement is taking place. So depending on the exact timing, the multimeter might have multiple pulses in the measurement (reading 5V there) or even missing pulses completely. That's the meaning of the Nyquist frequency, which states, that the measurement frequency must be higher than double of the signal frequency, or you will not be able to measure the signal correctly.

The echo pulse - if you receive one - will be rather short. With the maximum distance of most ultrasonic sensor boards of 3m, you will get a maximum pulse length of

3m / (300 m/s) = 0,01s = 10ms

You won't be able to correctly read that pulse with a multimeter. You would need an oscilloscope for that.

What to do now? If you want to make sure, that the used voltage divider divides 5V input to 3.3V output, you can connect the input to the 5V pin (but disconnect the echo pin first). Then measure the voltage at the output (which is now HIGH all the time, not just for the time of a pulse). If it's 3.3V, you can be sure, that the divider works correctly. As the ultrasonic sensor is provided with 5V, it won't output more than that. So you can be sure, that the ESP will only see 3.3V.

| improve this answer | |
1

You have your leads backwards. But that doesn't matter, since there's nothing to measure. You'll only see a voltage (and even then only a brief pulse) when an echo is actually received.

You would need an oscilloscope to be able to read that voltage.

| improve this answer | |
  • So what is my multimeter reading? It just keeps going up and down. It ranges between 0 and 5. – Yousuf Apr 17 at 22:04
  • Are you actively pinging at the time? Then you may be seeing it react to the pulses. – Majenko Apr 17 at 22:09
  • Yes it's fully pinned. 5v source. So when it reacts to the pulses, it changes the bolt reading? Since the max reading is 5v, does that mean that my resistors aren't placed properly since the voltage max didn't drop? – Yousuf Apr 17 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.