Seeeduino XIAO Expansion Board Ultrasonic Distance Sensor With Sound Warning - Arduino

by RonFrtek in Circuits > Arduino

212 Views, 0 Favorites, 0 Comments

Seeeduino XIAO Expansion Board Ultrasonic Distance Sensor With Sound Warning - Arduino

Seeeduino XIAO Expansion Board Ultrasonic Distance Sensor With Sound Warning

In this Tutorial we are going to explore how to measure a distance using a Seeeduino XIAO Expansion board and Ultrasonic Range sensor.

Watch the video!

What You Will Need

XIAO-EXPANSION.jpg
seeeduino-xiao-all-front_1_SAhS8Yn6jy.jpg
ultrasonic-sensor-hc-sr04-500x500.jpg
VisuinoAdvrtisementNewDesign1.jpg
FEGPLRJKK5FQW91.jpg
  • HC-SR04 Ultrasonic Range Measurement Module
  • Seeeduino XIAO Expansion board
  • Seeeduino XIAO
  • Jumper wires
  • Visuino program: Download Visuino

About Seeeduino XIAO

Seeeduino-XIAO-I2C-pins.jpg
Seeeduino XIAO demo | Smallest Arduino Compatible Board
Grove - TDS Sensor Demo with Seeeduino XIAO
  • Powerful CPU: ARM® Cortex®-M0+ 32bit 48MHz microcontroller(SAMD21G18) with 256KB Flash,32KB SRAM
  • Flexible compatibility: Compatible with Visuino & Arduino IDE
  • Easy project operation: Breadboard-friendly
  • Small size: As small as a thumb(20x17.5mm) for wearable devices and small projects.
  • Multiple development interfaces: 11 digital/analog pins, 10 PWM Pins, 1 DAC output, 1 SWD Bonding pad interface, 1 I2C interface, 1 UART interface, 1 SPI interface.

Typical Application

  • Wearable devices
  • Rapid prototyping (directly attached to the expanded PCB as a minimal system)Perfect for all the projects need mini Arduino
  • DIY keyboard
  • USB development (USB to multi-channel TTL/USB host mode, etc.)
  • A scenario where you need to read multiple mock values The DAC output

The Circuit

2022-03-07_9-35-41.jpg
xiao-expansion-board_orig.png
  • Place the Seeeduino XIAO on the Expansion board
  • Connect Ultrasonic sensor pin [VCC] to Expansion board pin [5V]
  • Connect Ultrasonic sensor pin [GND] to Expansion board pin [GND]
  • Connect Ultrasonic sensor pin [Trig] to Expansion board digital pin [0]
  • Connect Ultrasonic sensor pin [ECHO] to Expansion board digital pin [1]

Start Visuino, and Select the Seeeduino XIAO Board Type

F3UOF8GKU2NWUE7.jpg
FLYKYANKU2NWUE6.jpg

The Visuino: https://www.visuino.eu also needs to be installed. Download Free version or register for a Free Trial.

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Seeeduino XIAO" as shown on Picture 2

In Visuino Add,Set & Connect Components

2022-03-06_20-37-29.jpg
2022-03-06_20-40-35.jpg
2022-03-06_20-38-27.jpg
2022-03-06_20-41-34.jpg
2022-03-06_20-44-14.jpg
2022-03-06_20-38-47.jpg
2022-03-06_20-46-24.jpg
2022-03-06_20-46-46.jpg
2022-03-06_20-47-13.jpg
2022-03-06_20-52-57.jpg
2022-03-06_20-58-20.jpg
2022-03-06_20-57-10.jpg
2022-03-06_20-59-27.jpg
yi.png
  • Add "Ultrasonic Ranger" component
  • Add "Analog Multi Source" component
  • Add "OLED I2C" component
  • Add "Compare Analog Value" component
  • Add "Play Frequency Tone" component
  • Select "AnalogMultiSource1" and in the Properties window set "Output Pins" to 3
  • Select "CompareValue1" and in the Properties window set "Compare Type" to ctSmaller and "Value" to 5

This means that the Piezo will beep if the distance is less than 5cm

  • Select "PlayFrequency1" and in the Properties window select "Enabled" and click on the Pin Icon and select "Boolean SinkPin" and set "Initial Frequency (Hz)" to 15

Double click on the "DisplayOLED1" and in the "Elements" window:

  • Drag "Draw Text" to the left & in the properties window set "Size" to 2 and "Text" to Distance
  • Drag "Text Field" to the left & in the properties window set "Size" to 3 and "Y" to 30
  • Close the "Elements" window
  • Connect "Seeeduino XIAO" Digital pin [1] to "UltrasonicRanger1" pin [Echo]
  • Connect "UltrasonicRanger1" pin[Ping] to "Seeeduino XIAO" Digital pin [0]
  • Connect "UltrasonicRanger1" pin[Out] to "AnalogMultiSource1" pin [In]
  • Connect "AnalogMultiSource1" pin [0] to "CompareValue1" pin[In]
  • Connect "AnalogMultiSource1" pin [1] to "DisplayOLED1" > "Text Field1" pin [In]
  • Connect "AnalogMultiSource1" pin [2] to "DisplayOLED1" > "Text Field1" pin [Clock]
  • Connect "CompareValue1" pin [Out" to "PlayFrequency1" pin [Enabled"
  • Connect "PlayFrequency1" pin [Out" to "Seeeduino XIAO" Digital pin [3]
  • Connect "DisplayOLED1" I2C Pin [Out] to "Seeeduino XIAO" I2C Pin [In]"

Generate, Compile, and Upload the Arduino Code

FNVR54JKU2NWWJK.jpg

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Play

If you power the Seeeduino XIAO module, the Display will start to show Ultrasonic distance of the objects. If the object is closer than 5cm a piezo will start to beep.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Tutorial, you can download it and open it in Visuino: https://www.visuino.eu

Troubleshooting

2022-03-06_21-45-07.jpg

If Port is not detected in Visuino when you try to upload the code do a reset

Press quickly 2X "Reset" button on the XIAO Expansion board