Common accelerometer output signals are divided into digital output and analog output. The ADXL326 is a small, low-power triaxial analog output accelerometer from Analog Devices (ADI). This product has a minimum full-scale range of ±16g for measuring acceleration. In this post, we will mainly introduce how to use the ADXL326 module on the Arduino UNO development board to read raw data from the accelerometer.

Required components

  • ● Arduino UNO Development Board
  • ● YBX-ADXL326 Triaxial Accelerometer Sensor Module ( Taobao Link )
  • ● Connect jumpers
  • ● USB cable

YBX-ADXL326 Triaxial Accelerometer Module

The YBX-ADXL326 module uses the ADXL326 accelerometer sensor from Analog Devices (ADI). This sensor can measure static gravitational acceleration in tilt sensing applications, as well as dynamic acceleration caused by motion, impact, or vibration. Users select the accelerometer’s bandwidth using the CX, CY, and CZ capacitors on the XOUT, YOUT, and ZOUT pins. The bandwidth is selectable based on the application, with X-axis and Y-axis bandwidths ranging from 0.5 Hz to 1600 Hz, and Z-axis bandwidths ranging from 0.5 Hz to 550 Hz.

The module’s accelerometer has an onboard power supply LDO that supports 3.3V and 5V power input.

Connectin the ADXL326 accelerometer sensor to Arduino

Hardware connection

The Arduino development board connects to the YBX-ADXL326 module via analog pins. The hardware connection schematic is shown below:

Connectin the ADXL326 accelerometer sensor to Arduino

First, connect the VCC pin of the YBX-ADXL326 module to the +5V pin, and connect the GND pin to any GND pin of the Arduino.

Then connect the analog interface, and connect the XOUT, YOUT, and ZOUT pins of the YBX-ADXL326 module to pins A3, A4, and A5 of the Arduino UNO development board, respectively.

The hardware connection is complete, as shown in the following figure:

Connectin the ADXL326 accelerometer sensor to Arduino

code

This article uses the built-in Arduino function for reading analog pins, so no library files are required.

The complete code is shown below:

/*
Reads an ADXL326 3-axis accelerometer from Adafruit.
Sends the results as a JSON-formatted string like so:
{"x":"345", "y":"432", "z":"234"}
/

//Set up pins for ADXL326 breakout board:
const int zPin = A3;
const int yPin = A4;
const int xPin = A5;

boolean sending = false;

void setup() {
  Serial.begin(9600);
}

void loop() {
  // read for incoming messages. c = send, x = don't send:
  char inChar = Serial.read();
  switch (inChar) {
  case 'c': // connection open
    sending = true;
    break
  case 'x': // connection closed
    sending = false;
    break
  }

  if (sending) {
    // Read sensors:
    int x = analogRead(xPin);
    delay(1);
    int y = analogRead(yPin);
    delay(1);
    int z = analogRead(zPin);

    // form a JSON-formatted string:
    String jsonString = "{"x":"";
    jsonString += x;
    jsonString +="","y":"";
    jsonString += y;
    jsonString +="","z":"";
    jsonString += z;
    jsonString +=""}";

    // print it:
    Serial.println(jsonString);
  }
}

Compile and upload the code to the Arudino development board. Connect the development board to the computer.

Run test results

Open the serial monitor, select the correct serial port number and baud rate (9600), send the character ‘c’, and observe the output of the Arduino development board. Rotate the module and observe the changes in the output values.

Connectin the ADXL326 accelerometer sensor to Arduino

This concludes the tutorial on connecting the ADXL326 module using an Arduino development board. If you have any questions, please feel free to reply below this post.

Original post

error: Content is protected !!
Scroll to Top