weatherbox:team_nova:temperature_code

This is an old revision of the document!


#include <OneWire.h>
#include <DallasTemperature.h>

OneWire oneWire(A2);

DallasTemperature sensors(&oneWire);

arrays to hold device address DeviceAddress insideThermometer; void setup() { put your setup code here, to run once:

Serial.begin(9600);
sensors.begin();
sensors.getAddress(insideThermometer, 0); //set the address to take temperatures

}

void loop() {

//get temperature from sensor
sensors.requestTemperatures();

delay(1000);
//get the value of temperature in Celsius and set to tempC
float tempC = sensors.getTempC(insideThermometer); 

Serial.print("Temp C: ");
Serial.print(tempC);
Serial.print(" Temp F: ");
//convert temperature in C to F
Serial.println(DallasTemperature::toFahrenheit(tempC));

}

  • weatherbox/team_nova/temperature_code.1458257201.txt.gz
  • Last modified: 2021/09/19 21:59
  • (external edit)