Skip to content

Instantly share code, notes, and snippets.

@cat-haines
Last active August 29, 2015 14:16
Show Gist options
  • Save cat-haines/ce78ab030e4017a803f2 to your computer and use it in GitHub Desktop.
Save cat-haines/ce78ab030e4017a803f2 to your computer and use it in GitHub Desktop.
device.on("data", function(data) {
server.log(http.jsonencode(data));
});
// 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 ------------------------------------------------------------ */
poll();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment