Main Content

ADXL34x Accelerometer

Measure linear acceleration along axes of ADXL34x family of accelerometers

Since R2022a

Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.

  • ADXL34x Accelerometer

Libraries:
Simulink Support Package for Arduino Hardware / Sensors

Description

The ADXL34x Accelerometer block reads data from the ADXL34x family of accelerometers (ADXL343, ADXL344, ADXL345, and ADXL346) with Arduino hardware.

You can use this block to measure linear acceleration along the X, Y and Z-axes. The block also provides the option to enable the data ready interrupt.

Ports

Output

expand all

This port outputs the linear acceleration (in m/s2) along the x-, y- and z-axes, as a n-by-3 array, where n is the value specified as Samples per frame.

Data Types: double

Timestamp (in seconds) at which data is read from the sensor, returned as n-by-1 matrix, where n is the value specified as Samples per frame.

Dependencies

This output port appears only if you select the Enable timestamp output parameter.

The data type of Timestamp output depends on the value that you selected for the Data type parameter.

Note

It is observed that there are many faulty cloned ADXL345 sensors available in the market, with Z axis raw output becoming unresponsive. Buy the sensor from a genuine distributor to avoid this issue.

Parameters

expand all

Specify the I2C module on the Arduino® hardware to communicate with sensor peripherals. For more information on the Arduino pin mapping and modules that hardware boards support, see Pin Mapping for Arduino Timer Independent Blocks.

The I2C address of the ADXL34x sensor from which the block reads the values.

The ADXL34x sensor can have two I2C addresses depending on the logic level on pin ALT of the sensor.

Pin NamePin StateI2C Address
ALTLow0x53
High0x1D

Select this parameter to set Timestamp as one of the output ports.

Select the data type of the sensor from which the block reads the values.

Specify the output data type for the values read from ADXL34x sensor. The default data type for Arduino hardware is single. Use this parameter to change the values to double, if required.

Specify the number of samples that the block outputs. The value that you specify here is also used to compute the output sample time:

Output sample time = Samples per frame * Sample time

Specify how often this block reads the data from the ADXL34x sensor. When you set this parameter to -1, Simulink determines the best sample time for the block based on the block context within the model. The output sample time is the product of Samples per frame and Sample time that you specify.

Advanced settings

Select the range of acceleration that the accelerometer can measure.

Select the output data rate at which accelerometer data is sampled.

If this option is selected, an interrupt is generated on pin INT1 or INT2 of the sensor when data is ready, allowing you to trigger other subsystems to perform any action.

Select the interrupt generate pin to read accelerometer data.

Dependencies

To enable this parameter, select the Enable data ready interrupt parameter.

Version History

Introduced in R2022a