Created
April 9, 2016 22:23
-
-
Save papakpmartin/ee437d3cae37e3977ebfae3d5afe9c0e 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
// This #include statement was automatically added by the Particle IDE. | |
#include "OneWire/OneWire.h" | |
#include "spark-dallas-temperature/spark-dallas-temperature.h" | |
double tempF = 0.0; | |
int tempSensorPin = D2; | |
OneWire oneWire(tempSensorPin); | |
DallasTemperature sensors(&oneWire); | |
void setup() { | |
sensors.begin(); | |
//Particle.variable("tempf", tempF); | |
} | |
void loop() { | |
sensors.requestTemperatures(); | |
tempF = sensors.getTempFByIndex(0); | |
if ( tempF > -50 && tempF < 150) // might want to guard against a spurious high value as well | |
{ | |
Particle.publish( "Temp F", String(tempF,DEC) ); | |
} | |
delay(10000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment