Your shopping cart is empty!
![Read Sensor Value Read Sensor Value](https://static.cytron.io/image/tutorial/get-started-motion-2350-pro-circuitpython-read-sen/10.-read-sensor-value.png)
Read Sensor Value
- Hao Zhen Goh
- 08 Aug 2024
- Tutorial
- Beginner
- 156
This guide will show you how to read the analog and digital sensor value from Maker Port or GPIO breakout.
Analog Read
The figure below shows the GPIO that can read analog sensor value.
Note: You may look for the pins labelled "A_" on the board.
1. While your MOTION 2350 Pro is connected to your computer, open your editor software (for example Thonny). Select the code.py file in your drive.
2. Connect your analog module to the MOTION 2350 Pro, to Maker Port with GP 26 & GP27 using JST-SH to 4 female pins / grove cable.
OR connect to the GPIO breakout using male-to-female jumper wires together with grove cables (if applicable).
Example module used: Octopus Analog Rotation Brick OBARot
3. Copy and paste the following code to your editor.
4. Flash the codes to your MOTION 2350 Pro. And your CIRCUITPY drive should look like this (no lib file is used):
Digital Read
We will show all 2 types of connections for this application, including Maker Port and GPIO Breakout.
In this example, we will use the generic module of HC-SR04 Ultrasonic Sensor and Grove Ultrasonic Sensor as an illustration.
1. While your MOTION 2350 Pro is connected to your computer, open your editor software (for example Thonny). Select the code.py file in your drive.
2. Connect your sensor module to the MOTION 2350 Pro, to Maker Port with GP 26 & GP27 using JST-SH to 4 female pins / grove cable.
OR connect to the GPIO breakout using male-to-female jumper wires.
Generic Module:
Grove Module:
3. Copy and paste the following code to your editor.
4. Flash the codes to your MOTION 2350 Pro. And your CIRCUITPY drive should look like this:
Library file(s) required:
adafruit_hcsr04.mpy
If you don't have this file in your computer, download the lib bundle here and search for this file inside the "lib" folder.
Hardware Components
5VDC HC-SR04 Ultrasonic Sensor
$0.83 $1.13 $0.83
Octopus Analog Rotation Brick OBARot
$2.98 $2.98
MOTION 2350 Pro - Advanced Robotics Controller ...
$24.90 $24.90