hc-sr04 edits

blakadder 2019-11-07 00:14:23 +01:00
parent 8b79a485eb
commit c20b039fb1
4 changed files with 40 additions and 37 deletions

38
HC-SR04.md Normal file

@ -0,0 +1,38 @@
HC-SR04 (HC-SR04P and JSN-SR04T) is an ultrasonic ranging sensor. Provides 2cm to 400cm 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](https://www.sparkfun.com/products/13959) for more information.
Buy example:
- [AliExpress](https://www.aliexpress.com/item/4000124226294.html)
- [Sparkfun](https://www.sparkfun.com/products/13959)
## Configuration
### Wiring
<img src="https://raw.githubusercontent.com/arendst/arendst.github.io/master/media/wemos/wemos_hc-sr04_schematic.jpg" align=right></img>
| HC-SR04 | ESP8266 |
|---|---|
|Vcc |5V |
|GND |GND |
|Trig |GPIOx |
|Echo<br>use voltage divider! |GPIOy |
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.
![image](https://user-images.githubusercontent.com/5904370/68340827-75155880-00e7-11ea-8f79-efd47bd421bc.png)
### Tasmota
In the _Configuration -> Configure Module_ page assign:
1. GPIOx to `SR04 Tri (69)`
2. GPIOy to `SR04 Ech (70)`
![image](https://user-images.githubusercontent.com/5904370/68340227-4ea2ed80-00e6-11ea-90bf-c6da3cd6eb22.png)
### Tasmota Main
After a reboot webUI displays the HC-SR04 distance.
![image](https://user-images.githubusercontent.com/5904370/68340187-39c65a00-00e6-11ea-8c27-22527368e3d5.png)
Sensor sends a `tele/%topic%/SENSOR` JSON reponse:
```json
{"Time":"2019-01-01T22:42:35","SR04":{"Distance":16.754}}
```

@ -24,7 +24,7 @@ More about [general configuration](Sensor-Configuration).
- [**DS3231**](DS3231) - Real-Time-Clock (I<sup>2</sup>C)
- [**HM16/HM17**](iBeacon-driver) - Bluetooth iBeacon reader (serial)
- **HR-E** - Water Meter Encoder interface (serial)
- [**HC-SR04 (SR04+, SR04T)**](Wemos-D1-Mini-and-HC-SR04-Ultrasonic-Sensor) - Ultrasonic Sensor
- [**HC-SR04 (HC-SR04P, JSN-SR04T)**](HC-SR04) - Ultrasonic Sensor
- [**HC-SR501**](PIR-Motion-Sensors#HC-SR501) - PIR Motion Sensor<img src="https://user-images.githubusercontent.com/5904370/53279530-8c571600-3711-11e9-85c0-27d35be2df48.png" width="200" align="right" />
- **Honeywell HIH** - Temperature and Humidity sensor (I<sup>2</sup>C)
- **Honeywell HPMA115S0** - Particulate Matter Sensor (serial)

@ -17,7 +17,7 @@
- [**DS3231**](DS3231) Real-Time-Clock (I<sup>2</sup>C)
- [**HM16/HM17**](iBeacon-driver) Bluetooth iBeacon reader (Serial)
- **HR-E** Water Meter Encoder interface (Serial)
- [**HC-SR04 (SR04+, SR04T)**](Wemos-D1-Mini-and-HC-SR04-Ultrasonic-Sensor) Ultrasonic Sensor
- [**HC-SR04 (SR04+, SR04T)**](HC-SR04) Ultrasonic Sensor
- [**HC-SR501**](PIR-Motion-Sensors#HC-SR501) PIR Motion Sensor<img src="https://user-images.githubusercontent.com/5904370/53279530-8c571600-3711-11e9-85c0-27d35be2df48.png" width="250" align="right" />
- **HTU21** Temperature and Humidity sensor (I<sup>2</sup>C)
- **HX711** Load Cell sensor (GPIO)

@ -1,35 +0,0 @@
## HC-SR04 Ultrasonic Sensor
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/wemos/hc-sr04-ultrasonic-sensor-blue.jpg" align=right width=200>
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/wemos/hc-sr04-ultrasonic-sensor-red.jpg" align=right width=225>
"This is the HC-SR04 ultrasonic ranging sensor. This economical sensor provides 2cm to 400cm 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](https://www.sparkfun.com/products/13959) for more information.
Buy example:
- [AliExpress](https://aliexpress.com/item/Free-shipping-1pcs-Ultrasonic-Module-HC-SR04-Distance-Measuring-Transducer-Sensor-for-Arduino-Samples-Best-prices/690139020.html)
- [Sparkfun](https://www.sparkfun.com/products/13959)
### Connecting the HC-SR04 to a Wemos Mini D1
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/wemos/wemos_hc-sr04_schematic.jpg" align=left width=600>
| Wemos | HC-SR04 |
|---|---|
|GND |GND |
|5V |VCC |
|D6 (gpio12) |Echo via voltage divider |
|D7 (gpio13) |Trigger |
The HC-SR04 operates best at 5V, 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 operation voltage of the Wemos D1 Mini.
Please note 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.
### Tasmota Configuration
In the Configuration -> Configure Module page, select the following:
1. **Module Type : 18 Generic**
2. **D6 GPIO12 : 70 SR04 Ech**
3. **D7 GPIO13 : 69 SR04 Tri**
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/wemos/wemos_hc-sr04_config_marked.jpg" width=300>
### Tasmota Main
After reboot of the device the displays the HC-SR04 distance.
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/wemos/wemos_hc-sr04_main_marked.jpg" width=300>