HC-SR04

From Let's Control It
Revision as of 08:22, 3 October 2015 by Admin (talk | contribs) (→‎ESP Easy)
Jump to navigation Jump to search

Introduction

The ESP can also be used to measure distance with the HC-SR04 Ultrasonic sensor.

The sensor has to be connected to two GPIO pins on the ESP module. The ESP uses an interrupt routine to retrieve the echo pulse from the HC-SR04.

Hardware

HC-SR04.jpg

The HC-SR04 can be found on eBay. Please note that the sensor uses 5 volts signals and they should not directly be connected to the ESP. Use a level shifter!


Connections

WARNING: The unit uses 5 volt signals that can not be used on the ESP module. You must use a levelshifter!!! And do not connect VCC between HC-SR04 and the ESP. Power the HC-SR04 with a separate 5 volt supply!

 HC-SR04 	ESP-01
 GND   	GND
 VCC      	-
 Trig		1st GPIO (via levelshifter!!!)
 Echo		2nd GPIO (via levelshifter!!!)

Software

Custom Sketch

todo

ESP Easy

Use the device tab on the ESP Easy webinterface and create a new task by editing one of the available tasks. Select "Ultrasonic Sensor HC-SR04 from the dropdown box.

EasyConfigDistance.png

Enter the IDX found in the Domoticz device page. Also select the two GPIO pins that you have used to connect the HC-SR04 sensor. That should be all.

Optional settings

Use of value names

ESP Connexio