Skip to content

Instantly share code, notes, and snippets.

View alexellis's full-sized avatar
📖
Check out my eBook on Go

Alex Ellis alexellis

📖
Check out my eBook on Go
View GitHub Profile
@alexellis
alexellis / enviroflux.py
Last active July 29, 2016 08:29
Post enviro-phat data into InfluxDB
# You can start an influxDB + grafana instance through Docker + docker-compose: see my gist here:
# https://gist.github.com/alexellis/ce7253d48b6d5a83ca17790ea6249c9b
import time
from envirophat import weather, leds
from influxdb import InfluxDBClient
# set this variables, influxDB may well be localhost
host = "192.168.0.x"
port = 8086
@alexellis
alexellis / docker-compose.yml
Last active August 5, 2016 21:37
InfluxDB plus Grafana example
# This file will download + start up InfluxDB and Grafana and configure them for you.
# Then head over to localhost:3000, password: admin/admin.
# Add a datasource for InfluxDB and then add a dashboard and pick the meaurements you want to see.
version: "2.0"
services:
influx:
image: influxdb
ports:
- "8083:8083"
- "8086:8086"
@alexellis
alexellis / grafana.envirophat.json
Created August 5, 2016 22:24
Grafana dashboard.json for Envirophat
{
"id": 1,
"title": "Environment",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"sharedCrosshair": false,
"rows": [
@alexellis
alexellis / ultrasonic.py
Created August 10, 2016 18:52
Ultrasonic sensor for use with Explorer/p/Hat
# Copyright Alex Ellis 2016
# License: MIT
import RPi.GPIO as GPIO
import time
class distanceMeasure:
def __init__(self,trigger,echo):
self.GPIO_ECHO=echo
self.GPIO_TRIGGER=trigger
@alexellis
alexellis / ultrasonic.py
Created August 10, 2016 18:52
Ultrasonic sensor for use with Explorer/p/Hat
# Copyright Alex Ellis 2016
# License: MIT
import RPi.GPIO as GPIO
import time
class distanceMeasure:
def __init__(self,trigger,echo):
self.GPIO_ECHO=echo
self.GPIO_TRIGGER=trigger
@alexellis
alexellis / ultrasonic.py
Created August 10, 2016 18:52
Ultrasonic sensor for use with Explorer/p/Hat
# Copyright Alex Ellis 2016
# License: MIT
import RPi.GPIO as GPIO
import time
class distanceMeasure:
def __init__(self,trigger,echo):
self.GPIO_ECHO=echo
self.GPIO_TRIGGER=trigger
@alexellis
alexellis / flux.py
Last active August 12, 2016 02:36
My Pimoroni script to input into InfluxDB
# This script outputs sensor data to InfluxDB which can then be dashboard'd and graph'd through Grafana.
# The script runs on the Pi, Grafana + InfluxDB run on a PC through Docker or manually as installed applications.
# For using Docker on your PC use my docker-compose.yml file: https://gist.github.com/alexellis/ce7253d48b6d5a83ca17790ea6249c9b
# When Grafana is up + running, this JSON file contains the configured dashboard:
# https://gist.github.com/alexellis/74ec5f682d5790d4985c5d50b30bc3b5
# This program is to be run on each Pi with Envirophat.
@alexellis
alexellis / environment.json
Created August 13, 2016 21:32
Environment JSON file for Grafana
{
"id": 1,
"title": "Environment",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"sharedCrosshair": false,
"rows": [
@alexellis
alexellis / colour_cycle.py
Last active August 16, 2016 20:24
colour_cycle.py
# sunrise.py
# colors = [
# {"r": 0, "g": 0, "b": 0},
# {"r": 255, "g": 0, "b": 0},
# {"r": 0, "g": 255, "b": 0},
# {"r": 0, "g": 0, "b": 255},
# {"r": 255, "g": 255, "b": 255},
# {"r": 0, "g": 0, "b": 0}
# ]
@alexellis
alexellis / main.go
Created September 9, 2016 21:20 — forked from lizrice/main.go
Container from scratch
package main
// @lizrice, mostly copied from @doctor_julz: https://gist.github.com/julz/c0017fa7a40de0543001
import (
"fmt"
"os"
"os/exec"
"syscall"
)