Questions tagged [hc-sr04]

For questions about the HC-SR04 ultrasonic ranging sensor.

The HC-SR04 is an ultrasonic ranging sensor capable of measuring distances in the range 2cm to 400cm. It has a ranging accuracy that can reach up to 3mm under ideal conditions. The HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit.

The HC-SR04 module has four pins: VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground).

78 questions
3
votes
1 answer

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 is determined by emitting a signal from one…
3
votes
1 answer

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 ultrasonic sensor is being powered from a 5V source and…
3
votes
1 answer

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 this doesn't make sense because the emitted signal…
Jon
  • 31
  • 1
  • 2
3
votes
1 answer

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, LOW); duration=pulseIn(echo, HIGH,…
shurup
  • 300
  • 1
  • 8
  • 21
3
votes
0 answers

(Arduino + official GSM shield + ultrasonic HC-SR04 sensor) inaccurate measuring

I'm using an Arduino Uno, 1.0.5 r2 version of the IDE with and ultrasonic HC-SR04 sensor for measuring a tank water level. I want to send the data obtained over internet using the official arduino GSM shield sending them on the plot.ly servers with…
em1lio189
  • 31
  • 2
2
votes
1 answer

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 value readings from the (BOARD1) in the serial…
2
votes
3 answers

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 changing the code and had no luck so I thought…
Jordan
  • 21
  • 4
2
votes
3 answers

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 I was able to print out the distance correctly…
cr5519
  • 23
  • 1
  • 4
2
votes
0 answers

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 off a monophasic motor with Arduino too. I have…
2
votes
1 answer

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, but I don't know how to. #include…
MGL1080
  • 21
  • 2
2
votes
2 answers

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
  • 21
  • 1
  • 2
2
votes
1 answer

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 ground in arduino , the module works totally…
2
votes
3 answers

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. When I have it plugged into my laptop for power, it…
nedlud
  • 121
  • 4
2
votes
3 answers

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); delayMicroseconds(2); digitalWrite(trigger, HIGH); …
Don Grey
  • 71
  • 1
  • 4
2
votes
0 answers

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). Aside from the last 2 LEDs that only light up to…
Thibaut
  • 21
  • 1
  • 3
1
2 3 4 5 6