Hey
Currently trying to connect using I2C to this accelerometer (the lis3lv02dq). I have been having problems getting the send and return to work, so I simplified my code down until I could get it working. Afterwards, I'd concentrate on getting the details from it.
My wiring is:
- 3.3v to VDD
- analog 4 to SDA
- analog 5 to SCL
- digital 9 to CS
Right now, I'm just asking it for its physical address, which the datasheet said ought to be 3A. Currently it just returns ááá, if I serial.println as a DEC or HEX.
Here's the code:
#include <Wire.h>
#define i2cLIS 0x1D
void setup ()
{
pinMode(9, OUTPUT);
digitalWrite(9, HIGH);Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
Wire.beginTransmission(i2cLIS);
Wire.send(0x21); // CTRL_REG1 (20h)
Wire.send(0x87); // Device on, 40hz, normal mode, all axis's enabled
Wire.endTransmission();
}void loop()
{
//------------byte whoI;
//------------
Wire.beginTransmission(i2cLIS);
Wire.send(0x0F);
Wire.endTransmission();Wire.requestFrom(i2cLIS, 1);
if(Wire.available())
{
whoI = Wire.receive();}
Serial.println(whoI, DEC);
delay(1000);
}
Any thoughts on what might be the problem?