data from 2 accelerometers to data logging shield

Hi,

Trying to gather suspension acceleration data from shocks. Purchased Arduino Uno, Adafruit data logging shield, ADXL345 and Flora accelerometers.

I would prefer to use the flora accelerometers because they're round so the casing would be easier to manufacture.

I need data logged to the sd-card from at least 2 accelerometers at a time but if possible I'd like to gather data from 4 accelerometers at a time.

I need help with which accelerometers to use and how to connect and how to program

There's a lot of information around but can't seem to find info for this case so could someone please help??

RTC uses analog pins 4&5?

Flora to 3V pin
ADXL345 to 5V pin
Analog pins 0 & 1 to flora accelerometer SDA & SCL
Analog pins 2 & 3 to adxl345 accelerometer SDA & SCL?

Can I somehow use the reset button to store the next data and have it named differently like log1, log2, ...

What I've done so far is I've soldered headers on the data logging shield and set the RTC and checked that the SD connection works

Br,
Jussi

Learn more about I2C - all modules share the unique SCL/SDA lines (on A4/A5). Every module must have a unique bus address, what can be problematic with many modules of the same type - see the data sheets.

Hi,

If I'm correct:
Flora I2C 0x32 & 0x3C
ADXL345 I2C 0x53

This would make me believe that I could use one of each accelerometers to collect data at the same time cause they use different addresses?

I have no idea what a bus address is?

Both accelerometer types should work with 3volts so can I connect as follows:

Data logging shield----to----Flora
3V 3V
GND GND
Analog in 0 SDA
Analog in 1 SCL

Data logging shield----to----ADXL345
3V VCC
GND GND
Analog in 2 SDA
Analog in 3 SCL

Is that correct? I'd highly appreciate if someone could help me with this as I can't find information anywhere as to how they've made the connection from data logging shield to accelerometers. Before this I can't begin to start programming.

For some reason all the examples have analog pins 4&5 in use?

I gather I need to use analog pins cause I need actual data and not 1's and 0's.

Jussi

I gather I need to use analog pins cause I need actual data and not 1's and 0's.

You need to use the analog pins because they are the I2C pins. That they, when not being used for I2C purposes, can be used as analog pins is completely irrelevant.

I have no idea what a bus address is?

All devices on a bus share the bus (are connected to the same I2C pins), and have different addresses.

The bus address is a byte of data that is sent over the bus, and only the device with that address responds.

You MUST use the I2C pins that are appropriate for your Arduino. They vary from type to type.

I have a arduino uno and adafruit data logging shield and on the arduino uno the pins are analog 4 (i2c sda) and 5 (i2c scl) so I’ll connect both accelerometers to the same pins.

Data logging shield----to----Flora
3V 3V
GND GND
Analog in 4 SDA
Analog in 5 SCL

Data logging shield----to----ADXL345
3V VCC
GND GND
Analog in 4 SDA
Analog in 5 SCL

Thank you very much! I’ll connect the accelerometers this weekend and start trying to program

Jussi

Make sure the accelerometers have different addresses; study the data sheet.

Hi,

got the connection done and have been connecting different programs which I’ve found. Now I’m getting results from the flora and adxl345 but they’re not g’s. I attached a print screen of the “g’s” that I’m getting. (Flora ~15680, ADXL345 ~-23.00)

Could someone please help?

My code is as follows:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303.h>

Adafruit_LSM303 lsm;

    #define Power_Register 0x2D
    #define Data_Format 0x31 // Resolution and g-range.
    #define X_Axis_Register_DATAX0 0x33 // Hexadecima address for the DATAX0 internal register.

    int ADXAddress_1 = 0x53;  //Device address in which is also included the 8th bit for selecting the mode, read in this case.
int X10,X11,X1_out;
float X1a;

void setup() 
{
#ifndef ESP8266
  while (!Serial);     // will pause Zero, Leonardo, etc until serial console opens
#endif
  Serial.begin(9600);
  
  // Try to initialise and warn if we couldn't detect the chip
  if (!lsm.begin())
  {
    Serial.println("Oops ... unable to initialize the LSM303. Check your wiring!");
    while (1);
  
    
  }

      Wire.begin(); // Initiate the Wire library    
      Serial.begin(9600);    
      delay(100);
      
      Wire.beginTransmission(ADXAddress_1);
      Wire.write(Data_Format); // Data_Format Register
      // Full range 
      Wire.write(3); // Bits  (0000 0011)
      Wire.endTransmission();
      Wire.beginTransmission(ADXAddress_1);
      Wire.write(Power_Register); // Power_CTL Register
      // Enable measurement
      Wire.write(8); // Bit D3 High for measuring enable (0000 1000)
      Wire.endTransmission();

  
}

void loop() 
{
  lsm.read();
  Serial.print("Flora Accel X:       "); Serial.print((int)lsm.accelData.x); Serial.print(" ");
  delay(0); Serial.println();
{
 // X1-axis
  
  Wire.beginTransmission(ADXAddress_1); // Begin transmission to the Sensor 1 
  //Ask the particular registers for data
  Wire.write(X_Axis_Register_DATAX0);
  Wire.endTransmission(); // Ends the transmission and transmits the data from the two registers
}
  Wire.requestFrom(ADXAddress_1,2); // Request the transmitted two bytes from the two registers
  if(Wire.available()<=2) {  // 
    X10 = Wire.read(); // Reads the data from the register
    X11 = Wire.read();
    /* Converting the raw data of the X-Axis into X-Axis Acceleration
     - The output data is Two's complement 
     - X0 as the least significant byte
     - X1 as the most significant byte */ 
    X11=X11<<8;
    X1_out =X10+X11;
    X1a=X1_out/256.0; // X1a = output value from -1 to +1, Gravity acceleration acting on the X-Axis
}

      // Prints the data on the Serial Monitor
      Serial.print("ADXL345 Accel X:     ");
      Serial.print(X1a); Serial.println(); Serial.println(); delay(1000);
}

they're not g's

Of course not. Each accelerometer outputs a number that depends on the range you select, and a "sensitivity factor" for that range. Check the data sheet for the conversion information.

It is very instructive to hold the accelerometer still such that an axis is directly up or down. By definition, you have +/- 1 g acceleration along that axis, depending on orientation. Satisfy yourself that the number agrees with the sensitivity factor given in the data sheet.