Last active
January 8, 2018 09:48
-
-
Save Ozsie/aae65115ee4856445efccb97cd9eefd3 to your computer and use it in GitHub Desktop.
Read temperature
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
#include <OneWire.h> | |
#include <DallasTemperature.h> | |
#define ONE_WIRE_BUS 2 // DS18B20 pin | |
OneWire oneWire(ONE_WIRE_BUS); | |
DallasTemperature DS18B20(&oneWire); | |
void setup() { | |
Serial.begin(115200); | |
Serial.println("Hello World"); | |
} | |
void loop() { | |
int temp; | |
do { | |
DS18B20.requestTemperatures(); | |
temp = DS18B20.getTempCByIndex(0); | |
Serial.print("Temperature: "); | |
Serial.println(temp); | |
delay(100); | |
} while ((temp != 85.0 || temp == (-127.0))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment