Ultrasonic Distance Sensor Using ATOM Matrix ESP32

by RonFrtek in Circuits > Arduino

367 Views, 1 Favorites, 0 Comments

Ultrasonic Distance Sensor Using ATOM Matrix ESP32

Ultrasonic Distance Sensor Using ATOM Matrix ESP32

In this Tutorial we are going to explore how to measure a distance using the ATOM Matrix ESP32 and Ultrasonic Range sensor. If there is no obstacle a Green light will glow and if obstacle is detected a Red light will glow.

Watch the video!

What You Will Need

2022-07-27_11-05-19.jpg
images (10).jpg
sku_416860_1.jpg
VisuinoAdvrtisemenESPNowESP32C3-1.jpg
F5OFEUQJJ4ZYFKY.LARGE.jpg

The Circuit

2023-02-11_16-12-38.png
atom-matrix.png
  • Connect Ultrasonic sensor pin [VCC] to Atom Matrix pin [5V]
  • Connect Ultrasonic sensor pin [GND] to Atom Matrix pin [GND]
  • Connect Ultrasonic sensor pin [Trig] to Atom Matrix pin [G21]
  • Connect Ultrasonic sensor pin [ECHO] to Atom Matrix pin [G25]


Start Visuino, and Select the Atom Matrix Board Type

select-board-uno.jpg
F8NV60VLC0J1232.jpg

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 "Atom Matrix" as shown on Picture 2

In Visuino Add Components

FDNXV6WL0FAEFHO.jpg
FVMEGXSL0FAEFIC.jpg
2023-02-11_16-45-41.png
2023-02-11_16-46-18.png
  • Add "Ultrasonic Ranger" component
  • Add "Compare Analog Value" component
  • Add "Detect Edge" component
  • Add "Color Value" component

In Visuino Set Components

F75NY9FLC0J12WY.jpg
2023-02-11_16-48-49.png
2023-02-11_16-49-07.png
2023-02-11_16-51-43.png
2023-02-11_16-53-33.png
2023-02-11_16-54-29.png
2023-02-11_16-54-47.png
2023-02-11_16-55-02.png
  • Select "M5 Stack ATOM Matrix" board in the properties window expand "Modules">"RGB Matrix">"Elements" and click on the 3 dots button
  • In the "Elements" window drag "Fill Screen" to the left side and in the properties window select "Color" and click on the Pin Icon and select "Alpha Color SinkPin"
  • Close the "Elements" window
  • Select "CompareValue" and in the properties window select "Compare Type" to ctBigger and "Value" to 5 <<this is the distance to detect obstacle, you can adjust this number if you want
  • Select "DetectEdge1" and in the properties window set "Rising" to False


  • Double click on the "ColorValue1" and in the Elements window :
  1. drag "Set Value" to the left side and in the properties window set "Color" to clGreen
  2. drag another "Set Value" to the left side and in the properties window set "Color" to clRed
  • Close the Elements window

In Visuino Connect Components

2023-02-11_17-03-27.png
uz-at.png
  • Connect "M5 Stack ATOM Matrix" pin [GPIO 25] to "UltrasonicRanger1" pin [Echo]
  • Connect "UltrasonicRanger1" pin[Ping] to "M5 Stack ATOM Matrix" pin [GPIO 21]
  • Connect "UltrasonicRanger1" pin[Out] to "CompareValue1" pin [In]
  • Connect "CompareValue1" pin [Out] to "DetectEdge1" pin [In]
  • Connect "CompareValue1" pin [Out] to "ColorValue1" > "Set Value1" pin [In]
  • Connect "DetectEdge1" pin [Out] to "ColorValue1" > "Set Value2" pin [In]
  • Connect "ColorValue1" pin [Out] to "M5 Stack ATOM Matrix" > "Fill Screen1" pin [Color]
  • Connect "ColorValue1" pin [Out] to "M5 Stack ATOM Matrix" > "Fill Screen1" pin [Clock]


Generate, Compile, and Upload the Arduino Code

F3TR3PYLC0J17O5.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 ATOM Matrix module The Display will start to show Green color and you can put an obstacle in front of the Ultrasonic module the display will show a Red color.

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