Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [hc-sr04]

For questions about the HC-SR04 ultrasonic ranging sensor.

0
votes
1answer
15 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
0answers
28 views

HC-SR04 time how long an object is in range

I need help trying to figure out how long an object stays in front of the sensor in in a specified range, for example, if an object is in within range of 10cm and 200cm I start a timer, the moment ...
0
votes
1answer
89 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 ...
0
votes
1answer
51 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
1answer
701 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 ...
1
vote
1answer
55 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 ...
0
votes
0answers
58 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
1answer
369 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() { ...
0
votes
2answers
257 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
3answers
1k 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 ...
1
vote
1answer
164 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(...
0
votes
2answers
2k 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 ...
1
vote
0answers
94 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
1answer
132 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, ...
3
votes
2answers
3k 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.
1
vote
1answer
56 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
2answers
736 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
3answers
942 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. ...
0
votes
1answer
451 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
0answers
91 views

hc-sr04 water experiment. - ignoring first set of data

Im working on an experiment where I where i need to measure the speed of sound in water. I am using the hc-sr04 sound sensor to gather data, but I have run into a problem where the water reflects some ...
0
votes
1answer
228 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 ...
1
vote
1answer
595 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, ...
0
votes
1answer
366 views

HC-SR04 pulse at multiple angles

I have a HC-SR04 sensor mounted on a stepper motor, mounted on a car. The idea is this: The car moves forward with the ultrasonic sensor facing the front If the sensor reads a small distance the car ...
3
votes
2answers
800 views

HC-SR04 distance measuring without delay?

I am using the HC-SR04 ultra sound sensor for Arduino. I have used the following code to calculate distance and it works perfectly. long duration; digitalWrite(trigger, LOW); ...
1
vote
0answers
2k views

Turn on one by one the LEDs of a Neopixel rgb LEDs strip for each detection at the same distance from an Ultrasonic Distance Sensor (HC-SR04)

For this project I seek to create a counter of water glasses we drank throughout the day. I use for this an Arduino UNO card, a Piezo buzzer and a Neopixel rgb LEDs strip (5 LEDs for this test). ...
4
votes
1answer
966 views

Using multiple HC-SR04: sharing trigger pin and interference between HC-SR04

If I have four HC-SR04 detectors, can they share the same trigger pin on the Arduino? This would reduce the number of pins needed from eight to five. Even if they can share the same trigger, maybe ...
0
votes
1answer
867 views

Arduino + UltraSensor - Serial Monitor outputs garbage

I am trying to connect an HC-SR04 to an Arduino Uno. For some reason when I run this code on the serial monitor it outputs wingdings in a straight line. ýòøÿüÿøÿüòý÷ÿ÷ýÿÿúýÿýúÿòý÷ûòûòû÷ýÿøÿøÿÿ÷...
1
vote
3answers
525 views

Arduino with 2 echo sensors

For a project I'm doing I need the Arduino to be connected to two echo sensors (I have the HC-SR04). Currently I have 4 sensors that I can use, but I will need only 2 or 3. I have almost no knowledge ...
1
vote
1answer
509 views

How to make battery last for months?

I have a simple circuit: detect that a person is walking towards the circuit (with HC-SR04), measure distance, light diodes (a wave effect) according to that distance – the closer, the faster the led ...
0
votes
2answers
3k views

Alternative distance-meter, HC-SR04 doesn't work very well

On door to my room there is HC-SR04 that triggers led-wave. The shorter the distance, the faster the led-wave (8 leds). The circuit works fine in synthetic tests – moving hand or flat object towards ...
3
votes
1answer
170 views

Simultaneous output from sonar array

I am working on a project that records the elevation changes of a 1 foot wide section using sonar distance measurement. I have 10 HC-SR04 sensors arranged in a straight line over this 1 foot section. ...
0
votes
2answers
1k views

How to turn a LED if ultranonic HC-SR04 reading is on defined range for some interval

My objective is if ultrasonic readings ranging between 1 to 10 cm and no distance change for 10 seconds or more, a LED will turn on. Here is my current code. #define trigPin 7 #define echoPin 8 #...
0
votes
2answers
2k views

HCSR04 Sensor without delay

I've made a code to make a stepper work together with a HCSR04 sensor. The problem here is that the sensor has to use a delay in order to work. This delay messes with the smootness of the stepper. ...
1
vote
2answers
2k views

Transmitting Variables over RF

I'm using the 3715 RF arduino modules and a hc-sr04, and i'm trying to send the distance i get from the ultrasonic over to the arduino with the rf recieving module but i get something like this: ...
3
votes
1answer
3k views

How can I replace pulseIn with interrupts?

I have an HC-SR04 sensor and I need to get the distance from it. I use this code: digitalWrite(trig, LOW); delayMicroseconds(2); digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, ...
1
vote
3answers
946 views

Why does HC-SR04 return 0s in this sketch

I am building a robot with multiple sensors, abilities etc. Since I had a bug with a HC-SR04 rotated by a servo, I experimented in a different sketch. If the distance is less than 30cm, the servo ...
1
vote
2answers
2k views

How often can I ping an HC-SR04 ultrasonic sensor?

In my current project, I want the sensor to be continuously scanning for a value of less than 30cm. I was wondering how long of a delay I need (if any) between each call of the ping function. It ...
1
vote
1answer
108 views

How come my code does not wait for a specific time before going into an if statement?

I have an HC-SR04 attached to a servo. When the 90 degree reading is less than 30 cm, I want the motor to take 2 seconds to turn to 130 degrees, get a measurement on the right, and turn back to 90 ...
1
vote
2answers
285 views

Multiple HC-SR04 with one 5v 7805 regulator

I am working on a autonomous track vehicle. I have mounted 3 HC-SR04 sensors 1 Sharp infrared distance sensor 3 infrared led distance sensors 1 Arduino Mega 2560 1 H-bridge Board HG7881 I am ...
0
votes
1answer
20 views

Sketch not running as expected

I wrote this sketch along with an HC - SR 04 Ultrasonic transducer and a DC motor. Whenever the HC-SR 04 reads any distance less than 15 cm, the motor stops, otherwise it keeps running. The problem ...
0
votes
1answer
517 views

Using HC-05 to play a sound on an app

I connected a HC-SR04 Ultrasonic Sensor to Arduino Uno and built the circuit as shown in the link below. I also used the code below the link. Together, this code and the circuit detect any motion that ...
0
votes
2answers
68 views

Is it possible to connect 2 ultra sonic sensors to 1 arduino?

I am currently using the Arduino Pro Micro board and I want to connect 2 ultrasonic sensors to 1 board, whilst knowing which sensor is being triggered. The sensor I am using is a HC-SR04 Ultrasonic ...