Hello everyone,
I'm doing some tests with NodeMCU v3 board and HC-SR04.
It's a simple script that boots up, connects to WiFi, reads distance, sends it to a MQTT topic, and goes to deep sleep.
I'm using 18650 LiPos so I use three devices to manage power:
- TP4056 to charge batteries.
- DC booster (https://es.aliexpress.com/item/32807311456.html) to get 5v from LiPo and supply 5v to HC-SR04.
- LDO (MCP1700-3302E) to power the NodeMCU board with a stable 3.3V line.
As HC-SR04 works at 5v, im using a simple voltage divider (1K+2K) to step down Echo signal and don't overcharge any GPIO.
Im using this lib: https://github.com/lemariva/uPySensors/ ... /hcsr04.py
Im having issues with the HC-SR04 board:
- Instead of getting a stable read, I get sometimes a distance and in the next reading the half. For example, If I do 10 readings, 6 are 14cm and 4 are 28cm.
- Cannot get a real value of readings. For example, for a given real distance of ~55cm, I'm getting readings of 14cm and 28cm, but nothing near the real distance.
Can anybody help me?
Regards,
CiDsTaR
NodeMCU V3 and HC-SR04
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: NodeMCU V3 and HC-SR04
I'm using a similar setup. You can try to use my driver, but you need to strip it of all project specific methods and objects: https://github.com/kevinkk525/pysmartno ... /hcsr04.py
I also have trouble with inconsitent readings and only between 3cm and 80cm the readings were more or less accurate. I do multiple readings, remove the most extreme ones and use an average of the remaining readings. That seems to work acceptable but is of course a bit slow.
I also have trouble with inconsitent readings and only between 3cm and 80cm the readings were more or less accurate. I do multiple readings, remove the most extreme ones and use an average of the remaining readings. That seems to work acceptable but is of course a bit slow.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: NodeMCU V3 and HC-SR04
Have you ever given a try to HC-SR04P variant, that is supposed to work @3v?
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: NodeMCU V3 and HC-SR04
No I haven't tried that one yet.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: NodeMCU V3 and HC-SR04
I just received my HC-SR04P sensors.
Before any further tests, It seems that:
- It uses an IC named "RCWL-1601".
- It works pretty well at 3v. (Be careful with max current if you plan to use any GPIO pin as power source).
- It can be powered with the same 3v source as the ESP8266 (i.e. a Lipo with a LDO regulator).
- I'm getting more accuracy than with a HCSR04 sensor.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: NodeMCU V3 and HC-SR04
That's good news! Thanks for sharing your findings.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: NodeMCU V3 and HC-SR04
I've had some issues with the WiFi radio interfering with my sensors, so the steps I've taken is letting the WiFi connect when the board boots up, hit a url that pings me telling me it's active, and then I shut down the WiFi radio, and wait for sensor activation. If the sensor activates, then I have it connect to the WiFi again (it doesn't take long, a couple seconds at the most) and fire off the event via another url. I haven't had any false positives in a long time doing it that way, maybe that could help someone else having any interference issues.