Questions tagged [hc-sr04]

For questions about the HC-SR04 ultrasonic ranging sensor.

Filter by
Sorted by
Tagged with
0 votes
1 answer
52 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 ...
  • 111
0 votes
1 answer
110 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 ...
  • 103
1 vote
0 answers
30 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 ...
  • 11
3 votes
1 answer
223 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 ...
1 vote
0 answers
34 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 ...
1 vote
1 answer
72 views

How do I get sensor values using transmitter and reciever

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 but I don't know how to see the ...
1 vote
0 answers
77 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 ...
  • 11
1 vote
0 answers
43 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 ...
1 vote
0 answers
192 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 ...
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 ...
3 votes
1 answer
389 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 ...
0 votes
1 answer
140 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'...
1 vote
0 answers
165 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 ...
  • 31
0 votes
1 answer
44 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 ...
1 vote
1 answer
1k 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 ...
0 votes
1 answer
162 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 ...
  • 252
0 votes
2 answers
1k 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'...
  • 13
1 vote
0 answers
73 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 ...
1 vote
3 answers
1k 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 ...
1 vote
0 answers
129 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 ...
0 votes
3 answers
2k 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 ...
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. ...
2 votes
3 answers
306 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 ...
  • 21
0 votes
2 answers
258 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 ...
1 vote
0 answers
733 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 ...
  • 11
0 votes
1 answer
215 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, ...
  • 188
-1 votes
1 answer
249 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 ...
0 votes
1 answer
67 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 ...
1 vote
2 answers
14k 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. ...
0 votes
1 answer
363 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 ...
-1 votes
1 answer
326 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 ...
0 votes
1 answer
312 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 ...
  • 35
0 votes
1 answer
204 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 ...
1 vote
1 answer
6k 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 ...
  • 123
1 vote
1 answer
143 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 ...
  • 13
1 vote
0 answers
129 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 ...
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() { ...
  • 103
0 votes
2 answers
535 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 ...
2 votes
3 answers
6k 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 ...
  • 23
1 vote
1 answer
392 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(...
1 vote
2 answers
4k 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 ...
2 votes
0 answers
213 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 ...
2 votes
1 answer
222 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, ...
  • 21
2 votes
2 answers
4k 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.
2 votes
1 answer
127 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 ...
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 ...
2 votes
3 answers
2k views

Convert from 3 V to 5 V

I'm new to Arduino, electronics, and this forum. I have made up a little project that connects an HC-SR04 ultrasonic range detector, and displays the distance on a 4 digit, 7 segment LED display. ...
  • 121
0 votes
1 answer
1k views

Trying to map a room with Arduino controlled bot [closed]

What you see above is a map of my room. The boxes in black are obstacles and the box in red is my bot. Now I want my bot to go around the room, avoiding all obstacles, but at the same time, covering ...
0 votes
1 answer
397 views

Arduino HC-SR04 water experiment

I am working on an experiment with the HC-SR04 sound sensor, and i am using it to record the speed of sound. I successfully measured the speed of sound in air, but when measuring it in water, I ...
  • 11
1 vote
1 answer
1k views

How do I use ultrasound to track a moving object?

I'm trying to create a small scale, dumb-downed version of the pitch tracking systems used to detect the speed and direction of baseballs. I'm currently working with an HC-SRO4 sensor and an Arduino, ...