Created
February 9, 2016 18:35
-
-
Save k9ert/817690dd5730959028df to your computer and use it in GitHub Desktop.
This file contains hidden or 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 #include statement was automatically added by the Particle IDE. | |
#include "OneWire/OneWire.h" | |
// This #include statement was automatically added by the Particle IDE. | |
#include "spark-dallas-temperature/spark-dallas-temperature.h" | |
// Init Dallas on pin digital pin 3 | |
DallasTemperature dallas(new OneWire(D7)); | |
TCPClient tcpClient; | |
SparkCarbon carbon; | |
bool carbonsetup = false; | |
void setup() { | |
Serial.begin(9600); | |
for(int i = 10;i > 0;i--) | |
{ | |
Serial.println("Starting in " + String(i,DEC)); | |
delay(500); | |
} | |
// the carbon setup, doesn't work with DNS, unfortunately | |
//carbonsetup = carbon.begin(&tcpClient, "your.graphite.server.maybe.at.tutum.io"); | |
IPAddress remoteIP(192,168,12,102); // Maybe host your graphite inhouse | |
carbonsetup = carbon.begin(&tcpClient, remoteIP); | |
Serial.println("carbonsetup is " + String(carbonsetup)); | |
// The Dallas setup | |
dallas.begin(); | |
dallas.setResolution(12); | |
} | |
void loop() { | |
dallas.requestTemperatures(); | |
float celsius = dallas.getTempCByIndex( 0 ); | |
Serial.print("Temperature: "); Serial.println(celsius) ; | |
Spark.publish("temperature", String(celsius)); | |
if (celsius != -127) { | |
if ( carbon.sendData("stats.test.data3", String(celsius), Time.now())) { | |
Serial.println("stats sent" + carbonsetup); | |
} else { | |
Serial.println("stats not sent" + carbonsetup); | |
} | |
} | |
delay(60000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment