Ultimas novedades del día 15/4. Estuve mirando varios códigos y encontré el siguiente que me parecio apropiado para empezar. Si bien yo voy a tener un solo sensor, fue el que mas se acerca a lo que quiero dentro de los que ví.
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <SD.h>
File myFile;
char filename[] = "Testfile.CSV";
#define ONE_WIRE_BUS_PIN 2
OneWire oneWire(ONE_WIRE_BUS_PIN);
DallasTemperature sensors(&oneWire);
const int chipSelect = 4;
float tempC, Temp01, Temp02, Temp03, Temp04, Temp05, Temp06, Temp07, Temp08, Temp09, Temp10;
DeviceAddress Probe01 = { 0x28, 0x27, 0x26, 0x51, 0x05, 0x00, 0x00, 0x2B };
DeviceAddress Probe02 = { 0x28, 0x1A, 0x9B, 0x40, 0x05, 0x00, 0x00, 0x98 };
DeviceAddress Probe03 = { 0x28, 0x06, 0x2A, 0x41, 0x05, 0x00, 0x00, 0xB3 };
DeviceAddress Probe04 = { 0x28, 0xDB, 0xD9, 0x50, 0x05, 0x00, 0x00, 0x62 };
DeviceAddress Probe05 = { 0x28, 0xED, 0x1C, 0x51, 0x05, 0x00, 0x00, 0x42 };
DeviceAddress Probe06 = { 0x28, 0x16, 0xC5, 0x40, 0x05, 0x00, 0x00, 0xD2 };
DeviceAddress Probe07 = { 0x28, 0xA4, 0x1B, 0x41, 0x05, 0x00, 0x00, 0xC8 };
DeviceAddress Probe08 = { 0x28, 0xF0, 0xDC, 0x40, 0x05, 0x00, 0x00, 0xC6 };
DeviceAddress Probe09 = { 0x28, 0xC1, 0x94, 0x40, 0x05, 0x00, 0x00, 0xCB };
DeviceAddress Probe10 = { 0x28, 0xB5, 0xE6, 0x40, 0x05, 0x00, 0x00, 0x61 };
void setup() /****** SETUP: RUNS ONCE ******/
{
// start serial port to show results
Serial.begin(9600);
delay(300);//Wait for newly restarted system to stabilize
Serial.print("Initializing Temperature Control Library Version ");
Serial.println(DALLASTEMPLIBVERSION);
Serial.print("Initializing");
delay(2000);
pinMode(10, OUTPUT);
if (!SD.begin(chipSelect))
{
Serial.print("failed!");
delay (2000);
return;
}
Serial.println(" init. OK!");
// Initialize the Temperature measurement library
sensors.begin();
// set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
sensors.setResolution(Probe01, 12);
sensors.setResolution(Probe02, 12);
sensors.setResolution(Probe03, 12);
sensors.setResolution(Probe04, 12);
sensors.setResolution(Probe05, 12);
sensors.setResolution(Probe06, 12);
sensors.setResolution(Probe07, 12);
sensors.setResolution(Probe08, 12);
sensors.setResolution(Probe09, 12);
sensors.setResolution(Probe10, 12);
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
delay(3000);
Serial.println();
Serial.print("Number of Devices found on bus = ");
Serial.println(sensors.getDeviceCount());
Serial.print("Getting temperatures... ");
Serial.println();
// Command all devices on bus to read temperature
sensors.requestTemperatures();
Serial.print("Probe 01 temperature is: ");
printTemperature(Probe01);
Serial.println();
Temp01 = tempC;
Serial.print("Probe 02 temperature is: ");
printTemperature(Probe02);
Serial.println();
Temp02 = tempC;
Serial.print("Probe 03 temperature is: ");
printTemperature(Probe03);
Serial.println();
Temp03 = tempC;
Serial.print("Probe 04 temperature is: ");
printTemperature(Probe04);
Serial.println();
Temp04 = tempC;
Serial.print("Probe 05 temperature is: ");
printTemperature(Probe05);
Serial.println();
Temp05 = tempC;
Serial.print("Probe 06 temperature is: ");
printTemperature(Probe06);
Serial.println();
Temp06 = tempC;
Serial.print("Probe 07 temperature is: ");
printTemperature(Probe07);
Serial.println();
Temp07 = tempC;
Serial.print("Probe 08 temperature is: ");
printTemperature(Probe08);
Serial.println();
Temp08 = tempC;
Serial.print("Probe 09 temperature is: ");
printTemperature(Probe09);
Serial.println();
Temp09 = tempC;
Serial.print("Probe 10 temperature is: ");
printTemperature(Probe10);
Serial.println();
Temp10 = tempC;
myFile = SD.open(filename, FILE_WRITE);//<<<<<<<<<<<<< OPEN
myFile.print(Temp01);
myFile.print(",");
myFile.print(Temp02);
myFile.print(",");
myFile.print(Temp03);
myFile.print(",");
myFile.print(Temp04);
myFile.print(",");
myFile.print(Temp05);
myFile.print(",");
myFile.print(Temp06);
myFile.print(",");
myFile.print(Temp07);
myFile.print(",");
myFile.print(Temp08);
myFile.print(",");
myFile.print(Temp09);
myFile.print(",");
myFile.print(Temp10);
myFile.print(",");
myFile.println();
myFile.close();//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>CLOSE
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
void printTemperature(DeviceAddress deviceAddress)
{
tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Error getting temperature ");
}
else
{
Serial.print("C: ");
Serial.print(tempC);
//Serial.print(" F: ");
// Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}// End printTemperature
//*********( THE END )***********