Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// 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