Zio Ultrasonic Distance Sensor Qwiic Start Guide
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
- Zio Ultrasonic Sensor Overview
- Configuring your Ultrasonic Sensor
- Connection Setup
- Testing Example Codes
Zio Ultrasonic Sensor (HC-SR04) Overview
- Ultrasonic Receiver Module (Echo)
- Ultrasonic Transmitter Module (Trigger)
- Power and Signal Pins
- Power Pins:
- GND - Ground Supply
- 3V3 -3.3V Supply
- Signal Pins:
- Trig- Trigger Input Signal (Transmit Signal)
- Echo - Echo Output Signal (Receive Echo)
- Power Pins:
- STM8L051 MCU:
- 8-bit ultra-low power STM8 MCU Core with I2C and SPI interface
- Qwiic Connector:
- 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
- Zuino M Uno
- Zio Qwiic Ultrasonic Distance Sensor (HC-SR04)
- Zio Qwiic 0.91" OLED Display (Optional)
- Qwiic Cable (100mm)
- Micro USB Cable
- Powerbank (Optional)
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)
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