Arduino and the LIS3LV02DQ Triple Axis Accelerometer

A mouthful otherwise known as a nice little 3-axis accelerometer from STMicroelectronics with a SPI bus, which makes it handy for interfacing in microcontroller style applications. I picked up one of these in breakout board style from the DIY heros at Sparkfun Electronics to see about its suitability for a DIY pedometer. A bit pricey (single units at $15.95), but its register-based configuration and data reading is pretty cool and eliminates any issues with pulse-width measurements or analog-to-digital conversion. It’s not a slam-dunk replacement for simple projects, but I thought it’d be a good idea to learn more about it, and also learn more about interfacing over the SPI bus.

(See the end of this post for an update on a little problem I had with the device)

Ultimately I want to interface through some Atmel AVR device, but I figured I’d start with the Arduino, since it’s pretty easy to get up and running in that environment.

The LIS3LV02DQ has two interfaces, one of which is SPI. For that, we need four data lines. One for chip select (also known as slave select), one for a clock, one for data in (to the microcontroller, from the slave chip), and one for data out (from the microcontroller, to the slave chip). The idioms in the SPI world vary, as I learned. For instance, here’s a table of how they’re referred to in this case:

LIS3LV02DQ Arduino/Atmel Human
SDO MISO (master in, slave out) data in to Arduino from chip
SDA MOSI (master out, slave in) data out from Arduino to chip
SCL SCK clock
CS SS chip select

Whatever they’re called, the functionality is pretty straight forward. The Arduino/Atmel is the “master” device — it tells the accelerometer chip what to do and when. In this case, “we” (the Arduino) can do things like read or write registers on the accelerometer. These registers configure the chip, tell it to start up or shutdown, read its sensor values, etc. The great thing about SPI is that you can do this all with only a few wires, and the protocol is simple enough that you could write your own firmware to handle it if your microcontroller doesn’t support it in hardware. (Cf Nathan Seidle’s SPI firmware source code example for the PIC.)

Fortunately, the ATMega8 and most of the Atmel ATMega’s handle SPI in hardware.

Getting the LIS3LV02DQ up and running is pretty straightforward. I basically wanted to create a simple framework for reading and writing its registers, which means that first I need to hook it up to the Arduino and then initialize the chip and I’d be set. First, hooking it up. Easy peasy.

I’m a bit out of bounds here, because I hooked up the chip to +5V generated by the Arduino. It’s a 2.16V – 3.6V device, ideally. The IO lines can work at 1.8V for logic high. Here I TTL land. Not wanting to destroy the chip, I played around with level shifting but ultimately, for this test, decided that I’d risk TTL logic levels. It’s supposed to be able to take up to +5V, but I suspect the chip isn’t terribly happy with that.

So, here’s what gets hooked up and where:

VDD -> 5V
INT -> N/C
SDO -> Arduino 12
SDA -> Arduino 11
SCL -> Arduino 13
CS -> Arduino 10

Easy enough. In the source code (available here) are defined a few useful things, such as functions to read and write the registers. The idiom is straightforward. For instance:

// write to a register
void write_register(char register_name, byte data)
  // char in_byte;
   // clear bit 7 to indicate we're doing a write
   register_name &= 127;
   // SS is active low
   digitalWrite(SLAVESELECT, LOW);
   // send the address of the register we want to write
   // send the data we're writing
   digitalWrite(SLAVESELECT, HIGH);

Performing the actual transaction over the SPI bus is handled largely in hardware. The ATMega8 has a register called SPDR that, when written to, begins an SPI transaction. Once you start a transaction, you have a choice of two ways to handle it. One is to simply wait around until the transaction is over, indicated by the SPIF bit being set. The other is to set up an interrupt vector for this bit, which will result in a designated function being called when the interrupt occurs. We’re not doing all that much, so it’s easier to just sit around and wait for the data rather than set up the interrupt vectors. The way you do this is to loop until the SPIF bit gets set.

char spi_transfer(volatile char data)
  Writing to the SPDR register begins an SPI transaction
  SPDR = data;
  Loop right here until the transaction is complete. The SPIF bit is
  the SPI Interrupt Flag. When interrupts are enabled, and the
  SPIE bit is set enabling SPI interrupts, this bit will set when
  the transaction is finished. Use the little bit testing idiom here.
  while (!(SPSR & (1 << SPIF)))
  // received data appears in the SPDR register
  return SPDR;

The spec sheet for the LIS3LV02DQ has specific instructions about reading and writing registers and what all of the registers are for, and other important stuff, like clearing bit 7 of register name to indicate that what’s happening is a register write. I recommend reading it carefully to understand some of the nuances. But, it’s pretty easy to work with, all in all.

My main loop() simply reads the registers that contain the X, Y, and Z axis values indicating acceleration along those vectors. The value that are generated by the LIS3LV02DQ represent a range of acceleration readings between -2g and +2g (the device can be configured to read +/-6g as well.) The registers contain either a high or low order value, so there are actually six registers to be read, two registers to compose a 16bit value. Although, actually, the default range of precision is 12 bits, with the most significant four bits, in this mode, containing the same value as the 11th bit, which effectively is the sign (+/-) of the data.

The values that are generated, once formed into a 16 bit word (with 12 significant bits) is such taht 2g = 2^12/2 = 2048, which means that 1 x gravity should be a value of 1024. If you place any of the chip’s axes normal to the ground, you should see the value 1024, or thereabouts (possibly -1024).

Calculating a reasonable acceleration in the normal, human units (meters per second per second), you’d multiply the value by 1/1024. You’ll need to scale the values into the long datatype range, I’d suspect, as you can’t do floating point math. And your 9th grade physics will tell you that:

velocity = a * t (meters/sec)
distance = v * t (meters)

So, you would sample the acceleration along an axis in the direction of motion and use an average of the acceleration over the sample period to calculate velocity.

void loop()
  byte in_byte;
  int x_val, y_val, z_val;
  byte x_val_l, x_val_h, y_val_l, y_val_h, z_val_l, z_val_h;
  // read the outx_h register
  x_val_h = read_register(0x29); //Read outx_h
  // high four bits are just the sign in 12 bit mode
  if((x_val_h & 0xF0) > 0) {
  // comment this if you care about the sign, otherwise we're getting absolute values
  x_val_h &= 0X0F;
  //Serial.print("x_h="); Serial.print(x_val_h, DEC); Serial.print(", ");
  // read the outy_h register
  x_val_l  = read_register(0x28);
  //Serial.print("x_l="); Serial.print(x_val_l, DEC); Serial.print(", ");
  x_val = x_val_h;
  x_val <<= 8;
  x_val += x_val_l;
  // the LIS3LV02DQ according to specs, these values are:
  // 2g = 2^12/2 = 2048
  // 1g = 1024
  // if you use the sign, that gives a range of +/-2g should output +/-2048
  Serial.print("x_val="); Serial.print(x_val, DEC);
  y_val_h = read_register(0x2B); //Read outx_h
  y_val_l = read_register(0x2A); //Read outx_l
  y_val = y_val_h;
  y_val <<= 8;
  y_val += y_val_l;
 Serial.print(" y_val="); Serial.print(y_val, DEC);
  z_val_h = read_register(0x2D); //Read outz_h
 // Serial.print("z_h="); Serial.print(z_val_h, DEC); Serial.print(", ");
  z_val_l = read_register(0x2C); //Read outz_l
 // Serial.print("z_l="); Serial.print(z_val_l, DEC); Serial.print(", ");
  z_val = z_val_h;
  z_val <<= 8;
  /*Serial.print("z_h_<<8="); Serial.print(z_val_h, DEC); Serial.print(", ");*/
  z_val += z_val_l;
  //long g_z; // say approx 100 cm/s/s
  //g_z = z_val * 10 / 1024;
  Serial.print(" z_val="); Serial.println(z_val, DEC);

Update: I started having problems with the device when I had more than one SPI device on the interface. The problem revealed itself when the LIS3LV02DQ would send back erroneous data if it was not the “first” in the parallel chain of devices along the SCL net. So, if I went from Arduino pin 13 to the LIS3LV02DQ SCL, then to another device’s SCL, it would work fine. But, if I went to another device’s SCL “first” then to the LIS3LV02DQ, it would break sending back 0×30 or 0×38 for the WHO_AM_I register rather than the expected 0x3A. Or, if I had a test lead connected to the LIS3LV02DQ’s SCL and touched the lead, it would also send back erroneous data. After some back and forth with tech support at ST Microelectronics, I found out to my embarrassment that I was using the wrong SPI mode. I should’ve been using mode 3 (CPOL = 1 and CPHA = 1) and I was using mode 0. I made corrections in the code.

Here’s the full source code for interfacing to the LIS3LV02DQ using an Arduino

LIS3LV02DQ sensor available from Sparkfun Electronics
Arduino available from Sparkfun Electronics
Arduino Board Main Site

Why do I blog this? Notes on how to get this accelerometer to talk to the world.


Got Something To Say:

Your email address will not be published. Required fields are marked *


× 4 = thirty two

Hello there, thanks for the wonderful article. :) We are using the same setup here for a musical instrument, but we are having no luck. Could you share some of your wizardry? :)
We carefully followed your instructions, but we ended up with

Setup phase – first check: WHO_AM_I [1F] 0x3A expected
Setup phase – second check: WHO_AM_I [1F] 0x3A expected

NEG_Xx_val=4095 y_val=8063 z_val=8191
NEG_Xx_val=4095 y_val=8063 z_val=8191
NEG_Xx_val=4095 y_val=8063 z_val=8191

The only thing we have different is that we are sending out 2.6V to VDD. All the rest is ipsis literis!

I would be very grateful if you could give us a shout on suggesting what could possibly be wrong.

Regards from York, Uk.


This is just for the record, but we have found out our Arduino NG board had issues. The LED that is attached to port 13 was preventing the clock from working correctly.
If you are having this problem, follow this thread: and resolder the resistor. Good luck. Cass

Thanks Cass — this is a good issue to point out, particularly as many Arduino’s do indeed have that LED (and resistor) on Arduino pin 13.

Hi, do someone have any suggestions how i should build a g-meter like this but with a LIS3L06AL.

The code for this works great, except that the fourth line of the code does not match the wiring. Either change the CS line of the LIS3LV02DQ to digital pin 8 on the Arduino, *OR* change the 4th line of the source code to:

#define SLAVESELECT 10


Thanks Chuck for catching that! I made the change as you suggested.


Hey NFL,

You all Rawk!
Been banging my head about this for a few weeks
Getting a WHO AM I [FF]
any ideas?


Did you ever get multiple devices to work on the SPI bus along with the accelerometer? Technically, when the chipselect for the accelerometer is disabled, it goes into I2C mode. The clock and data lines for the SPI bus are still connected, however, and I did not know if this caused any data transfer problems of malfunction of the accelerometer since it would be receiving the SPI bus data. I had planned on putting a high impedance buffer that only connected the SPI bus to the accelerometer when then chipselect was enabled, but I was curious if, based on your hands on experience, I need to do this.



Hello Julian,

I’m currently trying to develop an application which works with the LIS3L. I’m not using Audrino but a NXP LPC2129 .
In the first step I was polling the registers with your loop() method. If I move around the chip the values received change so it obviously works. Now I wanted to get the same thing done using interrupts generated by LIS3L. But no interrupts are generated. Did you also try to work with interrupts? If so, could you provide me with the steps for setting up the LIS3L interrupt suff?
If I configure LIS3L to send the DRDY-Signal to the RDY/INT pad the ISR is called continuously. When switching vom DRDY to IEN (in CTRL_REG2) the ISR won’t be called anymore. Is it correct that the interrupt signal is triggered by Direction Detection or FreeFall/WakeUp generator?

Thank you,

Got the new arduino 10000 and life is better, the NG and Lis just don’t get along very well

Thanks for these instructions! Makes it easy to work with Arduino and this chip. I tried to run it but didn’t work until I realized that you shouldn’t be too creative with wiring ;) apparently the SPI clock generator is hardwired to PIN 13 in the chip and you just can’t change it in code and expect it to work. Had to refer to the Atmel chip datasheet to figure that out… but all is well that ends well, so good stuff.


I’ve never actually used the interrupt feature of the LIS3LVO2DQ — sorry. Let me know how it goes, though.


Folks like Matthias and myself grappling with LIS3LVxxx interrupts might find this (somewhat old) document of help:


Hello, Im trying to read the uAccelerometer using SPI Bus and a C8051 from Silicon Labs that has an SPI controller onboard.

I sent the command to read WHO AM I register (0x0F). The first time I read it I get 0xFF as answer. If I read it again, I get 0xA3. After that, any read from any reg, I get 0xA3, no mater what I read… Any ideas?

Tough to say. The communications is almost certainly not working properly, assuming that the accelerometer and the microcontroller are working okay. I’d double check the connections between your microcontroller (I’m not familiar with this one) and the accelerometer and make certain that the right things are connected together. MOSI/MISO and whatever you’re using for chip enable are connected properly to the accelerometer.

Without knowing anything about the C8051, it’s hard to help out. I’d check the developer’s forums and so forth for that particular microcontroller. First, do everything I could to solve the problem yourself — double-check connections, study-up on the SPI protocol, read the documentation for the microcontroller, borrow a friend’s logic analyzer or oscilloscope and check the signals. I’ve always found that watching the data move on a scope can reveal lots. It may be the bit ordering, or the data mode of the SPI protocol needs to be set properly on the C8051 to match that of the accelerometer.

Since SPI uses a clock to signal data transfers, there are variosu “modes” that the clock can be set to. For example, the phase and polarity of the clock can be set to determine the conditions under which data is sent/read. Is the signal on the data line sampled when the clock signal goes from “high” to “low” or when it goes from “low” to “high”? This is usually referred to as the clock phase. Then, there’s the clock polarity to consider, too.

For the Atmega microcontrollers, this needs to be configured in order for the protocol to communicate properly. It requires reading the specifications for the chip that you’re communicating with — the accelerometer or whatever — and finding out how its expecting to communicate. And then, you need to read the specifications for your microcontroller and set whatever register bits or what-have-you to determine how to get it to do data transfers accordingly.

Thanks for your answer Julian. I have been using a Logic Analizer to find out the problem, but have not been able to do so. Its the same for the C8051, you need to set all clock parameters. Now I have them set to the correct settings according to the Acc datasheet. I have not been able to find the problem. I still get 3A always after reading WHO AM I. I’ll keep trying. When I find the answer (which I MUST do in a few days, my “life” depends on that! :) ) I will post the problem.
Thanks again

I was trying to use your code to quickly implement the LIS3LV02DQ on my Arduino. I see that you had overcome a number of problems and documented them in your program. When I went to try to down load your program by double tapping:

Here’s the full source code for interfacing to the LIS3LV02DQ using an Arduino

At the URL: (bad old URL)

It came up as not found. Can you please fix the link?

Jim Kraemer

I’ve got my Arduino Diecimila connected to the LIS and they are working great.

One newbie question:

For a safe bet, I am considering to use the new Sparkfun’s logic level converter(5v-3.3v). In this case, then, would the SCL(clock) and CS(chip select) be connected to the tx side of the converter?

Thanks in advance

Bryan K.

    Good question Bryan. I actually have never used Sparkfun’s logic level converter, but I’m sure it’ll work fine. The one thing I’m not 100% of is the bidirectional hook-up. The Sparkfun guys say it can be used for I2C and SPI, so I’m sure it can. I guess you might try connected the high-level SCL side (Arduino) to both the high-level receive and transmit lines, and the low-level SCL side (LIS3LV02DQ) similarly. Same with CS. I’m guessing this’ll work just fine.


I’m still trying to find out if the Chip Select needs to be pulled low at power up to assure SPI operation rather than I2C operation.
Any help is appreciated.


    On page 17, section 5, it says that “The serial interfaces are mapped onto the same pads. To select/exploit the I2C interface, CS line must be tied high (i.e connected to Vdd_IO).” So, if CS remains high, the chip will assume that the protocol is I2C. But, I’d guess if you manipulate the SPI interface properly, then it’ll use the 3- or 4-wire protocol. I don’t think I had to tie this line low at power-up, but it might’ve been low without me knowing it just based on the design of the circuit.

    I2C and SPI are quite similar in that they’re synchronous clock-driven communication. SPI just adds a chip select line to the whole thing rather than using the addressing scheme of I2C.

    Also note that the chip supports 3- and 4- wire modes (see pages 19 and 21.) Figure out which one you’re using — that may be part of the problem.

    Other than that, I’m not sure what might be happening. Maybe you should throw a logic analyzer or something on it.


julian, this code of yours is very precise, i was wondering if you have developed the code for the c programming to use with atmel AVR, if you can post that, then it will be a great help.

I want to connect 4 LEDs to read the status of the acceleration. depending on which direction the board is facing, the LED light turns on. Can you tell me how to do that?


    Hook up the accelerator to an Arduino. Read the data from the accelerometer using code like that above. If the data indicates a tilt to the left, turn on LED 1 using the Arduino, which would be hooked up on one of its digital outputs to LED 2 through a resistor.. If the data indicates a tilt to the right, turn on LED 2 using the Arduino, which would be hooked up on one of its digital outputs to LED 2 through a resistor. Etc. Pretty straightforward. You’ll need to learn how to work the Arduino, which you can find more about at the Arduino website. You’ll also need to learn how to hook up an LED to an Arduino, which you can find more about at the Arduino website. That’s it. Easy-peasy. Try it, and learn.


Julian thanks for the code, accelerometer is giving cool readings. Now if I want to take the varying values of all the axis and store it directly on the cf/mmc/sd, is it possible to only store values on these memory cards using avr or arduino instead of having it in the arduino environment.

Any kind of help is appreciated thanks

    Hey Nareem — I’m totally not following your question..what cf/mmc/sd card are you talking about? Best as I know, there is no mass storage attached to the Arduino, but I bet you can probably get one attached. If that’s what you’re talking about, the device probably has some API that’ll allow the Arduino to talk to it. If there isn’t, then you may have to write your own code to talk to a cf/mmc/sd card or whatever. “Arduino” is AVR; it’s just a code wrapper and build environment that makes writing C/C++ for the AVR microcontrollers a little easier. When you write code for the Arduino, you’re writing code C/C++, so just put in your C/C++ as you normally would.

    I’ve attached neither an Arduino or an AVR microcontroller to external storage except for smallish I2C flash chips, not storage cards so I can’t help you specifically. For example, I’ve used flash storage in this project:


I was wondering how could you use the x, y and z axis for the calculation of distance ?

    That would be quite difficult in most cases without some much more complicated math to go along with it. It’s actually a hard problem, requiring various kinds of statistics and mathematical filtering of the data. The formulas for even doing pedometer like calculations are closely held information by manufacturers, and even with that you’d only be counting steps and would at best estimate distance.

Hi, I’be hooked up the accelerometer to an arduino diecimilia, double checked the wiring but all I get is this :

NEG_Xx_val=4095 y_val=-1 z_val=-1
NEG_Xx_val=4095 y_val=-1 z_val=-1

can someone enlight me please ?

    Without knowing/seeing much more, it looks like you’re not communicating with the accelerometer. The SDA line is not changing, it seems – it looks like it’s staying logic high. I doubt anything seriously wrong is happening — just something overlooked, or a timing issue. My approach, which may be different from yours, would be to put a logic analyzer on it. Check to see that the clock like (SCL) actually looks like a clock. Check continuity across SDA from the Arduino and the actual Atmel chip to the accelerometer pin for SDA. Check power to the accelerometer. Voltage levels — are they consistent? Or are you running the accelerometer at 5v rather than the specified 3.3v? This could cause problems, as well and you may need to look into logic level adjustments.

    Debug one thing at a time.

    Good luck!


can you show me (us) how you calculate the x,y,z data into distance?
i sort of need it. ’cause we using the accelerometer as a sensor for a mouse.


    Determining distance from acceleration requires some simple math.

    Distance = velocity * time
    Velocity = acceleration * time.


    Distance = acceleration * time * time.

    Since the acceleration is time dependent — meaning that it is changing quite often, especially if a human is moving the device with the accelerometer — the best you can do is to integrate acceleration over time for tiny time intervals. In other words, take an acceleration reading as quickly as possible, note how much time has passed in that interval, and multiply the acceleration value by that time interval. That will give you the velocity (acceleration * time). Multiply that by the time interval _again_ and you’ll get the displacement (distance) from where the reading first started.

    That should do it. Note that this may likely be accurate initially, but will probably slip quickly over time, so if you have some other mechanism to reset the initial value to a known location, you’ll be better off. Perhaps for small movements it will be accurate, but it would be interesting to see in your test case how much error gets introduced because of this method. Try using different time intervals to see the effects – 1 millisecond, 10 milliseconds, etc.

    Let me know how it goes!


hi to all
i want to inerface acceleroemater with atmega128
pleas guide me how i am staring because i dint know about the acceleromater specfication..
send me useful regarding atmega128 to study it..?
thank you in advance


    That is difficult to do without you describing a specific problem you are having. The Atmega128 is similar to the variety of Atmega used here, but with more (128k) of flash memory. The principles of how to make it interface with this accelerometer are the same though. You will have to try some things to make it “not” work for you and then start from there. Unfortunately, the Arduino environment does not compile for the Atmega128 so you are introducing yourself to one disadvantage. I would suggest either starting with an Arduino and learning from that platform. Otherwise, you must translate the Arduino code (which is ‘C’ ultimately) and put it in an environment such as AVR Studio and work from that development environment.

Have you ever experienced damage to the chip due to the 5v you are using as opposed to the specified 3.6? I’m getting values that seem to have an offset when I use the 5v. An axis normal to the ground gives me values around 1150. But when I use the arduino’s 3.3v, all x, y, and z values become static at 32767. Any insight you have would be be appreciated.

Thanks for your really thorough and detailed explanations it has been really helpful!

I just got a LIS3LV02DL from STMicroelectronics and want to use it with my Arduino Duemilanove. The LIS3LV02DL that I have seems to have similar specs to the LIS3LV02DQ that you used, but the actual size and shape of the chips are different and have a different pin arrangements.

Here is a link for your reference to the data sheet for the LIS3LV02DL….

Do you think I would be able to use the same instructions you laid out with the accelerometer I have?

Also another thing to note is that the accelerometer is just the chip… i noticed yours is soldered to a circuit board with a couple of other components on it. I was probably just going try to solder pins on mine to connect to a breadboard, then connect any other necessary components there as I try to get it to work.

Any input you have would be really helpful! Thanks.

    Hi Drew,

    Curious new embodiment of the device, there. It doesn’t look significantly different. I can’t say that you could use the exact same instructions, but it could be a start. Switching over to a new device should be done carefully. Read the reference sheet and look for any indication of changes or updates. I personally would start with seeing if there are any electrical differences — power, voltages, timing requirements and that sort of thing. Fortunately it looks like this new unit uses I2C which is standardized outside the context of any specific device — or should be. You could drunk duck hunt and just give it a try — so long as supply voltages are okay, you probably won’t damage the device shooting bitshot at it and seeing if anything reasonable drops from the sky. Or, you could just see why they call this one *DL rather than *DQ. It may be a packaging difference or pin layout as you mention.

    The soldering pins business — I mean, go for it if you feel you can get good electrical connectivity and mechanical integrity. It may be more headaches than it’s worth with wires popping while your debugging, amping up the ol’ fiddling-with-tiny-stuff-frustration-quotient..It might be worth laying out a break-out board and sending it off to be fab’d. That stuff can happen pretty quickly these days and, in the meantime, you can spend time on the other, other project I’m sure is sitting around.


Naive question here: what do you use to reliably connect the breakout board to the breadboard? I’ve been recommended to use jumper wire, but it looks like you’re not using that, and from my experience it doesn’t seem a good way of making a reliable connection to these boards. So what are you using here?

I have a ProtoAdvantage boardPA0066 QFN 28 7x7mm 0.8mm with the same chip. Could you do the same tutorial using a propeller.

    Sorry bub. That is left as an exercise for the reader! That project is four years on by now. Should be fairly straight forward – it’s just I2C comms of the basic sort. The flow would be nearly identical and I’m pretty sure there are plenty of Propeller I2C examples out there. Please post your results though!

I hooked it up an MMA7455L with arduino Duemilanove. I´m not sure quick well what the problem, I´m pretty sure that the wiring its Ok. It´s keeping reads :
WHO_AM_I [0]
no matter how its move.

Any clue or tip to check the problem, and making works….

Thanks a lot

    I think you’re in for a bit of debugging here. Either the Arduino is not communicating properly to the accelerometer (I’ve never used the particular one you are using) — the protocol is quite particular and you want to make sure you’ve configued the accelerometer to expect to communicate in the right fashion..either I2C or SPI or something else, you’ll need to check the specifications of the device. I often run into these sorts of problems, which can be frustrating. I think the best investment I ever made was in an Oscilloscope and, even better — a digital logic analyzer like the Saleae which I reviewed here: (Saleae).

Thanks for the good code.
Converting accelerations into distance through a double integration is a task for experts. The LIS accelerometers are stable enough only for a few seconds of integration before the distance error is off the charts – the error grows exponentially with time. Another basic issue is that you must always know very precisely in which direction the axes directions of the physical device are pointing, relative to the starting direction. Any unwanted miniscule rotation of the physical accelerometer will ruin the measurement. That is why you usually combine accels with gyros, because the gyros will keep track of the orientation of the accel. This is extremely complicated stuff. The only credible experiments you can do at home with a 3-axis accel is to move it back and forth in straight lines, perhaps following a ruler laid out on a table. The nice application with a pedometer does not build on a double integration to get the distance. Stay away from the double integration :)

I dug out my ol’ trusty LIS3LV02DQ for a current project only to find most links leading here, and the link to the source code to be down.

I went with this derivative instead: – using I2C, which works fine.


[...] be honest I haven’t a clue what it does. Neither does Luke. If anyone can help with the Parallax RFID reader tutorial then please [...]

LIS3LV02DQ Triple Axis Accelerometer…

The project it’s based on a nice little 3-axis accelerometer from STMicroelectronics with a SPI bus, which makes it handy for interfacing in microcontroller style applications.  This device could be interfaced with an AVR, but the author chose …

[...] to learn about accelerometers and the SPI bus. He picked up an accelerometer over at Sparkfun and proceeded to make it work. He ultimately wanted to make it work with an Atmel AVR, but started out with the Arduino for [...]

[...] this value could be shorter. Here is the code, don’t forget to check out [Troy]‘s code for more heavily commented accelerometer [...]

[...] this value could be shorter. Here is the code, don’t forget to check out [Troy]‘s code for more heavily commented accelerometer [...]

[...] although this value could be shorter. Here is the code, don’t forget to check out [Troy]‘s code for more heavily commented accelerometer [...]

[...] power and connections as in the diagrams below, full instructions and lots of interesting info by Julian Bleecker is here. Note these diagrams use a different accelerometer but the pins are equivalent. Triple Axis [...]

Copyright © 2014 Near Future Laboratory