Skip to content

Instantly share code, notes, and snippets.

View jamesabruce's full-sized avatar

James Bruce jamesabruce

  • Cornwall, UK
View GitHub Profile
@jamesabruce
jamesabruce / lock.py
Created July 14, 2015 16:22
DIY Proximity Lock v.01
#!/usr/bin/python
import bluetooth
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
RELAY = 23
GPIO.setup(RELAY, GPIO.OUT)
@jamesabruce
jamesabruce / detect.py
Created July 14, 2015 16:52
Detect user through Bluetooth demo, Python
#!/usr/bin/python
import bluetooth
import time
while True:
print "Checking " + time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime())
result = bluetooth.lookup_name('78:7F:70:38:51:1B', timeout=5)
if (result != None):
print "User present"
@jamesabruce
jamesabruce / detect.py
Created August 19, 2015 11:53
OpenHAB on Raspberry Pi Tutorial: Detect User Presence via Bluetooth, report to RESTful OpenHAB interface
#!/usr/bin/python
import bluetooth
import time
import requests
from requests.exceptions import ConnectionError
payload =''
while True:
/*
Basic MQTT example
*/
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
// Our first sensor, a cheap DHT11 temperature and humidty sensor
#include <DHT.h>
{"text":"These posts are still doing well: <http://www.makeuseof.com/tag/control-philips-hue-lights-arduino-and-motion-sensor/> (1392) ... <http://www.makeuseof.com/tag/3-easy-ways-tablet-stand/> (1037) ... <http://www.makeuseof.com/tag/upgrade-ps4s-hard-drive/> (2966) ","unfurl_links": true}
@jamesabruce
jamesabruce / mysensors_humidity_relay_nonblocking.ino
Created December 11, 2015 16:11
MySensors Example - Humidity and Relay with Non-blocking Loop
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
@jamesabruce
jamesabruce / 4wd-robot-test.ino
Created December 17, 2015 10:18
First program for 4WD Arduino Robot Kit
// Motor A pins (enableA = enable motor, pinA1 = forward, pinA2 = backward)
int enableA = 11;
int pinA1 = 6;
int pinA2 = 5;
//Motor B pins (enabledB = enable motor, pinB2 = forward, pinB2 = backward)
int enableB = 10;
int pinB1 = 4;
int pinB2 = 3;
@jamesabruce
jamesabruce / robot_with_ping.ino
Created December 19, 2015 15:08
Beginner Robot with Ping Sensor
#include <NewPing.h>
//Tell the Arduino where the sensor is hooked up
NewPing sonar(12, 13);
int enableA = 11;
int pinA1 = 6;
int pinA2 = 5;
int enableB = 10;
#include <NewPing.h>
//Tell the Arduino where the sensor is hooked up
NewPing sonar(12, 13);
long inches;
void setup() {
//Activate the serial monitor so you can see the output of the sensor
Serial.begin(9600);
@jamesabruce
jamesabruce / NodeMCU-MQTT-Siri-Wifi-Light.ino
Created January 29, 2016 11:37
Wi-Fi Neopixel light controlled over MQTT, to be connected through HAP-NodeJS to Siri
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <PubSubClient.h>
#include <Adafruit_NeoPixel.h>
#define PIN 4
Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, PIN, NEO_GRB + NEO_KHZ800);