ONE – Accelerometer + Magnetometer

 

Accelerometer

The SODAQ ONE V1 and V2 have a different accelerometer. On the ONE v1 there is the LSM303 which is not only an accelerometer but also an magnetometer. We moved in ONE v2 to the LIS3DE for its low power features.

Go to LSM303
Go to LIS3DE

 

LSM303 / ONE v1

Install the library

Go to: Sketch → Include Library → Manage Libraries…
Search for “LSM303”
Install the LSM303 by Pololu

Sample Sketch

#include <Wire.h>
#include <LSM303.h>

LSM303 compass;

char report[80];

void setup()
{
  SerialUSB.begin(9600);
  Wire.begin();
  compass.init();
  compass.enableDefault();
}

void loop()
{
  compass.read();

  snprintf(report, sizeof(report), "A: %6d %6d %6d    M: %6d %6d %6d",
    compass.a.x, compass.a.y, compass.a.z,
    compass.m.x, compass.m.y, compass.m.z);
  SerialUSB.println(report);

  delay(100);
}

LIS3DE / ONE v2

Library

Download the LIS3DE Library here: Sodaq_LIS3DE
Move the folder to Documents->Arduino->libraries