HC-SR04 ultrasonic ranging sensor~
This feature is included only in
When compiling your build add the following to
#ifndef USE_SR04 #define USE_SR04 // Add support for HC-SR04 ultrasonic devices (+1k code) #define SR04_MAX_SENSOR_DISTANCE 500 // Set sensor max detection distance #endif
HC-SR04 (HC-SR04P and JSN-SR04T) is an ultrasonic ranging sensor. Provides 2cm to 300cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. Each HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit. See HC-SR04 Ultrasonic Sensor for more information.
The US-100 can also be use as a HC-SR04 if you remove the jumper at the back (check Adafruit documentation).
use voltage divider!
The HC-SR04 operates at 5V and therefore the echo signal will be 5V as well. Connecting the echo pin via a voltage divider (see schematic) will divide the 5V to 3.3V, which is the operating voltage of an ESP8266.
There is a variant of the HC-SR04, called HC-SR04P. It mainly operates at 3.3V and then it doesn't need the voltage divider but you will notice a range drop of about 1 meter.
In the Configuration -> Configure Module page assign:
- GPIOx to
SR04 Tri (69)
- GPIOy to
SR04 Ech (70)
After a reboot webUI displays the HC-SR04 distance.
Sensor sends a
tele/%topic%/SENSOR JSON reponse: