Skip to content

Instantly share code, notes, and snippets.

Created March 18, 2015 11:39
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 anonymous/56882d67190b56bc079b to your computer and use it in GitHub Desktop.
Save anonymous/56882d67190b56bc079b to your computer and use it in GitHub Desktop.
#include "spark-dallas-temperature/spark-dallas-temperature.h"
#include "OneWire/OneWire.h"
#include "LiquidCrystal/LiquidCrystal.h"
#include "application.h"
#define ONE_WIRE_BUS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensor(&oneWire);
float temperature = 1.0;
char myStr[10];
LiquidCrystal lcd(D0, D1, A5, D3, D4, D5);
void setup() {
//OneWire setup
//Spark.variable("read", &myStr, STRING);
sensor.begin();
sensor.setResolution(12);
lcd.begin(20,4);
lcd.setCursor(0,0);
lcd.print("Hello, Sparky!");
}
void loop() {
//Read and print temperature:
sensor.requestTemperatures();
temperature = sensor.getTempCByIndex(0);
sprintf(myStr,"%.1f",temperature);
//sprintf(myStr,"%.3f",temperature);
lcd.setCursor(0,2);
String temp = String("Temp is: ");
temp = temp + myStr;
lcd.print(temp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment