In this example we connect a US-025 ultrasonic sensor to an Adafruit Feather M0 running Circuitpython
US-025 is an upgraded version of the HC-SR04, with a kind of high performance, low cost ultrasonic module. The module uses the CS100 , a high performance-cost ratio ultrasonic ranging chip.

First lets look at some information about the sensor from the manufacturer
Description
| 
 Electrical parameters  | 
 US-025, US-026 Ultrasonic ranging module  | 
| 
 Operating Voltage  | 
 DC 3V-5.5V  | 
| 
 Working current  | 
 5.3mA  | 
| 
 Operating temperature  | 
 -40°C-85°C  | 
| 
 output method  | 
 GPIO  | 
| 
 Induction angle  | 
 Less than 15 degrees  | 
| 
 Detection distance  | 
 2cm-600cm  | 
| 
 Detection accuracy  | 
 0.1cm+1%  | 
The high-performance, low-cost ultrasonic ranging module introduced by the module; the module adopts the cost-effective ultrasonic ranging chip CS100 the ranging is up to 6 meters, the ranging accuracy is high; the measurement consistency is good, the distance measurement Stable and reliable.
US-025/US-026The ultrasonic ranging module can realize non-contact ranging function of 2cm~6m, working voltage is 3V-5.5V, working current is 5.3mA, support GPIO communication mode, and work stably and reliably.
US-025 has the Same performance as US-026, the same size and the same principle.
the differences between the US-025 and the US-026 are:
- US-025 – The PCB is double sided, and the US-026 is single sided
 - US-025 – The 4 Pin pin header is soldered on the front side (the probe side), the US-026 is a single panel, the front side (the probe side) has no pad, and the pad is soldered on the back side (chip side).
 
Parts Required
| Name | Link | 
| Adafruit Feather M0 Express | Adafruit (PID 3403) Feather M0 Express – Designed for CircuitPython – ATSAMD21 Cortex M0 | 
| US-025 ultrasonic sensor | 1pcs US-025 US-026 ultrasonic ranging sensor module | 
| Connecting cables | Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire | 
Schematic/Connection
The Ultrasonic sensor has four terminals – +5V, Trigger, Echo, and GND connected as follows
- Connect the +5V pin to +3.3v on your Adafruit Feather board.
 - Connect Trigger to digital pin 5 on your Adafruit Feather board.
 - Connect Echo to digital pin 6 on your Adafruit Feather board.
 - Connect GND with GND on Adafruit Feather.
 

feather and us-026
Code Example
I used Mu for development, you can use the HCSR04 library
The following is based on a library , I copied the adafruit_hcsr04.mpy to the lib folder on my Feather M0 Express – https://circuitpython.org/libraries
[codesyntax lang=”python”]
import time
import board
import adafruit_hcsr04
sonar = adafruit_hcsr04.HCSR04(trigger_pin=board.D5, echo_pin=board.D6)
while True:
    try:
        print((sonar.distance,))
    except RuntimeError:
        print("Retrying!")
    time.sleep(0.1)
[/codesyntax]
Output
Here is what I saw in Mu REPL window
(5.066,)
(5.185,)
(4.658,)
(3.281,)
(3.349,)
(5.083,)
(3.774,)
(3.332,)
Links




