Questions tagged [hc-sr04]

For questions about the HC-SR04 ultrasonic ranging sensor.

Filter by
Sorted by
Tagged with
1 vote
1 answer
60 views

Problem adding IR receiver to smart car

I’m making a smart car using an arduino uno, sensor shield v5, motor control with a L298N and a servo motor + HC-SR04 ultrasound sensor. I want to add a IR receiver on the board so I can also control ...
AugustinS's user avatar
1 vote
1 answer
353 views

How to drive two Stepper motors and use an Ultrasonic sensor together?

I am working on an autonomous robot using two 4-pin stepper motors, HC-SR04 ultrasonic sensor, 2 L298N motor drivers (one for each motor), and an Arduino Uno. My problem is that when I use the stepper ...
Renier Jr.'s user avatar
-1 votes
1 answer
49 views

It is required to turn on the LED if the distance to the object is less than or equal to 200 centimeters. Find the error in the code

int trigPin = 10; const int echoPin = 8; int led = 7; const int distance = 200; void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(led, OUTPUT); } void loop() { ...
user90289's user avatar
1 vote
0 answers
106 views

Problems using HC-SR04 with LED displays

I'm having problems using an HC-SR04 ultrasonic sensor in conjunction with an LED display module. The sensor appears to work fine when outputting values to the serial monitor, measuring distances up ...
Nicholas's user avatar
  • 111
0 votes
1 answer
93 views

Ways to detect if a ball has reached the wall?

I'm building a kind of pin ball machine, and I need to detect when the ball has hit the wall with the sensor attached. The ball will hit the wall with a small impact, not large enough to push a button ...
SJ19's user avatar
  • 111
0 votes
1 answer
406 views

Limit on connector cable for HC-SR04 ultrasonic sensor

Is there a limit for the connector distance between an arduino and a HC-SR04 ultrasonic sensor? I have a set-up for measuring a liquid's level in a tank. The benchtop version worked OK, but when I ...
Ken's user avatar
  • 103
1 vote
0 answers
35 views

Problem regarding on HC-SR04 sonar with an additional stepper and SG90 servo motor

I'm making a project based on HC-SR04 ultrasonic sensor with a stepper motor and an SG90 servo motor. I have done some conditions for my stepper motor that is given below. Now I want to include my ...
Toufiq's user avatar
  • 11
3 votes
1 answer
900 views

How to use HC-SR04 sensor to make a flowmeter?

I am somewhat familiar with Arduino and am trying to use two ultrasonic HC-SR04 modules to measure the direction of water flow inside a pipe. The sensors are kept as in the image below. The direction ...
Aradhya Jain's user avatar
1 vote
0 answers
38 views

What is wrong with my code? (HC-SR04 using 433 mhz module);

I asked a question about this last time but I still couldn't make it work but it somehow gave me an overview about my project. Now I've created an another project that is similar to the last one, the ...
Thomas Raymond Santos's user avatar
2 votes
1 answer
159 views

How do I get sensor values using transmitter and receiver?

I used an HC-SR04 sensor and connected it to an Arduino board (BOARD1) with a 433 MHz transmitter, and the other board (BOARD2) is connected to the 433 MHz receiver. I don't know how to see the sensor ...
Thomas Raymond Santos's user avatar
1 vote
0 answers
185 views

How do you count objects (using ultrasonic sensor HCSR04) as 1, after they leave the trigger/echo path?

I found a simple code online that meets my goal to almost 100%, however when I place my hand in front of it, the number continues to count. I am trying to only count "1" when the solid ...
Chris's user avatar
  • 11
1 vote
0 answers
50 views

Ultrasonic HC-SR04

Having trouble with arduino Ultrasonic Sensor Module HC-SR04 I'm sure when you read this you're going to say how stupid can he be and you're probably right but I'm 82 years old and I'm trying very ...
Dennis M Martin's user avatar
1 vote
0 answers
340 views

ESP-01 and HC-SR04 problems booting up

I have a problem in a project that I am working, basically I need to use a ESP-01 to receive the measurements from a HC-SR04 and send it to another ESP-01 (which I won't cover here). Basically my ESP ...
Danillo Lange's user avatar
1 vote
1 answer
2k views

Connecting multiple ultrasonic sensors(hc-sr04) to a single arduino board.(mega)

I am currently working on an alarm system using multiple sensors and one arduino board and I am getting readings from 2 of the sensors but one gives a constant zero and a constant buzzer sound even ...
Wayne 254's user avatar
3 votes
1 answer
788 views

Ultrasonic Sensor(HC-SR04) recording random distance

I am am trying to make a code which automatically controls relay on basis of ultrasonic sensor measurements. I am using a nodeMCU as a microcontroller rather than an arduino. The relay and the ...
Shubham Bajaj's user avatar
0 votes
1 answer
184 views

Error for compiling for board Arduino Uno

I am new to Arduino and just got this error after writing this code:The error message is pasted after the code. I am kindly requesting for assistance so that someone can help me understand why it isn'...
Wayne 254's user avatar
1 vote
0 answers
235 views

Why is my buzzer always on?

I wanted to make a buzzer go off when the distance measured by the ultrasonic sensor becomes more than 100cm. The things used in this project are a 4x4 keypad, an hc-sr04 ultrasonic sensor, and a ...
Abhi's user avatar
  • 31
0 votes
1 answer
49 views

Arduino Coding Issue

I'm running a water pump based on ultra sonic readings. Once the Ultra Sonic Sensor reads > 10 cm , I want the water pump to start until sensor reads < 5 cm. Would you please help me adjust the ...
motion channel's user avatar
1 vote
1 answer
4k views

Code for 2 ultrasonic sensors

This is my code: int trigPin=13; //Sensor Trig pin connected to Arduino pin 13 int echoPin=11; //Sensor Echo pin connected to Arduino pin 11 float pingTime; //time for ping to travel from sensor to ...
python man's user avatar
0 votes
1 answer
244 views

Trying a crude water level sensor

first of all, Im from Cuba, that means I may have some problems to find parts... I have a little system to measure the water level in my house water tank. The system is pretty rough: a proximity ...
k.Cyborg's user avatar
  • 262
0 votes
2 answers
2k views

HC-SR04 ultrasonic sensor: How to check voltage on the ECHO pin

I'm using and ESP8266 with HC-SR04 ultrasonic sensor. The sensor requires 5v input and will also output to the GPIO pins at 5V. ESP8266 has a strong recommendation to use 3.3V into the GPIO pins. I'...
Yousuf's user avatar
  • 13
1 vote
0 answers
77 views

Combining two scripts

I'm trying to combine two scripts I've found. One to get my remote control model to work via a controller and the other to enable 6 ultrasound modules I have. When I omit the code highlighted in "THIS ...
Frank Warren's user avatar
1 vote
3 answers
2k views

How far can a HC-SR04 can stand from the microcontroller?

I was wondering if I connect a HC-SR04 to an Arduino or any other microcontroller by normal cables, what would be the maximum length of this cable so that the measurements will still be true, and not ...
Mihnea Cristian Marin's user avatar
1 vote
0 answers
166 views

ESP8266 GPIO limitations with HC-SR04

I want to build a systems that measures if some parking spots are occupied or not. I chose to use an ESP8266 12-E NodeMCU Kit with multiple HC-SR04 ultrasonic sensors. In my project, it is essential ...
Mihnea Cristian Marin's user avatar
0 votes
3 answers
3k views

Level shifting 5V <-> 3.3V

My main goal is to use connect the HC-SR04 ultrasonic sensor with ESP8266. Problem is, HC-SR04 works with 5V while the ESP8266 works with 3.3V In order to solve this, idea would be to use a logical ...
3dprogramin's user avatar
1 vote
0 answers
20 views

Getting weird output for following object detection code using interrupts on HUZZAH ESP8266 and motor controller L293D along with 3 HCSR04 sensors

I am trying to implement a bot which can sense obstacle in front, left or right and post detection send interrupts. Which in turn will perform the appropriate motor function to avoid these obsticles. ...
Abhishek's user avatar
2 votes
3 answers
475 views

Arduino ultrasonic sensor weird output

So I just got into arduino and bought Elegoo's car robot v3 kit and built it, but when I put the robot on "object avoidance" it constantly spins as though there is an object in front of it. I tried ...
Jordan's user avatar
  • 21
0 votes
2 answers
342 views

Help with Stair Lighting using HC-SR04 sensor and WS2812 LED Strip

Excuse my naivete in this as I am very new to Arduino and the programming of. I am trying to put together a project for stair lighting triggered by a ultrasonic sensor at the bottom of the stairs and ...
DapurDan's user avatar
1 vote
0 answers
885 views

HC-SRO4 always returns zero no matter what I do?

Wondering if it's the sensor or the code? can anyone help? I've used the code here /* HC-SR04 Ultrasonic Sensor with LCD dispaly HC-SR04 Ultrasonic Sensor VCC to Arduino 5V GND to Arduino GND ...
Tanish's user avatar
  • 11
0 votes
1 answer
278 views

Waking Arduino from sleep with an ultrasonic sensor

I have a parking guide using an ultrasonic sensor (HC-SR04), based on the instructions here. I'm trying to modify the code so that the Arduino goes to sleep after a certain period of inactivity (say, ...
Jim421616's user avatar
  • 188
-1 votes
1 answer
305 views

Why is my Arduino code for running a Bluetooth controlled robot with obstacle sensor not working as it should be?

I have created a Bluetooth based smartphone controlled robot (a 4 wheel car) earlier using Arduino and an obstacle avoidance robot. Now, I wanted to combine both of them. So, I combined their ...
Naved THE Sheikh's user avatar
0 votes
1 answer
73 views

Problems when attaching a second ultrasound sensor (HC SR04)

I am working on an obstacle avoiding robot. It uses an ultrasound sensor to avoid obstacles, but currently has trouble avoiding objects that are diagonal to it. Thus, i want to add a second ultrasound ...
Nick Heumann's user avatar
1 vote
2 answers
17k views

No headers (.h) found in Documents\Arduino\libraries\arduino_144469 with demo code

I followed this tutorial for a demo code for the SR04 ultrasonic distance sensor (without the LCD display). I've installed the Arduino IDE and wrote the code in it and saved it in some location. ...
Dame Lyngdoh's user avatar
0 votes
1 answer
572 views

HC-SR04 Echo Pin Fails To Go Low After Trigger Pulse

I have implemented an HC-SR04 distance sensor using an Arduino. After power up, the sensor operates well when objects are within range of the sensor. However, if the distance to be measured exceeds ...
BitBanger46's user avatar
-1 votes
1 answer
371 views

NodeMCU with HC-SR04 ultrasonic sensor

How can I interface an ultrasonic sensor with a MCU with 3.3 V GPIO like the NodeMCU? I tried powering the sensor with both 5 V and 3.3 V from the MCU. Both failed to show any results as the distance ...
maheshmt's user avatar
0 votes
1 answer
402 views

Problem with interrupts

Alright. This is what I wanted to do: Make a circuit and code the arduino such that there are 2 tactile switches, each with a predefined pwm value. Whenever any one button is pressed the led should ...
Kishore's user avatar
  • 35
0 votes
1 answer
293 views

Bending pins of HC-SR04 [closed]

I got a question regarding the ultrasound sensor (HC-SR04) connecting to the arduino. I have a project, and the space is really tight, so i will have to bend the pins of the HC-SR04. Is this okay to ...
user507237's user avatar
1 vote
1 answer
7k views

Getting 0 cm from ultrasonic sensor when nothing is in front

My Ultra sonic sensor (HC-SR04) is returning these types of values when it has nothing in front: Ping: 144cm Ping: 0cm Ping: 0cm Ping: 0cm Ping: 105cm Ping: 105cm Ping: 94cm Ping: 0cm Ping: 378cm ...
gpuguy's user avatar
  • 123
1 vote
1 answer
159 views

SdFat initialization blocks HC-SR04

I appreciate the help of this forum very much and it`s my first time to ask you experts befor driving crazy... ArduinoUno and SDcard-BreakOutboard and DistanceSensor HC-SR04 are not working well ...
Rob's user avatar
  • 13
1 vote
0 answers
133 views

HC-SR04 systematically finding a weird value

I have a HC-SR04 connected to my Arduino. its all working very nice. Yet with a constant interval a weird value appears (see the Serial Plot picture). I am wondering what causes this. I will soon ...
Anton van der Wel's user avatar
0 votes
1 answer
1k views

Strange discrete errors when reading HC-SR04 sonar sensor

I'm experimenting with an HC-SR04 sonar sensor. Basically I'm measuring the distance to a cardboard box twice a second with these lines of code running on an ESP32: unsigned long sonarMeasure() { ...
Falko's user avatar
  • 103
0 votes
2 answers
617 views

Communication between Arduino Uno and Mega

I am working on a project which uses a set of sensors (HC-SR04). These sensors use pins 2 to 13 of the Arduino Uno. Here you can find the board: . I also want to add an MP3 shield (VS1053B) to it ...
Majid Hojati's user avatar
2 votes
3 answers
8k views

Is my HC-SR04 sensor broken?

I am extremely new to Arduino and electrical engineering, and the project I am attempting involves a ultrasonic sensor. I am using the HC-SR04 with the Elegoo Mega2560 Arduino board. A few days ago ...
cr5519's user avatar
  • 23
1 vote
1 answer
418 views

Object Sensor on conveyor belt (want to record the data in EEPROM for testing)

void setup () pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(LED_Blue_pin, OUTPUT); pinMode(LED_White_pin, OUTPUT); Serial.begin(9600); digitalWrite(LED_Blue_pin, LOW); digitalWrite(...
Mecha hornbill's user avatar
1 vote
2 answers
5k views

JSN-SR04T-2.0 with NodeMCU not starts after reset or reconnect usb power

I have bought a NodeMCU (1.0) and a JSN-SR04T waterproof ultrasonic sensor compatible with HC-SR04. If I upload my program to NodeMCU it works but sometimes it measures a wrong distance - it is an ...
Dániel Kis's user avatar
2 votes
0 answers
230 views

Interference in readings

I have an project which control a heat exchanger. I read 4 temperature sensors DS18B20, a distance with HC-SR04 Ultrasonic Sensor, and a flow with YF-S201 (with attach interrupt). I can turn on and ...
FelipeFonsecabh's user avatar
2 votes
1 answer
258 views

Keep RTC time in a loop

I recently started a project with HC-SR04 sensors and RTC DS1302 clock. The idea is when a sensor detects an object, call and keep a timestamp (hh:mm:ss) all over the loop until Else If{} appears, ...
MGL1080's user avatar
  • 21
2 votes
2 answers
5k views

Ultrasonic HC-SR04 echo and trig pins

I am doing a watch with GPS tracker project. I am using an Ultrasonic HC-SR04 sensor. I don't know where to connect the Echo and trig pins with my Arduino. Please let me know how to connect it.
Nurul Nazerah's user avatar
2 votes
1 answer
187 views

Ultrasonic distance module works without connecting to gnd

I have a (HCSR04) ultrasonic distance module connected to arduino , i have connected all the four pins of the module properly and its working fine , then when i pull off the wire which is connected to ...
user8561793's user avatar
1 vote
2 answers
1k views

How do I make the HC-05 bluetooth module take data from the HC-SRO4, and then send it to my Android app?

Currently, I have an Arduino Uno set up, with a HC-SRO4 ultrasonic sensor printing distances of objects in front of it on a scale from 1-15 to the serial monitor. I want to attach the HC-05 bluetooth ...
Sanjiv Prasad's user avatar