An archive of as of Saturday January 26, 2019.

Esquilo Air & HC-SR04 + 1602 LCD Tutorial


Esquilo Air & HC-SR04 + 1602 LCD Tutorial

Made by Leeland Heins

About this project

This is a simple example setup to show how to hook an HC-SR04 Ultrasonic Sensor and an 1602A LCD panel up to an Esquilo Air.

Project info
Difficulty: Eas
Estimated time: 1 hour

This project builds on my previous two which featured each of these parts connected separately to an Esquilo Air. In this project we combine both parts with the data from the HC-SR04 Ultrasonic Sensor being output to the 1602A LCD panel as well as part of the code being re-written to use the new Ultrasonic library which I have ported from Arduino to the Esquilo

If you are interested in more detail about these two parts please reference the previous tutorials or there is a ton of information on-line.

Step 1: Parts List

1 Esquilo Air
1 HC-SR04 Ultrasonic Sensor
1 1602 LCD
1 10k Potentiometer
1 Breadboard
20 Male-Male hookup wires. It is nice to make them color coordinated.

I used:
5 red
5 black
2 white
3 orange
1 yellow
2 green
2 blue

Step 2: Connect the components

Connect the components and wires as shown in the pictures.

Step 3: Load the code into the IDE

// HC-SR04 Ultrasonic Range Finder output to 1602A LCD



local hcsr04 = Ultrasonic(13, 1, 0); // GPIO 13, PWM 1 Channel 0

local distance;

// 4 bit mode, rs = GPIO 12, enable = GPIO 11, data = GPIO 5, 4, 3, 2
local lcd = LiquidCrystal(0x00, 12, 0, 11, 5, 4, 3, 2, 0, 0, 0, 0);

// set up the LCD's number of columns and rows:
lcd.begin(16, 2, 0);

while (true) {
echoPin.arm(0, CAPTURE_EDGE_RISING);
distance = hcsr04.Ranging(hcsro4.CM);
//print("distance=" + distance);
// Print a message to the LCD.
lcd.print("distance=" + distance);

The libraries can be found here:

Step 4: Run the nut