Hey Guys,
I am working on a project which is using Arduino Due (Board Model DUE R3) connected with ADXL345 accelerometer. The board is connected with Pc with a usb cable at 9600 baud rate. Right now I am using the following code to recieve the x,y and z readings from the accelerometer:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
Adafruit_ADXL345_Unified BSens = Adafruit_ADXL345_Unified(1);
void setup()
{
Serial.begin(9600);
BSens.begin();
}
void loop()
{
sensors_event_t event;
BSens.getEvent(&event);
Serial.print(event.acceleration.x);
Serial.print(" ");
Serial.print(event.acceleration.y);
Serial.print(" ");
Serial.println(event.acceleration.z);
}
With this code right now I am recieving the readings from the accelerometer at 310 Hz datarate. Increasing the data rate starts to give errors in the reception of the data (printing of data on the screen at once). The ADXL345 manual says that we can increase the data rate of the accelerometer to upto 3200Hz. So my plan is to increase the datarate of the accelerometer to 3200Hz(maximum value) and store it as a packet of data in the Arduino Due Board and recieve that data after every 1 or 2 seconds as a packet file.
So can anyone please explain me that what changes should I make in my code or settings to set the sampling rate of accelerometer to 3200Hz. Please state clear and explained answers as I am a newbie in this kind of project. (a detailed answer to make the datarate of the accelerometer to 3200 Hz, the maximum value).
Note: Increasing the Baud does not make much difference in the datarate.
Will be really grateful to you in this regard.
Regards,
Daniyal Khan