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