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 / Control Philips Hue from Arduino Ethernet Shield
Created April 5, 2015 20:43
Example of using an Arduino with Ethernet shield to control Philips Hue, with PIR motion sensor on i/o pin 2.
/*
Talking to Hue from an Arduino
By James Bruce (MakeUseOf.com)
Adapted from code by Gilson Oguime. https://github.com/oguime/Hue_W5100_HT6P20B/blob/master/Hue_W5100_HT6P20B.ino
*/
#include <SPI.h>
#include <Ethernet.h>
// Hue constants
// Slightly modified Adalight protocol implementation that uses FastLED
// library (http://fastled.io) for driving WS2811/WS2812 led stripe
// Was tested only with Prismatik software from Lightpack project
#include "FastLED.h"
#define NUM_LEDS 114 // Max LED count
#define LED_PIN 6 // arduino output pin
#define GROUND_PIN 10
#define BRIGHTNESS 255 // maximum brightness
@jamesabruce
jamesabruce / ESP_RELAY_MQTT.ino
Created February 12, 2016 10:40
Simple MQTT controlled relay running on NodeMCU dev board on pin d2/gpio4
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <PubSubClient.h>
#define RELAY 4 // pin labelled d2
// Update these with values suitable for your network.
const char* ssid = "YOURWIFI";
@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;
@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);
@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 / 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)
/*
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>
@jamesabruce
jamesabruce / neomatrix_pixel_display.ino
Created January 22, 2015 17:55
Sample code for working with the giant LED screen described at MakeUseOf.com, using Adafruit Neomatrix and GFX libraries
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define XSIZE 15
#define YSIZE 14
#define PIN 6
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(XSIZE, YSIZE, PIN,
NEO_MATRIX_BOTTOM + NEO_MATRIX_LEFT +
@jamesabruce
jamesabruce / Officelight_accessory.js
Last active September 5, 2018 19:20
HAB-NodeJS accessory for MakeUseOf Wi-Fi light tutorial
// MQTT Setup
var mqtt = require('mqtt');
console.log("Connecting to MQTT broker...");
var mqtt = require('mqtt');
var options = {
port: 1883,
host: '192.168.1.99',
clientId: 'MakeUseOf Wifi Light'
};
var client = mqtt.connect(options);