Skip to content

Instantly share code, notes, and snippets.

var five = require("johnny-five");
var Spark = require("spark-io");
var board = new five.Board({
io: new Spark({
token: process.env.SPARK_TOKEN,
deviceId: process.env.SPARK_DEVICE_ID
})
});
@Resseguie
Resseguie / gist:8302903
Created January 7, 2014 17:24
Oversimplified method of sending ThingSpeak updates from Spark Core. (Not really recommended for real world use.) This connects and sends data successfully several times, but eventually something hangs and it stops updating.
// ThingSpeak Settings
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = "THINGSPEAK_WRITE_KEY";
const unsigned int updateThingSpeakInterval = 30000;
// Variable Setup
unsigned long lastConnectionTime = 0;
// Initialize TCP Client
TCPClient client;
@Resseguie
Resseguie / gist:8294929
Created January 7, 2014 05:19
Attempting to send analog data from Spark Core to Thingspeak. (Note: Something still not fully working. First post works, then it hangs.)
// ThingSpeak Settings
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = "THINGSPEAK_WRITE_API";
const unsigned int updateThingSpeakInterval = 30000;
unsigned long lastConnectionTime = 0;
bool lastConnected = false;
int failedCounter = 0;
TCPClient client;