after finally finding out how to create a software SPI connection i now can successfully read the data from an ADXL345 acceleration sensor. But they look rather strange to me, this are some sample values:
X: -252 Y: -532 Z: 9616
These values are measured in +-16g mode with full precision (so basically we have 4mg/LSB). These values are in mG (e.g a value of 1000 would represent 1G). I don't quite understand why the Z-value is so high?
I initialize the ADXL345 with this code:
write_command = ((0x00 | 0x31) << 8) | 0b01001011;//set SPI 3wire & 16g range & full-res write_command = ((0x00 | 0x2D) << 8) | 0x08; //Enable measurements
I send the values over uart to an UART / USB converter. The values are changing if i start to move the sensor board so i think my reading part is correct:
//read X-Axis x0 = readRegister(0x80 | 0x32); x1 = readRegister(0x80 | 0x33); //read Y-Axis y0 = readRegister(0x80 | 0x34); y1 = readRegister(0x80 | 0x35); //read Z-Axis z0 = readRegister(0x80 | 0x36); z1 = readRegister(0x80 | 0x37); //convert in milli-G [4.0mg/LSB] in +/- 16g mode @ full-res x = ((x1 << 8) | x0); y = ((y1 << 8) | y0); z = ((z1 << 8) | z0); *x_val = x * 4; *y_val = y * 4; *z_val = z * 4;
Do you have any ideas what i do wrong at the data processing part?