Arduino Uno and Evaluation Board

I'm attempting to create a digital ballistocardiogram using the LIS3DH digital output accelerometer. Data sheet can be found here: http://www.st.com/web/catalog/sense_power/FM89/SC444/PF250725

The accelerometer chip is mounted onto the STEVAL-MKI105V1 evaluation board Data Sheet:http://www.st.com/web/en/catalog/tools/PF251655

I'm having a problem figuring out how to connect the arduino to the evaluation board so that I can start reading data from the accelerometer chip. Page 9 on the accelerometer chip data sheet (1st link) has a list of the pin numbers, names, and functions for the accelerometer chip, but I am unsure of which pins I should connect from the evaluation board to the arduino. Any help would be much appreciated, thank you in advance.

It is 3.3V chip, you should use the Arduino 3.3V output pin to power it. Using I2C mode is the easiest to connect it to an Arduino Uno, but I don't know if the I2C mode is fast enough to measure the heart beat.

Next are the pin numbers of the chip and the names. 1 Vdd_IO and 14 Vdd : 3.3V 5 GND and 12 GND and 10 RES : GND 8 CS : connect to 3.3V for I2C mode. For safety, use 10k resistor to 3.3V, or don't connect. 6 SDA and 4 SCL : I2C bus 7 SDO is internal pulled high. Don't connect. 11 INT1 and 9 INT2 : don't connect

Add two pullup resistors of 4k7 for the I2C bus to 3.3V. That is 4k7 from SDA to 3.3V and 4k7 from SCL to 3.3V. Be sure to connect the pullup resistors to 3.3V (not to 5V) and don't connect the sensor to an Arduino Uno without those 4k7 resistors.

Pin 7 SDO and pin 8 CS have internal pullup resistors that pull them high. That means that the chip is default in I2C mode with the highest chip select.

After everything is connected, run the i2c_scanner to see if the sensor is detected. http://playground.arduino.cc/Main/I2cScanner

Thank you, I really appreciate you taking the time to reply. You mentioned that the I2C mode may not be fast enough, is there something we can use that is faster than the I2C mode?

Project Goal: Measure the low frequency vibrations of the sternum caused by cardiac activity using the LIS3DH accelerometer. This data will then be used to assess the ballistic forces on the heart.

The I2C speed can be set with Wire.setClock().
Default is 100000 (100kHz), but 200000 and 400000 will often also work (only with short wires).

The SPI bus is a lot faster than I2C. However the Arduino Uno is a 5V microcontroller and the sensor is a 3.3V sensor. You need a level shifter for that. With I2C it will probably work without level shifter, as long as there are 4k7 pullup resistors to 3.3V.

This information has been extremely helpful, thank you. I'm going to construct a level shifter and use the SPI bus, just to ensure that it is quick enough.

I greatly appreciate you taking the time to help me out. Thanks again and have a wonderful day.

Or.... use a 3.3V Arduino board.

There are 8MHz 3.3V Arduino boards, like the Pro Mini (so small, it doesn't have a usb connector), or the Arduino Due (big).

The Adafruit Metro is able to switch between 3.3V and 5V : http://www.adafruit.com/products/2488 But you have to know that running an ATmega328P microcontroller at 16MHz and at 3.3V is outside the specificiations of the datasheet. There is no guarantee that it will be stable at 3.3V.

If the i2c_scanner can't find the I2C device, then something is wrong :confused:

Well, okay, the CS has an internal pullup resistor, so the chip is in I2C mode by default I think.

Did you read this : http://forum.arduino.cc/index.php/topic,148850.0.html Number 8 on that page is how to attach a photo. use the "REPLY" button so see those additional options.

I don't know the LIS3DH, but if you can make a photo that shows all the wiring to the Arduino, I can have a look at it. I'm afraid there is not much more I can do to help.

So I connected VCC on the evaluation board to 3.3 V and the scanner worked. It found something at the address 0x19. I have attached a picture of my setup, it may be a bit hard to see what’s going on at first so here’s a quick summary:

  1. The two resistors that go over the top of the board are 4.7k resistors going from SDA and SCL to a bus which I have connected to VDD_IO which is connected to 3.3V coming from the Arduino.

  2. The yellow wire on the bottom connects VCC to 3.3V.

  3. On the top side of the board there is an orange wire which connects GND on the evaluation board to GND on the Arduino.

  4. Next to the orange GND wire there is a 10k resistor which connects CS to 3.3V.

  5. Where the 4.7k resistors connect to SDA and SCL there is a green wire which connects SCL from the evaluation board to SCL on the Arduino.

  6. Where the other 4.7k resistor is there is a yellow wire which connects SDA from the evaluation board to SDA on the Arduino.

I’ve said it many times already, but I just want to reiterate that I really appreciate you helping me out here.

Good ! it is detected :slight_smile:
The wiring is okay as far as I can tell.
I think pins like CS can be connected directly to 3.3V, but I’m not sure. Therefor using a resistor is safer.

According to the datasheet : “The Slave ADdress (SAD) associated to the LIS3DH is 001100xb
The binary value “.001 100x” is either 0x18 or 0x19. Since SDO is internally pulled high, the last bit is a ‘1’, and the address is 0x19 :stuck_out_tongue:

That was the easy part. I don’t know about a library and how to program it.

Excellent, and I've found some sample code for the accelerometer chip, I just need to fix it up a bit. Thanks again, have a wonderful day.

Hi cuuddii

You messaged me about an earlier thread on a related chip, and some test code I had posted.

Looking again at the datasheet, I think I can see a problem in that code. The datasheet says that, when reading from the chip, the master needs to send a “restart” (rather than a “stop”) after writing the register address.

Try this instead, to see if you can read the device ID 0x33 from the chip. Check that the I2C address in the code matches what you are getting on the scanner.

Regards

Ray

#include <Wire.h>
#define address 0x19

void setup()
{
 Serial.begin(9600);
 Serial.println("Program started ...");
 Wire.begin();

 // Read device "who am I?" register
 Wire.beginTransmission(address);
 Wire.write(0x0F);  
 Wire.endTransmission(false); // false causes a restart to be sent
 Wire.requestFrom(address, 1);
 if (Wire.available() > 0){
   Serial.print("WHO_AM_I: ");
   Serial.println(Wire.read(), HEX);
 }
 else
 {
    Serial.println("No data received");
 }
}

After uploading the new code you posted, I was able to get the correct result. Thank you very much.

After changing the #define address to 0x19 from 0x18 I was able to get the correct acceleration values as well. I really appreciate you taking the time to reply, have an excellent day.

#include <Wire.h> //I2C Arduino Library

#define address 0x19 //I2C 7bit address

void setup(){
//Initialize Serial and I2C communications
Serial.begin(9600);
Wire.begin();

//Put into the correct operating mode
Wire.beginTransmission(address); //open communication with
Wire.write(0x20);
Wire.write(0x27);
Wire.endTransmission();
}

void loop(){

int x,y,z; //triple axis data

Wire.beginTransmission(address);
Wire.write(0xA8);
Wire.endTransmission();

//Read data from each axis
Wire.requestFrom(address, 6);
if(6<=Wire.available()){
x = (int)Wire.read();
x |= (int)Wire.read()<<8;
y = (int)Wire.read(); // Note change in operator on this and next three statements
y |= (int)Wire.read()<<8;
z = (int)Wire.read();
z |= (int)Wire.read()<<8;
}

//Print out values of each axis
Serial.print("x: “);
Serial.print(x);
Serial.print(” y: “);
Serial.print(y);
Serial.print(” z: ");
Serial.println(z);

delay(450);
}

In your working code, before the block of code that reads the acceleration values, do you have ...

Wire.endTransmission(false);

or this?

Wire.endTransmission();

I have Wire.endTransmission(); right before the voidloop(){ which obtains the acceleration data. I took a closer look at my readings and they seem a bit strange, this is what I got while the breadboard was sitting on the floor, as still as I could get it:

x: 128 y: 256 z: 17216 x: 64 y: 256 z: 17344 x: 128 y: 192 z: 17280 x: 192 y: 256 z: 17344 x: 128 y: 256 z: 17216 x: 192 y: 384 z: 17280 x: 0 y: 128 z: 17408 x: 128 y: 256 z: 17216 x: 64 y: 128 z: 17152 x: 64 y: 128 z: 17216 x: 0 y: 192 z: 17280 x: 128 y: 128 z: 17280 x: 64 y: 256 z: 17280

Do you know why the z-axis is reading 17000? I'm going to add some analog and digital filtering when I get a better idea of the signal characteristics I'm looking for so that I can attenuate some of the noise.

I just realized the z axis will read 1g for gravity. Or 16384