Hack an HC SR04 to a 3 Pin Sensor

About: The world is a Roller coaster, Im the operator.

Intro: Hack an HC SR04 to a 3 Pin Sensor

I hope you all have heard of that expensive-but-awesome parallax ping))) sensor. I cannot buy one of them it blasts my budget into tiny little pieces of debris floating around (30$ i mean). So what do you do? literally hack your problems into pieces. So guys with the hcsr04 if you are like me pondering over the ping))). Follow this hack and get amazed:)

Step 1: Get the Stuff

1x HC SR04 ultrasonic distance sensor

Lot of 22 awg solid core hookup wire

Breadboard

Arduino

Programming A/B cable.

Now let us begin

Step 2: The Circuit

Connect this circuit.

Step 3: Code


//this is a code for using a 4 pin hc sr04 sensor as a 3 pin ping sensor By robobot3112


#include <NewPing.h>

#define PING_PIN 12 // Arduino pin for both trig and echo

NewPing sonar(PING_PIN, PING_PIN );

void setup() {

Serial.begin(115200);

}

void loop() {

delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay

unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).

Serial.print("Ping: ");
Serial.print(uS / US_ROUNDTRIP_CM); // convert time into distance

Serial.println("cm"); }

Step 4: Results

Here are the results.

Let me know any error i shall revise it.

Please vote

Share

Recommendations

  • Tiny Home Contest

    Tiny Home Contest
  • Fix It! Contest

    Fix It! Contest
  • Metalworking Contest

    Metalworking Contest

52 Discussions

0
None
knachuthan

3 years ago on Introduction

Am doing a project on obstacle detector using Hcsr04 (I need to use it outdoor so going for ultrasonic). Earlier i had DYP-ME007TX which is 3 pin sensor gives out serial output. as i have problem in converting 32 bit serial output to 8 bit, i brought this HC-SR04 , Am using it with AT89S52. I dono where am making mistake.

I gave 5v to vcc, then gnd. later high pulse to trig input and after that no response from echo. Please help me out!

Thanks in advance.

6 replies
0
None
robobot3112knachuthan

Reply 3 years ago on Introduction

Does the code get uploaded to your microcontroller ? if so; test the hc-sr04 with an arduino or a clone.

ps sorry for the late reply

0
None
knachuthanrobobot3112

Reply 3 years ago on Introduction

Yes i completed the project successfully. The thing i missed early was time frame. when the trig pin receives high pulse for 10 us it emits ultrasonic test signals immediately. thus we must be ready right from the 11th microsec to recieve the signal.

0
None
robobot3112knachuthan

Reply 3 years ago on Introduction

I'll look into the microcontroller you are using and send you the problem. Sorry for the late reply.

0
None
AravindP4

1 year ago

hello sir i want to use two sensors .

but trigger on one hscr04

echo on other ultrasonic sensor .

can u please tell me how to do

2 replies
0
None
robobot3112AravindP4

Reply 1 year ago

Im not sure what you mean, but i think youre trying to integrate two sensors into one.

So, instead of using trig on one an echo on one,

just short the two pins, and connect the wire as shown in the instructable, because integrating the 2 sensors into one is a difficult task.

Best of luck.

0
None
AravindP4robobot3112

Reply 1 year ago

first i will say thank you for answering me.

what i am trying to do is transmit on one ultrasonic .receive from another ultrasonic sensor .

0
None
Titannet1Titannet1

Reply 2 years ago

I've found it: http://playground.arduino.cc/Code/NewPing#Download

0
None
freduj

2 years ago

3112 Hello robot,

thank you for your work , because these cheap sensors are really difficult to operate.now it's ok

.is it possible to run three sensors at the same time?

thank you

2 replies
0
None
robobot3112freduj

Reply 2 years ago

yes you can run upto as many sensors as pins on your arduino as long as you have powered it correctly.

0
None
fredujrobobot3112

Reply 2 years ago

thank you,

i will try to make this project but I'm beginning in arduino world, it's not simple for me.if I can I put my code here.

0
None
MaxneilQ

2 years ago

do I need a library for the sensor to work?

1 reply
0
None
PeterS48

3 years ago on Introduction

hi! can you help please? I put the extracted the newPing file containing the header into the same folder as my file is with your code and it still can not find the header and I get an error message, when I try to compile. Any ideas what I am doing wrong? thanks in advance!

1 reply