Skip to content

Instantly share code, notes, and snippets.

Bryan Fink beerriot

View GitHub Profile
@beerriot
beerriot / altimeter-posting.lua
Created Feb 20, 2017
Beer IoT (Part 4) example code: Altimeter Posting
View altimeter-posting.lua
now = he.now() -- time that we took the reading
-- "f" is "floating point type
-- port, time, type, value
he.send("x", now, "f", x)
he.send("y", now, "f", y)
he.send("z", now, "f", z)
@beerriot
beerriot / altimeter-reading.lua
Created Feb 20, 2017
Beer IoT (Part 4) example code: Altimeter Reading
View altimeter-reading.lua
addr = 0x53 -- Default I2C address
reg_pwr_ctl = 0x2D -- Power control register
pwr_ctl_on = 0x08 -- Active measurement mode
reg_x0 = 0x32 -- X0 register
length = 6 -- Bytes for a full measurement
-- Power up
he.set_power(true)
-- ADXL345 starts in an idle mode; activate it
You can’t perform that action at this time.