Skip to content

Instantly share code, notes, and snippets.

@harrisonhjones
harrisonhjones / example.cpp
Last active December 20, 2016 08:11
Particle IO - serialEvent Emulation
// #define USING_SERIAL2 // Uncomment if you need to use Serial2
#ifdef USING_SERIAL2
#include "Serial2/Serial2.h" // Only needed if you use Serial2
void serialEvent2(){
Serial.print("Data is available on serial2");
Serial2.read();
}
#endif
@harrisonhjones
harrisonhjones / example.cpp
Created September 25, 2015 01:56
Particle IO - ElapsedMillis Example
#include "elapsedMillis/elapsedMillis.h"
elapsedMillis timeElapsed;
unsigned char readSoilStateMachine = 0;
int rd = 0; // Global soil moisture value
void loop()
{
readSoil(); // Run this as often as possible (it's non-blocking)
}
@harrisonhjones
harrisonhjones / example.cpp
Last active September 23, 2015 06:31
Particle IO - TCP Client Test
TCPClient client;
bool over = false;
void setup()
{
// Make sure your Serial Terminal app is closed before powering your device
Serial.begin(9600);
// Now open your Serial Terminal, and hit any key to continue!
while(!Serial.available()) SPARK_WLAN_Loop();
@harrisonhjones
harrisonhjones / example.ino
Created September 21, 2015 18:42
Particle IO - InternetButton - IFTTT
#include "InternetButton/InternetButton.h"
#include "math.h"
// Set up lots of global variables that we'll be using
InternetButton b = InternetButton();
uint8_t button1 = 0;
uint8_t button2 = 0;
uint8_t button3 = 0;
uint8_t button4 = 0;
uint8_t buttonAll = 0;
@harrisonhjones
harrisonhjones / phpSpark.class.php
Created September 20, 2015 19:07
phpDashboard - phpSpark class
<?php
/*
* @project phpSpark
* @file phpSpark.class.php
* @authors Harrison Jones ([email protected])
* Devin Pearson ([email protected])
* @date March 12, 2015
* @brief PHP Class for interacting with the Spark Cloud (spark.io)
*/
@harrisonhjones
harrisonhjones / particleTMP36Example.ino
Last active September 19, 2015 19:37
Example: Reads a TMP36 temperature in a loop and exposes it as a Cloud variable and sends it out via serial
// Particle TMP36 Example
// Author: [email protected]
// Description: Reads a TMP36 temperature in a loop and exposes it as a Cloud variable and sends it out via serial
// Connection: Connect VS to 3.3v, GND to GND, VOUT to A0. See http://www.analog.com/media/en/technical-documentation/data-sheets/TMP35_36_37.pdf for pin information
//
/* How it works:
The TMP36 outputs a voltage proportional ot the current temperature.
The resolution is 10 mv / degree centigrade (100 degrees centigrade / volt). There is a 500 mV offset (.5v) so negative temperatures can be measured
*/
### Keybase proof
I hereby claim:
* I am harrisonhjones on github.
* I am harrisonhjones (https://keybase.io/harrisonhjones) on keybase.
* I have a public key whose fingerprint is 44A3 EA71 BECE C315 077F 3525 1EF7 42AB E0ED 275D
To claim this, I am signing this object:
/*jslint node: true */
"use strict";
// Setup the modules we need to use
var spark = require('spark');
var fs = require('fs');
// Login and start doing things!
spark.on('login', function() {
//Get test event for specific core
@harrisonhjones
harrisonhjones / gist:1258e235362c110f9830
Last active August 29, 2015 14:23
Particle - Pebble App
// Project: Door Controller
// Description: A simple Pebble app for controlling my Particle-powered door lock
// Author: Harrison Jones ([email protected])
// Date: 6/7/2015
// -------- Includes -------- ///
var UI = require('ui');
var ajax = require('ajax');
//var Vector2 = require('vector2');
//var Accel = require('ui/accel');
// -------------------------------------------- //
// Documentation
// ------------------
// -------------------------------------------- //
// Compiler Defines
// ------------------
#define APP_VERSION 1.2 // Keep track of what version this code is
#define NUM_MEASUREMENTS 20 // The number of measurements we want to take befoe averaging and publishing