Example Code for Using the External I2C Sensor

Last revision 2026/01/06

This guide offers a detailed walkthrough on using an external I2C sensor with the UNIHIKER M10, including hardware and software setup, wiring diagrams, and sample Python code for the URM09 Ultrasonic Distance Sensor to measure distances efficiently.

Hardware Preparation

Software Preparation

According to the Getting Started section in the UNIHIKER official documentation, it is recommended for beginners to operate according to the instructions in the Mind+ section. [Click to view]

The main process is: download and install MInd+ on your PC, open Mind+, switch to Python mode and Code page, click on the icon in front of Terminal, open the Connect Remote Terminal menu, and then connect the UNIHIKER. After that, you can create a new py file in the File System, write code and run.

Mind+ interface diagram

Wiring Diagram

Wiring Diagram

Sample Code

#  -*- coding: UTF-8 -*-
# MindPlus
# Python

import time
from pinpong.board import Board
from pinpong.libs.dfrobot_urm09 import URM09

Board().begin()

ult1 = URM09(0x11)
ult1.set_mode_range(ult1._MEASURE_MODE_AUTOMATIC, ult1._MEASURE_RANG_500)

while True:
    print((str("Distance:") + str(ult1.distance_cm())))
    time.sleep(1)

Result

The distance data of the ultrasonic sensor is printed in the terminal.

Result image

Was this article helpful?

TOP