This file contains hidden or 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
// | |
// ESP32 in DeepSleep reading a BME280 every few seconds | |
// | |
#include <Arduino.h> | |
#include <Wire.h> | |
#include <HardwareSerial.h> | |
#include <Adafruit_BME280.h> | |
#define SERIAL_BAUD 9600 |
This is an attempt at a Python script to make use of Pimoroni's Enviro pHAT to calculate the average light level (lux) in a room, and to trigger an action if the lux drops below a pre-determined threshold (in this case, send a webhook command to turn on some Philips Hue lights).
I "borrowed" some of the code used in Pimoroni's BME680 Breakout Board to calculate the average lux level. The idea being that the Enviro pHAT captures the lux for 15 seconds, then calculates the average reading that is then used to trigger the action.
For simplicity, I'm using IFTTT's Maker channel to use webhooks. These webhooks link to an IFTTT applet that triggers a Philips Hue bulb at home based on the parameters passed.
This file contains hidden or 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
#!/usr/bin/env python | |
import sys | |
import time | |
try: | |
import psutil | |
except ImportError: | |
sys.exit("This script requires the psutil module\nInstall with: sudo pip install psutil") |
This file contains hidden or 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
from colorsys import hsv_to_rgb, rgb_to_hsv | |
import motephat | |
from flask import Flask, jsonify, make_response | |
app = Flask(__name__) | |
motephat.configure_channel(1, 16, False) | |
motephat.configure_channel(2, 16, False) | |
motephat.configure_channel(3, 16, False) | |
motephat.configure_channel(4, 16, False) |
This file contains hidden or 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
#!/usr/bin/python | |
import urllib2 | |
from urllib import quote | |
import time | |
import json | |
from config import ( | |
ig_style, | |
ig_account, | |
ig_access_token, |
This file contains hidden or 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
#!/usr/bin/python | |
import tweepy | |
import urllib2 | |
import time | |
# For Twitter: Add the relevant keys, tokens and secrets from your Twitter app made here: https://apps.twitter.com/ | |
consumer_key = '' | |
consumer_secret = '' |
This file contains hidden or 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
#!/usr/bin/python | |
import urllib2 | |
from urllib import quote | |
import json | |
# Variables - configure the bits below to get your script working. | |
style = '#3b5998' # Colour for the message - default is Facebook blue | |
fb_page = '' # Facebook Page name |
This file contains hidden or 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
#!/usr/bin/python | |
import tweepy | |
import urllib2 | |
import time | |
# For Twitter: Add the relevant keys, tokens and secrets from your Twitter app made here: https://apps.twitter.com/ | |
consumer_key = '' | |
consumer_secret = '' |