Skip to content

Instantly share code, notes, and snippets.

@fvdbosch fvdbosch/ Secret
Last active May 14, 2017

What would you like to do?
Sending Enviro pHAT data to Adafruit IO
#!/usr/bin/env python
from envirophat import weather, light, analog, motion, leds
from Adafruit_IO import Client
# Personal Adafruit IO Key
aio = Client('<Adafruit IO Key>')
# Select which sensors to use
bmp280_enabled = True # Temp and Pressure
tc3472_enabled = True # Light and Colour
lsm303d_enabled = True # Motion and Heading
ads1015_enabled = False # Analog inputs
# Send the Enviro values to Adafruit IO feeds
if bmp280_enabled:
# Temperature
t = round(weather.temperature(), 1)
aio.send("enviro_temp", t)
# Pressure
p = round((weather.pressure()/100), 2)
aio.send("enviro_pressure", p)
if tc3472_enabled:
# Light
l = round(light.light(), 0)
aio.send("enviro_light", l)
# Colour
r, g, b = light.rgb()
aio.send("enviro_colour_r", r)
aio.send("enviro_colour_g", g)
aio.send("enviro_colour_b", b)
if lsm303d_enabled:
# Motion
x, y, z = motion.accelerometer()
aio.send("enviro_motion_x", x)
aio.send("enviro_motion_y", y)
aio.send("enviro_motion_z", z)
# Heading
h = motion.heading()
aio.send("enviro_heading", h)
if ads1015_enabled:
# Analog 0
a0 = round(, 2)
aio.send("enviro_analog_0", a0)
# Analog 1
a1 = round(, 2)
aio.send("enviro_analog_1", a1)
# Analog 2
a2 = round(, 2)
aio.send("enviro_analog_2", a2)
# Analog 3
a3 = round(, 2)
aio.send("enviro_analog_3", a3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.