-
• #2
What did yòu change A0 and A1 to and how did you wire it up?
I think the values you are seeing are random values.
-
• #3
I have
A0 map to NodeMCU.D1(Label D1 on board) => Trig on sensor
A1 map to NodeMCU.D2(Label D2 on board) => Echo On sensor -
• #4
Is the HC-SR04 code even known working on ESP8266? Because of how it has to keep yielding to do the radio stuff, timing-critical things can be problematic....
-
• #5
I don't know if the code is working on the esp8266. Can any body share their experience with the esp8266 here?
-
• #6
I have same issue on esp32, just increasing numbers ...
I don't think it's a bug with timing, rather
setWatch
not triggering onrising
signal only onfalling
. As values are based on timer offalling
event numbers are increased all the time. -
• #7
Same here guys. Data seems clean for second when I disconnected and connect echo pin again
-
• #8
connect pin Vcc to 5V and try again.
Hint: Some use a voltage divider for the Echo pin and some don't, check this Google search
used code
/* ESP8266 */ var sensor = require("HC-SR04").connect(NodeMCU.D1,NodeMCU.D2,function(dist) { console.log(dist+" cm away"); }); /* PICO var sensor = require("HC-SR04").connect(B3,B4,function(dist) { console.log(dist+" cm away"); }); */ setInterval(function() { sensor.trigger(); // send pulse }, 500);
distance HC-SR04 to
- room ceiling 168.57866655316 cm
- hand on top 10.12233265659 cm
- room ceiling 168.57866655316 cm
-
• #9
Search for the RCW-0001 ultrasonic sensor, it works with 3v3 - 5v.
Hi all, I am playing with the HC-SR04 on my esp8266 today and found that the outputted cm value doesn't seem correct at all. it looks like this(see below). a very large value returned. btw, I am completely new to this iot. but I did played with the ultrasonic sensor once with the arduino uno a while back and the distance output seems correct. so, my question is that is it possible that there's a bug in the distance calculation? I highly doubt that. but just want to make sure. If not, what am I doing wrong here? thanks in advance
I used the code straight from https://www.espruino.com/HC-SR04
output values: