Zio Ultrasonic Distance Sensor Qwiic Start Guide

30/01/2019

This post is part of our Zio Qwiic Start Guide Blog Series.

 

Introduction

 

The ultrasonic distance sensor is useful for applications that need effective measures to sense nearby objects and distance. Commonly embedded in robots to sense collisions. 

 

Table of Contents

  1. Zio Ultrasonic Sensor Overview
  2. Configuring your Ultrasonic Sensor
  3. Connection Setup
  4. Testing Example Codes

 

 

Zio Ultrasonic Sensor (HC-SR04) Overview

 

 

  1. Ultrasonic Receiver Module (Echo)
  2. Ultrasonic Transmitter Module (Trigger)
  3. Power and Signal Pins
    1. Power Pins: 
      1. GND - Ground Supply
      2. 3V3 -3.3V Supply
    2. Signal Pins: 
      1. Trig- Trigger Input Signal (Transmit Signal)
      2. Echo - Echo Output Signal (Receive Echo)
  4. STM8L051 MCU: 
    1. 8-bit ultra-low power STM8 MCU Core with I2C and SPI interface
  5. Qwiic Connector:
    1. A system to easily connect to other qwiic compatible modules via Qwiic cable


Configuring your Ultrasonic Distance Sensor (HC-SR04)

 

 Difficulty Level: 


Helpful Resources:

This qwiic guide has a separate post on our development board guides. Check them out below:


Connection Set up

 

Hardware & Components

 


Setup


Testing Example Codes

We are going to demo our Ultrasonic Distance Sensor using the following example codes. The following examples work with our Zio development boards. Just select the right board and port from the  Arduino IDE platform.

 


1. HC-SR04 I2C Example Code

 

Step 1 Download and Install the following libraries for OLED display. 

 

We also created a separate qwiic guide for our Zio 0.91” OLED Display. Check it out here!

 

Step 2 Download the following example code for Zio Ultrasonic Distance Sensor.

 

Download the example code from our Github page.

Extract and open the downloaded folder. Go to Arduino > Zio_Ultrasonic_Distance_Sensor_IIC_Test



Step 3 View Results

Open Serial Monitor to view results using a serial monitor.

 

Results on Zio 0.91" OLED Display

 

 

 

Got questions or suggestions? Or just want to greet us? Drop us a comment below!

 

 

1 Comment(s)

Moussa:
01/07/2019, 08:23:47 PM
Reply

Hi;I am interested to buy the full kit to test the HC-SR04 sensor. I appreciate all the help to get such a kit.HC-SR04 specifies a detection range from 2cm to 400cm with accuracy of 3mm. Do you have anything that can detect down to 0.5cm or 1cm ?Our detection range requirement is 0--20cm with accuracy of 2mm (prefered) or 5mm as worst case.Thanks; Moussa Iskandar Varian Medical Systems

Leave a Comment