In this illustration we will going to wire the ESP8266 12E nodeMCU with Ultrasonic Raging Sensor HCSR04. As you can see the illustration below the sensor trigger pin is connected to D1 which is pin 5 in Arduino Board, and the ECHO is connected to D2 which is pin 4 in Arduino Board. However in the sketch code we are going to use the Arduino IDE to program the NodeMCU ESP8266 12E Development board if you to have a interpreter in your Arduino IDE please refer to this link.

Hardware Required

  • NodeMCU ESP8266 12E Development Board
  • HCSR04 Ultrasonic Raging Sensor
  • Jumper Wires & DuPont Wires
  • Solderless Breadboard

Wiring Diagram

Ultrasonic-HCSR04-NodeMCU-Schematics-Diagram

Test Code

 

Wiring ESP8266 nodeMCU with HCSR04 Ultrasonic Sensor
Facebooktwittergoogle_plusredditpinterestmail
Tagged on:                 

7 thoughts on “Wiring ESP8266 nodeMCU with HCSR04 Ultrasonic Sensor

  • at
    Permalink

    HC-SR04 is a 5V device, anybody????? this circuit might work (sometimes) but it is simply wrong

    Reply
    • at
      Permalink

      There are also models which work within a range of 3.3V-5V (marked as HC-SR04+ on the backside)

      Reply
    • at
      Permalink

      use HC-SR04P as it has a wide range of operating voltage, 3-5.5V.

      Reply
  • at
    Permalink

    ese sensor no funciona bien con 3.3v.
    ese lo tienes que alimentar con 5v forzosamente para que opere adecuadamente, y si funcionará con ese código pero, quizás eches a perder las GPIO si no haces la correcta acoplación de niveles lógicos.
    si no quieres batallar usa el MAXBOTIX EZ-03

    the sensor does not work well with 3.3v.
    that you have to feed 5v necessarily to operate properly, and if it will work with that code but perhaps fuck off the GPIO if you do not the right coupled logic levels.
    if you do not want troubles you most use the EZ-03 MAXBOTIX

    Reply
  • at
    Permalink

    I can confirm this code and wiring works with a logic level converter between the ESP8266 and nodeMCU. gives pretty accurate distance results

    Reply
  • at
    Permalink

    Alguien me dice si ese codigo realmente hara que mi sensor me de los datos en centi!etros o que hace ese codigo(soy nuevo) y como se si el sensor ocupa los 5 v o solo la energia fel nodemCU

    Reply
    • at
      Permalink

      Hay un cierto error en el diagrama arriba, usted necesita 5v que puede ser engancha para arriba en el usb micro cercano, antes de que usted vaya a hacer esto, lo hace seguro su fuente de NodeMCU es 5v así que usted puede conseguir 5v hacia fuera del micro USB Luego conéctelo en el Sensor VCC, GROUND (tierra común), ECHO, TRIG. 🙂 or you can use Logic Level.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *