Introduction: DIY Distance Meter With OLED Display

In this tutorial we will be building a digital distance meter that will output the values on an OLED display. For this project you can choose to use an ardiuno or an ESP8266 module and I will provide code for both of them. If you are using an ESP8266 for the first time please check out my tutorial about this module. The outline of this program is the HC-SR04 distance sensor will send its reading to the microcontroller (arduino or ESP8266) and then the microcontroller will output this value to the display. So lets get started.

Supplies

For this tutorial you will need the following components:

Step 1: Circuit Wiring

Follow the schematics and the table for the wiring of the arduino or ESP8266.

PINArduinoESP8266VCC (distance sensor)5V5VTRIG13D6ECHO12D5 GND (distance sensor)GNDGNDVDD (OLED display)3.3V3.3VGND (OLED display)GNDGNDSCKA5D1SDAA4D2

Step 2: Install Adafruit OLED Library

Follow the following steps to install the OLED library:

  1. Open the Arduino IDE and go to Sketch > Include Library > Manage Libraries
  2. Now that the library manager window is open, search "SSD1306"
  3. Select the one that has the title "Adafruit SSD1306 by Adafruit"
  4. Click install
  5. The library should now be installed and you can now go onto programming

Step 3: Programming

This is the link for both of the arduino IDE files for the ESP8266 and the arduino. The code has comments which explain the function of each line.

Step 4: You Finished!

You should now see the distance displayed on the OLED display. Thank you for reading and please checkout my other tutorials.