This file contains 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
# Python 2.7.9 | |
# Uses pi_switch from https://github.com/lexruee/pi-switch-python | |
# See pi_switch readme for details on setup | |
from pi_switch import RCSwitchReceiver | |
import time | |
import csv | |
receiver = RCSwitchReceiver() | |
receiver.enableReceive(2) |
This file contains 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
// --------------------------------------------------------------------------- | |
// Sketch for a Lego car with two servos (with continuous rotation) for left | |
// and right wheel and an SR04 ultra sonic sensor for measuring the distance to | |
// objects in front of the car | |
// --------------------------------------------------------------------------- | |
#include <NewPing.h> | |
#include <Servo.h> | |
// | |
// SR04 distance sensor setup |
This file contains 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
/* | |
* This is an example sketch on using aREST with an Adafruit Feather Huzzah board | |
* The sketch starts a web server and handles requests as REST calls via aREST | |
* The board uses two relays on pins 12 and 13 that can be toggled via the REST API | |
* Examples: | |
* HuzzahIP/digital/12 -> returns the state of relay 1 | |
* HuzzahIP/digital/13 -> returns the state of relay 2 | |
* HuzzahIP/digital/12/0 -> turns relay 1 off | |
* HuzzahIP/digital/12/1 -> turns relay 1 on | |
* HuzzahIP/digital/13/0 -> turns relay 2 off |
This file contains 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
void setup() | |
{ | |
setupWiFi(); | |
aio.begin(); | |
dht.begin(); | |
float h = dht.readHumidity(); | |
float t = dht.readTemperature(); |
This file contains 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
void sendDataToAdafruitIO(float temperature, float humidity) | |
{ | |
unsigned long startTime = millis(); | |
if (isnan(temperature) || isnan(humidity)) | |
{ | |
Serial.println("Failed to read from DHT sensor!"); | |
return; | |
} |
This file contains 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
void sendDataToAdafruitIO(float temperature, float humidity) | |
{ | |
unsigned long startTime = millis(); | |
if (isnan(temperature) || isnan(humidity)) | |
{ | |
Serial.println("Failed to read from DHT sensor!"); | |
return; | |
} |
This file contains 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 flask import Flask, jsonify, request | |
from outletdefinitions import outlets | |
import codesender | |
app = Flask(__name__) | |
@app.route("/Outlets/api/outlets", methods=["GET"]) | |
def get_outlets(): | |
return jsonify({"outlets" : outlets}) |
This file contains 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
import pi_switch | |
byte0codeON = 0x55 | |
byte0codeOFF = 0x54 | |
byte2 = 0x15 #This is group 1 | |
buttonToIDCodesMap = { | |
1: 0x15, | |
2: 0x45, | |
3: 0x51, |
This file contains 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
outlets = [ | |
{"id":"1","name":"Spotlights"}, | |
{"id":"2","name":"Stereo"}, | |
{"id":"3","name":"Table lamp"}, | |
{"id":"4","name":"Floor lamp"} | |
] |
This file contains 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 flask import render_template | |
@app.route("/Outlets/",methods=["GET"]) | |
def index(): | |
return render_template("index.html") |