NodeMCU V3 and HC-SR04
Posted: Sun Dec 22, 2019 10:54 pm
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
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