RPi Pico B.Tech/Diploma Beginner

ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython

Interfacing ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython Code to read the acceleration data on x, y, z axis

  • Suitable forB.Tech/Diploma RPi Pico students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project


Overview
This tutorial explains how to interface the ADXL375 Accelerometer module with the Raspberry Pi Pico using MicroPython Code.
This is the ADXL375 module, which is a digital MEMS accelerometer from Analog Devices. The sensor is small and thin, with ultra-low power consumption as low as 35 µA in measurement mode. The best thing about this sensor is that it can measure acceleration up to ±200 g. Imagine reading such a high gravitational pull of the Earth or measuring the acceleration of a very fast-moving object—here, the ADXL375 is perfect.
Fig: ADXL375 Accelerometer Module
In this tutorial, we will first go through the ADXL375 features, capabilities, pinout, and other details. Then, we will show you how you can use the ADXL375 accelerometer with Raspberry Pi Pico using MicroPython code.
Components Required
The following are the components required for making this guide.
S.N.
Components Name
Quantity
Purchase Link

Raspberry Pi Pico

Amazon
AliExpress

ADXL375 Accelerometer

Amazon
AliExpress

Connecting Wires

Amazon
AliExpress

Breadboard

Amazon
AliExpress
ADXL375 Accelerometer
The ADXL375 is a small, thin, 3-axis accelerometer that provides low power consumption and high resolution measurement up to ±200 g.
Fig: ADXL375 Accelerometer Module
The digital output data is formatted as 16-bit, two’s complement data and is accessible through a SPI or I2C digital interface. It supports a bandwidth of up to 1 Kilo Hertz. The bandwidth is selectable via Serial Command. An integrated memory management system with a 32-level FIFO buffer can be used to store data to minimize host processor activity and lower overall system power consumption.
Fig: ADXL375 Functional Diagram
The sensor has the ability to determine shock, even, or could be used in an activity or inactivity monitoring system. One shocking thing to notice about this module is, it has a 10,000g shock survival, which is amazing. According to the datasheet, it could be used for concussion and head trauma detection, and also for high-force event detection. To learn more about the ADXL375 Module, you may go through the
ADXL375 Datasheet
ADXL375 Features & Specifications
Measurement Range:
±200 g (fixed) with 13-bit two ’s-complement output
Sensitivity:
49 mg/LSB (0.049 g/LSB) → ~0.4805 mg resolution when converted to m/s²
Power Consumption:
Measurement mode:
35 µA typical
Standby mode:
0.1 µA typical (VS = 2.5 V)
Note:
Supply current varies with output data rate/bandwidth setting
Output Data Rate / Bandwidth:
User-selectable via serial registers
Bandwidth up to 1 kHz (ODR up to 1 kHz)
FIFO Buffer:
32-sample watermark FIFO reduces host-processor load
Event Detection:
Single-tap / double-tap (impulse) detection
Activity/inactivity monitoring with programmable thresholds & durations
Digital Interfaces:
I²C (7-bit address = 0x53 when ALT_ADDRESS = LOW)
SPI (3- or 4-wire)
Supply Voltage:
2.0 V to 3.6 V
I/O Voltage Range:
1.7 V to VS
Operating Temperature:
–40 °C to +85 °C
Shock Survivability:
10,000 g (non-operating)
Package / RoHS:
3 × 5 × 1 mm LGA, RoHS-compliant
Hardware Connection between Raspberry Pi Pico & ADXL375 Accelerometer
First, let’s perform basic testing of ADXL375 with the Raspberry Pi Pico. Here is the simple schematic
We can connect the ADXL375 to the Raspberry Pi Pico via the I²C interface.
We can simplify the breadboard wiring with jumper cables and ensure the ADXL375 is oriented as shown on the breakout board.
Source Code/Program: Getting Acceleration Readings
Lets develop a basic MicroPython sketch to get Acceleration reading on all the 3-axis for ADXL375 & Raspberry Pi Pico

from
machine
import
Pin
I2C
import
time
class
ADXL375
:
_REG_BW_RATE
=
0x2C
_REG_POWER_CTL
=
0x2D
_REG_DATA
=
0x32
_SCALE
=
0.049
*
9.80665
# g-scale → m/s²
def
__init__
(
self
i2c
addr
=
0x53
)
:
self
i2c
=
i2c
self
addr
=
addr
if
addr
not
in
self
i2c
scan
(
)
:
raise
OSError
(
"ADXL375 not found at 0x%02X"
%
addr
)
# Standby → 100 Hz → Measure
self
_write
(
self
_REG_POWER_CTL
0x00
)
time
sleep_ms
(

)
self
_write
(
self
_REG_BW_RATE
0x0A
)
self
_write
(
self
_REG_POWER_CTL
0x08
)
time
sleep_ms
(

)
def
_write
(
self
reg
val
)
:
self
i2c
writeto_mem
(
self
addr
reg
bytes
(
[
val
]
)
)
def
_read
(
self
reg
n
)
:
return
self
i2c
readfrom_mem
(
self
addr
reg
n
)
def
_twos_comp
(
self
val
bits
=

)
:
# convert unsigned to signed (two's complement)
if
val
&
(

<<
(
bits

)
)
:
val
-=
(

<<
bits
)
return
val
def
read_raw
(
self
)
:
buf
=
self
_read
(
self
_REG_DATA

)
# little-endian, manual two’s-comp
=
buf
[

]
(
buf
[

]
<<

)
y
=
buf
[

]
(
buf
[

]
<<

)
z
=
buf
[

]
(
buf
[

]
<<

)
return
(
self
_twos_comp
(
)
self
_twos_comp
(
y
)
self
_twos_comp
(
z
)
)
def
read_mps2
(
self
)
:
y
z
=
self
read_raw
(
)
return
(
x *
self
_SCALE
y *
self
_SCALE
z *
self
_SCALE
)
# ——— Example ——————————————————————————————
i2c
=
I2C
(

sda
=
Pin
(

)
scl
=
Pin
(

)
freq
=
400000
)
try
:
accel
=
ADXL375
(
i2c
)
except
OSError
as
e
:
(
e
)
while
True
:
time
sleep
(

)
(
"ADXL375 ready!"
)
while
True
:
y
z
=
accel
read_mps2
(
)
(
"X:{:+6.2f} Y:{:+6.2f} Z:{:+6.2f} m/s²"
format
(
y
z
)
)
time
sleep_ms
(

)
Copy the above code and paste it on the editor window of Thonny IDE. Run this code, you will see the Acceleration data on the terminal window for all the x, y, and z axes.
The x and y data should be almost zero as the sensor is placed on a flat surface. The z-axis data should be almost 9.8 m/s2 due to the gravitational pull of the Earth. But it’s showing some offset readings. That’s why you modified the MicroPython code for auto calibration.
Source Code/Program: Read Acceleration with Auto Calibration
Here is the modified code for reading the correct values of acceleration in the x, y, and z axis.
We first average 100 readings with the board held flat to compute
x_offset
y_offset
, and
z_offset = avg_z – 9.80665 m/s²
. Then, on each loop, we subtract those offsets from the raw readings so that X/Y read ~0 and Z reads ~9.8 m/s² when the sensor is level.

from
machine
import
Pin
I2C
import
time
# Standard gravity (m/s²)
G
=
9.80665
class
ADXL375
:
_REG_BW_RATE
=
0x2C
_REG_POWER_CTL
=
0x2D
_REG_DATA
=
0x32
# DATAX0..DATAZ1
_SCALE
=
0.049
*
G
# 0.049 g/LSB → m/s²
def
__init__
(
self
i2c
addr
=
0x53
)
:
self
i2c
=
i2c
self
addr
=
addr
# calibration offsets (m/s²)
self
x_offset
=
0.0
self
y_offset
=
0.0
self
z_offset
=
0.0
# check device present
if
addr
not
in
self
i2c
scan
(
)
:
raise
OSError
(
"ADXL375 not found at 0x%02X"
%
addr
)
# Standby → 100 Hz → Measure
self
_write
(
self
_REG_POWER_CTL
0x00
)
time
sleep_ms
(

)
self
_write
(
self
_REG_BW_RATE
0x0A
)
# 100 Hz
self
_write
(
self
_REG_POWER_CTL
0x08
)
# Measure on
time
sleep_ms
(

)
def
_write
(
self
reg
val
)
:
self
i2c
writeto_mem
(
self
addr
reg
bytes
(
[
val
]
)
)
def
_read
(
self
reg
n
)
:
return
self
i2c
readfrom_mem
(
self
addr
reg
n
)
def
_twos_comp
(
self
val
bits
=

)
:
if
val
&
(

<<
(
bits

)
)
:
val
-=
(

<<
bits
)
return
val
def
read_raw
(
self
)
:
buf
=
self
_read
(
self
_REG_DATA

)
=
buf
[

]
(
buf
[

]
<<

)
y
=
buf
[

]
(
buf
[

]
<<

)
z
=
buf
[

]
(
buf
[

]
<<

)
re

Technologies used

Raspberry PiBLEPythonI2CSPIMicroPython

Hardware components

  • Raspberry Pi

Software & tools

  • Thonny
  • MicroPython

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.