Created
July 19, 2010 07:55
-
-
Save solon/481126 to your computer and use it in GitHub Desktop.
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
/* | |
* skype_status.pde | |
* Turns on an LED when a Skype user is online and vice versa | |
* See http://apps.pachube.com/onlinestatus/online-status.php for more info and setup instructions. | |
*/ | |
/* ============================== | |
* This code, which assumes you're using the official Arduino Ethernet shield, | |
* updates a Pachube feed with your analog-in values and grabs values from a Pachube | |
* feed - basically it enables you to have both "local" and "remote" sensors. | |
* | |
* Tested with Arduino 14 | |
* | |
* Pachube is www.pachube.com - connect, tag and share real time sensor data | |
* code by usman (www.haque.co.uk), may 2009 | |
* copy, distribute, whatever, as you like. | |
* | |
* v1.1 - added User-Agent & fixed HTTP parser for new Pachube headers | |
* and check millis() for when it wraps around | |
* | |
* =============================== */ | |
#include <Ethernet.h> | |
#include <string.h> | |
#undef int() // needed by arduino 0011 to allow use of stdio | |
#include <stdio.h> // for function sprintf | |
#define SHARE_FEED_ID 8909 // this is your Pachube feed ID that you want to share to | |
#define REMOTE_FEED_ID 8914 // 8914 is the ID of the Pachube feed for bsolon's Skype status http://www.pachube.com/feeds/8914 ... ID = 0 | |
#define REMOTE_FEED_DATASTREAMS 1 // make sure that remoteSensor array is big enough to fit all the remote data streams | |
#define UPDATE_INTERVAL 10000 // if the connection is good wait 10 seconds before updating again - should not be less than 5 | |
#define RESET_INTERVAL 10000 // if connection fails/resets wait 10 seconds before trying again - should not be less than 5 | |
#define PACHUBE_API_KEY "YOUR_PACHUBE_API_KEY_HERE" // fill in your API key | |
byte mac[] = { 0xCC, 0xAC, 0xBE, 0xEF, 0xFE, 0x91 }; // make sure this is unique on your network | |
byte ip[] = { 192, 168, 1, 144 }; // no DHCP so we set our own IP address | |
byte remoteServer[] = { 209,40,205,190 }; // pachube.com | |
float remoteSensor[REMOTE_FEED_DATASTREAMS]; // we know that feed 256 has floats - this might need changing for feeds without floats | |
int ledPin = 9; | |
void setup() | |
{ | |
Serial.begin(57600); | |
setupEthernet(); | |
pinMode(ledPin, OUTPUT); | |
digitalWrite(ledPin, LOW); | |
} | |
void loop() | |
{ | |
pachube_in_out(); | |
Serial.print("Skype status = "); | |
Serial.println((int)remoteSensor[0]); // 0 = ID of sensor we want to read (skype status) | |
if ((int)remoteSensor[0] == 1) { | |
digitalWrite(ledPin, HIGH); | |
} else { | |
digitalWrite(ledPin, LOW); | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment