OPERATION HOURS
Monday - Friday: 9am - 6pm.
Saturday: 10am - 2pm.
Sunday & Public Holiday: Closed.
Buy online 24/7 or walk-in to our store, our friendly team is always ready to serve you :)
HC-SR04P Ultrasonic Ranging Module
The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats or dolphins do. It offers excellent range accuracy and stable readings in an easy-to-use package. It operation is not affected by sunlight or black material like Sharp rangefinders are (although acoustically soft materials like cloth can be difficult to detect). Similar in performance to the SRF005 but with the low-price of a Sharp infrared sensor.
HC-SR04 (1ST GEN)
===================================
Power Supply : 5V DC
Quiescent Current : <2mA
Effectual Angle: <15°
Ranging Distance : 2cm – 500 cm/1" - 16ft
Resolution : 0.3 cm
===================================
HC-SR04P (2ND GEN - UPGRADE VERSION)
===================================
HC-SR04P Upgrade version with build-in crystal, more reliable, lower working current.
Power Supply: 3.3~5 VDC
Quiescent Current : <2mA
Working Current: 2.8mA @ 5V
Effective Angle: <15°
Ranging Distance : 2cm – 400 cm or 1″ – 13ft
Connector: 4-pins header with 2.54mm pitch.
Dimension: 45mm x 20mm x 15mm
Weight 8.5-g.
===================================
Basic use of the HC-SR04 Ultrasonic Sensor
Please see the datasheet (under "Download" tab) for an excellent description of how the sensor operates.
Using the HC-SR04 with a PICAXE microcontroller
There is a nice tutorial right here at LMR with sample code for using an ultrasonic sensor with a PICAXE 28 project board (thanks Frits!). Do not be disappointed that it’s written for the SRF05 ultrasonic sensor; the sensor operates the same way.
“How to connect SRF05 to Picaxe 28 pin Project board” tutorial
Using the HC-SR04 with an Arduino
There is an Arduino library for the HC-SR04 that offers two ways to use the sensor. To install, download the “Ultrasonic Library” from the "Download" page, unzip the release package into your “arduino-0018/libraries/” folder. Open the Arduino IDE and include the library by Sketch-Import library-Ultrasonic . There is also an example sketch in File-Examples-Ultrasonic-UltrasonicDemo.
The library includes 3 functions:
1. Ultrasonic(int TP, int EP)
This is a initial function for ultrasonic ranging module, choose the pins for module TRIG and ECHO pin. For example:
Ultrasonic(13,12);
defines the digital pin 13 of Arduino as the TRIG pin of HC-SR04 and pin 12 for the ECHO pin.
2. long Timing()
This function triggers the ultrasonic module and returns the duration that the ECHO pin was held high. For example:
long time; Ultrasonic hcsr; time = hcsr.Timing();
The distance of the object corelates to the time the ECHO pin is held high. The distance formula is:
Distance = ((Duration of high level)*(Sonic :340m/s))/2
3. long Ranging(int sys) — (sys : CM / INC)
If you don’t want to change the time into distance yourself, this function will help you get the distance immediately. This function has a parameter (using CM or ICN) that shows the distance in centimeters or inches. This function will call Timing() and you don’t need to use the Timing() before it. For example:
long distance; Ultrasonic hcsr; distance = hcsr.Ranging(CM);
returns the distance in centimeters