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.
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.
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 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
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);
}
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.