ماژول شتاب سنج 3 محوره دیجیتال ADXL345 GY-291

۹۵,۰۰۰ تومان

موجود در انبار

10 نفر در حال مشاهده این محصول هستند!
توضیحات

ADXL345 Digital 3-Axis Acceleration of Gravity Tilt Module GY-291
Description
The GY-291 is a breakout board for the ADXL345.
The ADXL345 is a small, thin, low power, well suited to measures the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock.
Digital acceleration module Outline The ADXL345 is a small, thin, low-power 3-axis accelerometer, can high TAT ± 16 g acceleration measurement of the high resolution (13 bits).
Number of digital outputs It is for the 16-bit two’s complement format SPI (3-wire or 4-wire) or I2C digital interface.
ADXL345 is a three-axis accelerometer module with two I2C and SPI interfaces and low power consumption.
This module is easily connected to 5V microcontrollers such as Arduino.
The silicon structure of this sensor allows the user to detect acceleration in three directions: X, Y and Z.
Technical Specifications
Model: HW-860

Measuring range: ± 2g ± 16g
Supply voltage between 1.8 and 3.6 volts
Low power consumption: 25 to 130 microamps at 2.5 V supply voltage
Support of SPI and I2C protocols
High resolution of 13 bits in ±16g range
Module type: GY-291
Use the chip: ADXL345
3-Axis, ± 2g / ± 4g / ± 8g / ± 16g
Dimensions
21 x 15 x 1 mm
Package Includes
1 x ADXL345 module

Application
Robotics and flying robots
Orientation devices
3D remote controllers
Game consoles
Laboratory applications

Test code for ADXL345
The following code is presented so that you can test the operation of the MPU, it is worth mentioning that calibration is required and the data returned is from the factory.

#include < Wire .h> //Library to communicate with devices via I2C
 #define DEVICE (0x53) // ADXL345 address specified in the datasheet to initiate communication
 byte _buff[6];
char POWER_CTL = 0x2D; //Control register
 char DATA_FORMAT = 0x31;
char DATAX0 = 0x32; //X-Axis Data 0
 char DATAX1 = 0x33; //X-Axis Data 1
 char DATAY0 = 0x34; //Y-Axis Data 0
 char DATAY1 = 0x35; //Y-Axis Data 1
 char DATAZ0 = 0x36; //Z-Axis Data 0
 char DATAZ1 = 0x37; //Z-Axis Data 1

void  setup () {
   Wire . begin ();
  Serial . begin (9600);
  writeTo(DATA_FORMAT, 0x01); //Place ADXL345 within +/- 4G range to write the value at 0x01 to the DATA_FORMAT register
  writeTo(POWER_CTL, 0x08); //Places the ADXL345 in Measurement Mode to write the value in register 0x08 to the POWER_CTL register
}

void  loop () {
  readAccel(); // tilt reading function in x/y/z
  delay (1000); // readings every second
}

void readAccel() { //function to read the inclination in x/y/z
   uint8_t data = 6; //6 bit read
  readFrom( DATAX0, data, _buff); //accelerometer reading in ADXL345 register DATX0
                                    // each axis has a resolution of 10 bits starting from LSM
  // conversion from bytes to integer from the read buffers
  int x = ((( int )_buff[1]) << 8) | _buff[0];
  int y = ((( int )_buff[3]) << 8) | _buff[2];
  int z = ((( int )_buff[5]) << 8) | _buff[4];
  //printing the values ​​of each axis
  Serial . print ("x: ");
  Serial . print (x);
  Serial . print ("and: ");
  Serial . print (and);
  Serial . print ("z: ");
  Serial . println (z);
}

void writeTo( byte address, byte val) { //function to write data to the
   Wire registers . beginTransmission (DEVICE); // begins Wire communication 
   . write (address); // send the addresses of
   Wire registers . write (val); // sent the
   Wire value . endTransmission (); // end of communication
}


void readFrom( byte address, int num, byte _buff[]) { // Function for reading the number of bytes for the addresses of registers in the 
   Wire buffer . beginTransmission (DEVICE); // begins Wire communication
   . write (address); // send the address that was read
   Wire . endTransmission (); // end of transmission
   Wire . beginTransmission (DEVICE); // begins Wire communication
   . requestFrom (DEVICE, num); // 6 byte request to MPU
   int i = 0;
  while ( Wire . available ()) { // The MPU may send less data than required (abnormal)
    _buff[i] = Wire . read (); // receives bytes and saves them in the buffer
    i++;
  }
  Wire . endTransmission (); // end of stream
}

We can also use one of the many libraries available.
For example, the Sparkfun provided library for the ADXL345 .
This library provides methods to communicate via both I2C and SPI, to configure the ADXL345, and define interrupts for detection of activity, inactivity, normal and double presses.
The library provides code examples, which it is advisable to review.
The following example is a reduced version of those available in the library, which performs the same functions as the previous example with much more concise code.

#include <SPI.h>
#include <Wire.h>
#include <SparkFun_ADXL345.h> 

ADXL345 adxl = ADXL345();

void setup() 
{
  Serial.begin(9600);             
  Serial.println("Iniciar");
  Serial.println();

  adxl.powerOn();            
  adxl.setRangeSetting(16);       //Definir el rango, valores 2, 4, 8 o 16
}

void loop() 
{
  //leer los valores e imprimirlos
  int x, y, z;
  adxl.readAccel(&x, &y, &z);  
  Serial.print(x);
  Serial.print(", ");
  Serial.print(y);
  Serial.print(", ");
  Serial.println(z); 
}
نظرات (0)

دیدگاهها

هیچ دیدگاهی برای این محصول نوشته نشده است.

اولین نفری باشید که دیدگاهی را ارسال می کنید برای “ماژول شتاب سنج 3 محوره دیجیتال ADXL345 GY-291”

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *