// No hay que usar la librería OneWire de Arduino, sino la que tengo en OneWireNoResistor-1.0
// Script simple para medir solo un dispositivo DS18x20 conectado al pin 9.
#include <OneWire.h>
#include <DallasTemperature.h>
// This is an updated version of the Tester program that comes with the DallasTemp library
// It will drive a DS18x20 tempurature sensor plugged directly to the Arduino header pins 8,9, and 10.
// The flat side of the sensor should face into the center of the board.
// More info and a video here...
// http://wp.josh.com/2014/06/23/no-external-pull-up-needed-for-ds18b20-temp-sensor/#more-1892
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 9
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
void setup(void)
{
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control.");
sensors.begin();
sensors.setResolution(10);
}
void loop(void)
{
DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address
sensors.requestTemperatures(); // Send the command to get temperatures
// Search the wire for address
if(sensors.getAddress(tempDeviceAddress, 0))
{
float tempC = sensors.getTempC(tempDeviceAddress);
Serial.println(tempC,4);
}
delay(1000);
}