Created
April 24, 2015 21:39
-
-
Save ersatzavian/56522ad28d1bb037e45c to your computer and use it in GitHub Desktop.
9dof-tail-log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
device.on("data", function(data) { | |
server.log(http.jsonencode(data)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/electricimp/lsm9ds0 | |
#require "LSM9DS0.class.nut:1.0" | |
i2c <- hardware.i2c89; | |
i2c.configure(CLOCK_SPEED_400_KHZ); | |
imu <- LSM9DS0(i2c); | |
function poll() { | |
imp.wakeup(1,poll); | |
local acc = imu.getAccel(); | |
local mag = imu.getMag(); | |
local gyr = imu.getGyro(); | |
agent.send("data", { | |
acc = acc, | |
mag = mag, | |
gyr = gyr | |
}); | |
} | |
/* RUNTIME START ------------------------------------------------------------ */ | |
// Enable the gyro in all axes | |
imu.setPowerState_G(1); | |
// Enable Accelerometer in all axes | |
imu.setEnable_A(1); | |
// Set the Accelerometer data rate to a nonzero value | |
imu.setDatarate_A(10); // 10 Hz | |
// Enable the Magnetometer by setting the ODR to a non-zero value | |
imu.setDatarate_M(50); // 50 Hz | |
imu.setModeCont_M(); // enable continuous measurement | |
poll(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment