Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@papakpmartin
Created April 9, 2016 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papakpmartin/ee437d3cae37e3977ebfae3d5afe9c0e to your computer and use it in GitHub Desktop.
Save papakpmartin/ee437d3cae37e3977ebfae3d5afe9c0e to your computer and use it in GitHub Desktop.
// 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