How to Use ESP32 with HCSR04 Ultrasonic Sonar sensor and Arduino IDE

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 พ.ค. 2023
  • Affiliate Link for
    ESP32:- dir.indiamart.com/impcat/wifi...
    Boards Manager link-
    raw.githubusercontent.com/esp...
    Code and Circuit Diagram-
    github.com/harshkzz/ESP32-HCS...
    For any business queries contact us at inovatrixhelp@gmail.com
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 26

  • @nurhijran8287
    @nurhijran8287 7 หลายเดือนก่อน +1

    thanks man it works

  • @treditor1337
    @treditor1337 หลายเดือนก่อน

    its working fine sir, thanks a lot

  • @viniciusdemenezescosta9958
    @viniciusdemenezescosta9958 หลายเดือนก่อน

    thanks

  • @knowledge_seeker80
    @knowledge_seeker80 5 หลายเดือนก่อน

    By the way, after a research can get data from ultrasonic module just by using 2 wires by carry data over dc lines :)

    • @gonzaflex
      @gonzaflex 3 หลายเดือนก่อน +1

      can you share the link to read about?

  • @utmocanimations4136
    @utmocanimations4136 หลายเดือนก่อน

    I ran mine with a similar code, but it keeps sending me the Distance:0

  • @bostonmacosx
    @bostonmacosx 6 หลายเดือนก่อน +4

    This board iS 5V..... not great.

  • @UpskillwithAI
    @UpskillwithAI 2 หลายเดือนก่อน

    how do i open the link to see the code and circuit

    • @INOVATRIX
      @INOVATRIX  2 หลายเดือนก่อน

      All given in description.

  • @nurfatinsyazwinasaharbi5687
    @nurfatinsyazwinasaharbi5687 9 หลายเดือนก่อน +1

    why my distance just 0cm

    • @hajokijewski6415
      @hajokijewski6415 9 หลายเดือนก่อน +1

      Had the same issue - Ensure that you do not use pin 2 for something other e.g. build in LED. Move to 5/18 instead 2/4

    • @sisas2008
      @sisas2008 8 หลายเดือนก่อน

      amigo solo tienes que cambiar en el algoritmo #define echoPin 18 por #define echoPin 2 y #define trigPin 5 por #define trigPin 4 . ya que fisicamente en el esp32 estan en 2 y 4

  • @renzodamian724
    @renzodamian724 5 วันที่ผ่านมา

    IF YOU HAVE 0CM USE 5V instead of 3,3V!!!!!!!!!!!!!

  • @by_jhona
    @by_jhona 10 หลายเดือนก่อน

    O meu sensor ultrasonico hc sr04 nao está funcionando no 3.3v, sabe o que poderia resolver?

    • @INOVATRIX
      @INOVATRIX  10 หลายเดือนก่อน

      Connect power to VIN pin on the ESP32 Board.

    • @by_jhona
      @by_jhona 10 หลายเดือนก่อน

      @@INOVATRIX to receive the echo return, would there be damage to the esp32 input pin?

  • @hithushmohanaraja1133
    @hithushmohanaraja1133 หลายเดือนก่อน

    Will the same code work for esp8266?

    • @INOVATRIX
      @INOVATRIX  หลายเดือนก่อน +1

      Yes it should work, just make sure that you select the right pins.

    • @hithushmohanaraja1133
      @hithushmohanaraja1133 หลายเดือนก่อน

      @@INOVATRIX tysm!

    • @hithushmohanaraja1133
      @hithushmohanaraja1133 หลายเดือนก่อน +1

      The distance is always 0 cm. I am using a 3 3v esp8266. What is the issue?

  • @gonzaflex
    @gonzaflex 3 หลายเดือนก่อน

    distances under 40 cm can be measure without problem, more that that i just get random values. Any idea how solve it?

    • @INOVATRIX
      @INOVATRIX  3 หลายเดือนก่อน +1

      That is the approximate limit of the sensor. For more range you'll need to use more expensive and accurate sensor

    • @gonzaflex
      @gonzaflex 3 หลายเดือนก่อน +1

      i am using one HCSR04 with one Arduino Mega 2560 and can measure easily 2 mts in a water tank, but with ESP32 works bad, any idea?@@INOVATRIX

  • @NotHumant8727
    @NotHumant8727 5 หลายเดือนก่อน

    bad. It is not async and uses blocking functions. slow

  • @edwinawariyah6239
    @edwinawariyah6239 9 หลายเดือนก่อน +3

    Use this code instead and connect the VCC to VIN (Notice I changed the pins and the serial monitor baud)
    #include
    #define echoPin 18 // CHANGE PIN NUMBER HERE IF YOU WANT TO USE A DIFFERENT PIN
    #define trigPin 5 // CHANGE PIN NUMBER HERE IF YOU WANT TO USE A DIFFERENT PIN
    long duration, distance;
    void setup(){
    Serial.begin (115200);
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
    }
    void loop(){
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);

    duration = pulseIn(echoPin, HIGH);
    distance = duration / 58.2;
    String disp = String(distance);
    Serial.print("Distance: ");
    Serial.print(disp);
    Serial.println(" cm");
    delay(1000);
    }

    • @explorinOW
      @explorinOW 5 หลายเดือนก่อน

      Thank you so much. It works! But can you tell me the reason why you have thought to make this change & why was that one not working?