HC-SR04

Can I get I get a HC SR04 sensor that can measure up to 100metres and what type of microcontroller can be used for it?

Question by Miccokams 1 year ago


SENSOR- Ultrasonic HC-SR04 (Interfacing HC-SR04 with 8051)

Hi friends, I am doing a project based on obstacle detector. It is a outdoor project hence i choose to buy an ultrasonic sensor to work efficiently on both bright sun light as well as dark nights. Now my problem is i am not able to interface this sensor with my controller. Anyone please tell me what input i must give to trig input of that sensor and what kind of output i get form the echo pin. also tell me how can i interface this sensor with the AT89S52. i have attached the user manual which i downloaded from internet.  Please help me with your valuable comments, Thanks in advance.

Topic by knachuthan 4 years ago  |  last reply 3 years ago


Arduino + Wifishield + buzzer + hc sr04

Hey, i started a project, i will explain it: i will try to measure a distance mit an arduino and a hc sr04 and sending the distance information to an monitor/pc/smartphone. Has anyone done something like this yet? thanks for helping.

Topic by MaximilianS2 3 years ago


Sr04 like device works to 300ft

An sr04 has a max range of 12'. I need to range to 300'. Residential well, 8" pipe. Aprox. 150-300' to water. A pinger and mic? A sr0400? Can not drop rocks or physically go past 6" below pipe cap. If I can find said device I'm thinking connect to a LoRa. We want to monitor say 12 wells in a square mile.Thanks

Question by liderbug 2 months ago  |  last reply 2 months ago


What is the program code for arduino obstacle avoiding robot it has IR remote and receiver module with HC-SR04 sensor?

It has HC-SR04 ultrasonic sensor , arduino uno R3, L293D motor driver , and Infrared remote and Infrared receiver module.

Question by KodakH1 1 year ago  |  last reply 1 year ago


Can you tell me the code for arduino robot that has HC-SR04 Ultrasonic sensor , L293D , IR receiver module and remote?

It is a arduino obstacle avoiding robot , that has arduino uno R3 , L293D motor driver , HC-SR04 ultrasonic sensor , IR remote and receiver module on 2wD chassis.

Question by KodakH1 1 year ago  |  last reply 1 year ago


arduino ultrasonic communication

I was thinking about using the ultrasonic  module (hc-sr04) for communication for two or more arduino.the way i was thinking of do to turn a 8 bit number into single bits(i have no idea on how to do that) and send them one at time(with delay) to a another arduino which turn it back into a number also  has a master arduino  and slave arduinos 

Topic by act casual 7 years ago  |  last reply 6 years ago



No sensory input on a motor shield?? Answered

Hello, I recently acquired a seeed motor shield http://www.seeedstudio.com/depot/motor-shield-p-913.html But what i notice now is that there is nowhere to attach my Sr04 ultrasonic sensor! How do I include sensory input on my robot with this shield? Thanks bunches. 

Question by TheIronHobo 5 years ago  |  last reply 5 years ago


Back that Arduino Up

Hello instructables, I am a student at High Tech High North County and we are working with arduinos in our Engineering class. Our project is to create a reverse sensor for a motor vehicle, we are having trouble finding a way to set up the sensor with the arduino. The sensor we are using is HC-SR04 Ultrasonic Ping range sensor. If you have any idea on how to do this, please reply. Thanks.

Topic by hthnc-student 6 years ago  |  last reply 6 years ago


sketch for arduino obstacle robot using seed motor shield v2.0?

Hi everybody, im barely started writing sletch so i need help, i build a obstacle robot and i used  arduino uno r3 seeed motor shield v2.0 one servo tamiya twin motor gear box hc-sr04 sensor  so i dont really know how to start writind the sketch.....

Question by salvador.lopez1 4 years ago  |  last reply 4 years ago


How to stop a servo using conditional if?

I'm using an Arduino Uno, Ultrasonic sensor (HC-SR04) a Servo motor (SG90 Tower Pro). I would like to rotate the servo continuously from 0 to 180 and back to 0. I would like to stop the servo whenever the ultrasonic sensor detects an object  at a distance of 40 cm or less. I know how to rotate the servo and how to detect an object using the ultrasonic sensor, but I couldn't combine the two. Can you kindly help me on how to do so?

Question by iSmartov 1 year ago  |  last reply 1 year ago


40kHz Ultrasonic Receiver Wanted

I'm looking for a breakout board, module, etc that is basically a 40kHz ultrasonic receiver, where if it detect a 40kHz signal it puts a pin high sort of thing (volume level as a PWM whatever, I just need to know when there is a 40kHz signal near by). I was thinking of using a HC-SR04 Ultrasonic Range Finder but they only receive for a very short time after the trigger pin goes high, I need it to constantly be sensing.Ideally works with a Raspberry Pi (ie 3.3 volts output, but 5v just means I add a voltage divider not a biggie)Thanks

Question by Duke Nukem 11 months ago


arduino code nedded

HI, MY  NAME IS THIAGO IKEDA AND HERE IS MY FIRST "ASK" my english is VERY bad. well sorry anyway FIRST  i made this arduino tank (named ardutank) with ladyada motor shield and i used library and worked then i like WOW I SUPER GENIUS so i buy an HC-SR04(ULTRASONIC SENSOR) to put with ARDUTANK, and i used the library too but when i upload the code the ARDUTANK START make some wild noises. i dont know what to do to ARDUTANK work with the sensor obs: in first mode (with out ultrasonic sensor) one motor spins more fast than other, WHY? the bouth motors are the same motor. but when i put to HIM to RUN HE make lil curve. here is code WITH SENSOR PLEASE IGNORE THE RELE AND BUZER NEXT TO SENSOR // Adafruit Motor shield library // copyright Adafruit Industries LLC, 2009 // this code is public domain, enjoy! #include #include #define TRIGGER_PIN  12 #define ECHO_PIN     13 int distance; Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN); AF_DCMotor motor1(1); AF_DCMotor motor2(2); void setup() {   Serial.begin(9600);           // set up Serial library at 9600 bps   Serial.println("Motor test!");   // turn on motor   delay(10);   motor1.setSpeed(20);   motor2.setSpeed(20); motor2.run(RELEASE);   motor1.run(RELEASE); } void loop() {   uint8_t i;   float cmMsec, inMsec;   long microsec = ultrasonic.timing();   cmMsec = ultrasonic.convert(microsec, Ultrasonic::CM);   inMsec = ultrasonic.convert(microsec, Ultrasonic::IN);   Serial.print("tick");   motor1.run(FORWARD);   motor2.run(FORWARD);   if(distance<10) {    motor1.run(RELEASE);    motor2.run(RELEASE); } else {    motor1.run(FORWARD);   motor2.run(FORWARD); } }

Question by crazy_thiago 5 years ago  |  last reply 5 years ago


new to arduino, want to run a dual display for 2 sensors

I'm new to the Arduino community.  wanting to set up a dual radar setup with 2 ultrasonic sensors,  (Ultrasonic Sensor Module HC-SR04), and outputting to a pair of 7 segment displays ( two 7 segment displays each).  I've found a code to do a single could use a lot of help to output two at the same time, basically 2 lanes without 2 units.  im using an arduino mega, ordered a unor3 and hopefully it can be made to run on one or the other. code is as follows: /* HC-SR04 Sensor    The circuit:     * VCC connection of the sensor attached to +5V     * GND connection of the sensor attached to ground     * TRIG connection of the sensor attached to digital pin 2     * ECHO connection of the sensor attached to digital pin 4  */    /*  This is a radar ping sensor that calcultates the speed of an  object traveling away or towards the sensor. I took some of this  code for the HC-SR04 Sensor implementation by Tautvidas Sipavicius. The rest  is original code from me. I know that the seven segment display  code is not the best to look at or the most optimized but it  serves its purpose just fine and is easy to understand.    Written by Matthew Ladd  */   const int trigPin = 2; const int echoPin = 4;   void setup() {   // initialize serial communication:   Serial.begin(9600);   //First 7 segment (ones place)   pinMode(30,OUTPUT);//F   pinMode(31,OUTPUT);//G   pinMode(32,OUTPUT);//E   pinMode(33,OUTPUT);//D   pinMode(34,OUTPUT);//C   pinMode(35,OUTPUT);//B   pinMode(36,OUTPUT);//A   //Second 7 segment (tens place)   pinMode(37,OUTPUT);//F   pinMode(38,OUTPUT);//G   pinMode(39,OUTPUT);//E   pinMode(40,OUTPUT);//D   pinMode(41,OUTPUT);//C   pinMode(42,OUTPUT);//B   pinMode(43,OUTPUT);//A } void zerofirst(){   digitalWrite(30,LOW);   digitalWrite(31,HIGH);   digitalWrite(32,LOW);   digitalWrite(33,LOW);   digitalWrite(34,LOW);   digitalWrite(35,LOW);   digitalWrite(36,LOW); } void onefirst(){   digitalWrite(30,HIGH);   digitalWrite(31,HIGH);   digitalWrite(32,HIGH);   digitalWrite(33,HIGH);   digitalWrite(34,LOW);   digitalWrite(35,LOW);   digitalWrite(36,HIGH); } void twofirst(){   digitalWrite(30,HIGH);//F   digitalWrite(31,LOW);//G   digitalWrite(32,LOW);//E   digitalWrite(33,LOW);//D   digitalWrite(34,HIGH);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void threefirst(){   digitalWrite(30,HIGH);//F   digitalWrite(31,LOW);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,LOW);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void fourfirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,HIGH);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,HIGH);//A } void fivefirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,LOW);//D   digitalWrite(34,LOW);//C   digitalWrite(35,HIGH);//B   digitalWrite(36,LOW);//A } void sixfirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,LOW);//E   digitalWrite(33,LOW);//D   digitalWrite(34,LOW);//C   digitalWrite(35,HIGH);//B   digitalWrite(36,LOW);//A } void sevenfirst(){   digitalWrite(30,HIGH);//F   digitalWrite(31,HIGH);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,HIGH);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void eightfirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,LOW);//E   digitalWrite(33,LOW);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void ninefirst(){   digitalWrite(30,LOW);//F   digitalWrite(31,LOW);//G   digitalWrite(32,HIGH);//E   digitalWrite(33,HIGH);//D   digitalWrite(34,LOW);//C   digitalWrite(35,LOW);//B   digitalWrite(36,LOW);//A } void zerosecond(){   digitalWrite(37,LOW);   digitalWrite(38,HIGH);   digitalWrite(39,LOW);   digitalWrite(40,LOW);   digitalWrite(41,LOW);   digitalWrite(42,LOW);   digitalWrite(43,LOW); } void onesecond(){   digitalWrite(37,HIGH);   digitalWrite(38,HIGH);   digitalWrite(39,HIGH);   digitalWrite(40,HIGH);   digitalWrite(41,LOW);   digitalWrite(42,LOW);   digitalWrite(43,HIGH); } void twosecond(){   digitalWrite(37,HIGH);//F   digitalWrite(38,LOW);//G   digitalWrite(39,LOW);//E   digitalWrite(40,LOW);//D   digitalWrite(41,HIGH);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } void threesecond(){   digitalWrite(37,HIGH);//F   digitalWrite(38,LOW);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,LOW);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } void foursecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,HIGH);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,HIGH);//A } void fivesecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,LOW);//D   digitalWrite(41,LOW);//C   digitalWrite(42,HIGH);//B   digitalWrite(43,LOW);//A } void sixsecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,LOW);//E   digitalWrite(40,LOW);//D   digitalWrite(41,LOW);//C   digitalWrite(42,HIGH);//B   digitalWrite(43,LOW);//A } void sevensecond(){   digitalWrite(37,HIGH);//F   digitalWrite(38,HIGH);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,HIGH);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } void eightsecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,LOW);//E   digitalWrite(40,LOW);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } void ninesecond(){   digitalWrite(37,LOW);//F   digitalWrite(38,LOW);//G   digitalWrite(39,HIGH);//E   digitalWrite(40,HIGH);//D   digitalWrite(41,LOW);//C   digitalWrite(42,LOW);//B   digitalWrite(43,LOW);//A } long distanceOverTime(long first,long second){  return ((first-second)/.1)*.0223693629;//taking cm/s to mph } long holder;//store the cm from last time through loop. long temp;//used to store the speed value after changes int counter; void loop() {   // establish variables for duration of the ping,   // and the distance result in inches and centimeters:   long duration, inches, cm;   int tens;   int ones;   long Speed;   // The sensor is triggered by a HIGH pulse of 10 or more microseconds.   // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:   pinMode(trigPin, OUTPUT);   digitalWrite(trigPin, LOW);   delayMicroseconds(2);   digitalWrite(trigPin, HIGH);   delayMicroseconds(10);   digitalWrite(trigPin, LOW);     // Read the signal from the sensor: a HIGH pulse whose   // duration is the time (in microseconds) from the sending   // of the ping to the reception of its echo off of an object.   pinMode(echoPin, INPUT);   duration = pulseIn(echoPin, HIGH);     // convert the time into a distance   inches = microsecondsToInches(duration);   cm = microsecondsToCentimeters(duration);   Speed=distanceOverTime(holder,cm);   holder=cm;//after speed caclulation so take the cm value for another calculation   Speed=abs(Speed);   if(Speed!=0 || counter==10){     temp=Speed;     counter=0;   }else{     counter++;   }   if(temp>=100){    zerofirst();    zerosecond();   }else{     ones=temp%10;     tens=temp/10;   }   if(ones == 0){     zerofirst();   }else if(ones==1){     onefirst();   }else if(ones==2){     twofirst();   }else if(ones==3){     threefirst();   }else if(ones==4){     fourfirst();   }else if(ones==5){     fivefirst();   }else if(ones==6){     sixfirst();   }else if(ones==7){     sevenfirst();   }else if(ones==8){     eightfirst();   }else if(ones==9){     ninefirst();   }   if(tens == 0){     zerosecond();   }else if(tens==1){     onesecond();   }else if(tens==2){     twosecond();   }else if(tens==3){     threesecond();   }else if(tens==4){     foursecond();   }else if(tens==5){     fivesecond();   }else if(tens==6){     sixsecond();   }else if(tens==7){     sevensecond();   }else if(tens==8){     eightsecond();   }else if(tens==9){     ninesecond();   }       Serial.print(inches);   Serial.print(" in, ");   Serial.print(cm);   Serial.print(" cm, ");   Serial.print(Speed);   Serial.print(" mph");   Serial.println();     delay(100); }   long microsecondsToInches(long microseconds) {   // According to Parallax's datasheet for the PING))), there are   // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per   // second).  This gives the distance travelled by the ping, outbound   // and return, so we divide by 2 to get the distance of the obstacle.   // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf   return microseconds / 74 / 2; }   long microsecondsToCentimeters(long microseconds) {   // The speed of sound is 340 m/s or 29 microseconds per centimeter.   // The ping travels out and back, so to find the distance of the   // object we take half of the distance travelled.   return microseconds / 29 / 2; } again, all your help and thought are appricated

Topic by herb1977 1 year ago  |  last reply 1 year ago


Automatic Irrigation using d1 mini

Hi Everyone, I reviewed different automatic irrigation system projects here in instructables and other sites as well and i decided to gather parts to do a simple small project myself. One thing that comes hard is the programming part as I don't know any programming language. I'm looking for some help with code merging, explanation and some general guidance. Could you please let me know, point me to right direction and tell me what you think and if requirements are actually achievable? What I would like to achieve: Intention of this project is to have manual and auto irrigation system which will: 1. Measure soil moisture and dependently on the value activate the usb pump which will water the plant (preferably analog output that will show the measurements in %) 2. Manual activating the pump via hardware button and via mobile phone with internet connection 3. Distance sensor which should measure how much water is left in the tank 4. Email notification with info when to water the plants and soil sensor data regardless of the automatic process that has already started 5. Email notification with info about the water in the tank when it’s near empty 6. Dashboard preferably inside the network (not using third party like blynk or others) with access from the internet (I have QNAP that I think can be used). 7. If possible – have amazon echo (Alexa) read the sensor data to tell me the values and comment if the plant should or shouldn’t be watered or the tank should be refiled or not as well as ability to ask Alexa to start or stop the irrigation Hardware: D1 mini: https://wiki.wemos.cc/products:d1:d1_mini Wemos V2 Relay shield: http://hobbycomponents.com/shields/865-wemos-v2-relay-shield My relay is slightly modified: 2 small wires soldered to the vcc and ground so that when it receives the signal on d1 pin it opens and current flows to female usb connector supposedly activating the usb water pump. All this can be stacked together even with soldered wires YL-69 sensor: http://www.oddwires.com/yl-69-soil-hygrometer-humidity-soil-moisture-detection-sensor/ Ultrasonic Distance Sensor (HC-SR04): https://thepihut.com/products/ultrasonic-distance-sensor-hcsr04 USB mini water pump: www.goo.gl/yUABDd Button x4 if needed: Board x4 if needed: sample codes used in other projects: https://randomnerdtutorials.com/guide-for-soil-moisture-sensor-yl-69-or-hl-69-with-the-arduino/ https://create.arduino.cc/projecthub/nekhbet/using-the-yl-39-yl-69-soil-humidity-sensor-with-arduino-968268 https://community.blynk.cc/t/irrigation-relay-with-timer-esp8266-wip/700 Alexa enabled homemade cat feeder example: https://www.hackster.io/darian-johnson/alexa-powered-automated-cat-feeder-9416d4 Thank you very much in advance for your help and support.

Topic by wube 1 year ago  |  last reply 1 year ago