EG254S: IoT System Project - Sensors Sensors

Wiring HC-SR04 Ultrasonic Sensor to ESP8266

 We are going to wire the Adafruit HUZZAH ESP8266 with the HC-SR04 Ultrasonic Sensor. Before we proceed, we’ll look at the Adafruit Feather HUZZAH ESP8266 choices of GPIO pins available.

Adafruit Feather HUZZAH ESP8266 GPIO pins

(Reference: https://learn.adafruit.com/adafruit-feather-huzzah-esp8266/pinouts)

This breakout has 9 GPIO: #0, #2, #4, #5, #12, #13, #14, #15, #16 arranged at the top edge of the Feather PCB.

These pins are general purpose and can be used for any sort of input or output. Most also have the ability to turn on an internal pullup. Many have special functionality:

GPIO #0, which does not have an internal pullup, and is also connected a red LED. This pin is used by the ESP8266 to determine when to boot into the bootloader. If the pin is held low during power-up it will start bootloading! That said, you can always use it as an output, and blink the red LED - note the LED is reverse wired so setting the pin LOW will turn the LED on.

GPIO #2, is also used to detect boot-mode. It also is connected to the blue LED that is near the WiFi antenna. It has a pullup resistor connected to it, and you can use it as any output (like #0) and blink the blue LED.

GPIO #15, is also used to detect boot-mode. It has a pulldown resistor connected to it, make sure this pin isn't pulled high on startup. You can always just use it as an output

GPIO #16 can be used to wake up out of deep-sleep mode, you'll need to connect it to the RESET pin

Also note that GPIO #12/13/14 are the same as the MISO/MOSI/SCK 'SPI' pins!

Connections

The connections are very simple:

HC-SR04 Ultrasonic Sensor pin

Adafruit Feather HUZZAH ESP8266 GPIO pin

Vcc

3V

Trig

12

Echo

13

Gnd

GND

You can actually connect Trig and Echo to whichever pins you want, 12 and 13 are just the ones I'm using.

Note: Since, GPIO #12 and #13 are chosen, MOSI and MISO ‘SPI’ pins are not to be used to avoid conflicts.

 

Schematics

Follow the schematic diagram to wire the HC-SR04 ultrasonic sensor to the Adafruit Feather HUZZAH ESP8266.