Miesięcznik Murator ONLINE

Skocz do zawartości

Arduino&22xDS18B20 for dummies - data logger


Recommended Posts

Swoim mało programistycznym rozumkiem ogarnąłem jakoś i posklejałem z internetowych tutoriali odczyt z czujników DS18B20. Pod choinkę dostałem coś takiego:

https://www.aliexpress.com/item/Free-Shipping-New-XD-05-Logging-Recorder-Data-Logger-Module-Shield-V1-0-for-Arduino-UNO/1871088695.html

Chciałem to razem z Arduino Uno zasilanego z pakietu AA zostawić na budowie (aktualnie stan zero), żeby już teraz zacząć logować temperatury (mam czujniki schowane już w ławie, w zasypce pod chudziakiem wewnątrz domu, w ścianie fundamentowej i jeszcze w kilku miejscach - teraz w sumie 5, ale szybko będzie przybywało bo tylko czekają na postęp prac budowlanych).

 

 

Pomoże ktoś przerobić? RTC chodzi, karta SD też jest widoczna - "tylko" przerobienie skryptu, żeby zapisywał do pliku zamiast na ekran mnie przerosło.

 

#include                 //Libraries we need
#include 
#include            
#include 

#define ONE_WIRE_BUS_PIN 2         // The pin that we are using

OneWire oneWire(ONE_WIRE_BUS_PIN);  // Setup oneWire
DallasTemperature sensors(&oneWire);//  oneWire to Dallas Temperature.
RTC_DS1307 RTC;                     // define the Real Time Clock object

// Assign the addresses of your  temp sensors.You must use 1 wire adress finder


DeviceAddress Probe01  = {  0x28, 0xFF, 0x8D, 0x40, 0x80, 0x16, 0x5, 0x94  }; 
DeviceAddress Probe02  = {  0x28, 0xFF, 0xD5, 0x1D, 0x80, 0x16, 0x5, 0x7A  }; 
DeviceAddress Probe03  = {  0x28, 0xFF, 0xB9, 0x67, 0x80, 0x16, 0x5, 0xF9  }; 
DeviceAddress Probe04  = {  0x28, 0xFF, 0x91, 0x6A, 0x80, 0x16, 0x5, 0xA2  }; 
DeviceAddress Probe05  = {  0x28, 0xFF, 0x92, 0xD, 0x80, 0x16, 0x5, 0xFA   }; 
DeviceAddress Probe06  = {  0x28, 0xFF, 0x8A, 0x27, 0x80, 0x16, 0x4, 0x8D  }; 
DeviceAddress Probe07  = {  0x28, 0xFF, 0x8A, 0x13, 0x80, 0x16, 0x3, 0x48  }; 
DeviceAddress Probe08  = {  0x28, 0xFF, 0x99, 0x4A, 0x80, 0x16, 0x4, 0xB2  }; 
DeviceAddress Probe09  = {  0x28, 0xFF, 0x49, 0x27, 0x80, 0x16, 0x4, 0xE1  }; 
DeviceAddress Probe10  = {  0x28, 0xFF, 0xBF, 0x4D, 0x80, 0x16, 0x4, 0x50  }; 
DeviceAddress Probe11  = {  0x28, 0xFF, 0xFB, 0x2D, 0x80, 0x16, 0x3, 0xB5  }; 
DeviceAddress Probe12  = {  0x28, 0xFF, 0x35, 0x21, 0x80, 0x16, 0x4, 0xA4  }; 
DeviceAddress Probe13  = {  0x28, 0xFF, 0x4A, 0xD9, 0x43, 0x16, 0x3, 0xFF  }; 
DeviceAddress Probe14  = {  0x28, 0xFF, 0xC, 0xC3, 0x43, 0x16, 0x4, 0x2A   }; 
DeviceAddress Probe15  = {  0x28, 0xFF, 0x36, 0xC8, 0x43, 0x16, 0x3, 0x4   }; 
DeviceAddress Probe16  = {  0x28, 0xFF, 0xB2, 0x32, 0x44, 0x16, 0x3, 0xC0  }; 
DeviceAddress Probe17  = {  0x28, 0xFF, 0xD4, 0xFD, 0x43, 0x16, 0x4, 0x17  }; 
DeviceAddress Probe18  = {  0x28, 0xFF, 0xFB, 0xDC, 0x43, 0x16, 0x3, 0xFC  }; 
DeviceAddress Probe19  = {  0x28, 0xFF, 0x4C, 0xCB, 0x43, 0x16, 0x3, 0x5C  }; 
DeviceAddress Probe20  = {  0x28, 0xFF, 0x81, 0xFE, 0x43, 0x16, 0x3, 0x5B  }; 
DeviceAddress Probe21  = {  0x28, 0xFF, 0xFE, 0xE6, 0x43, 0x16, 0x4, 0xFE  }; 
DeviceAddress Probe22  = {  0x28, 0xFF, 0x94, 0xC2, 0x43, 0x16, 0x4, 0x2C  }; 




void setup()
{
Serial.begin(9600);            //Must match with the serial monitor
Wire.begin();
RTC.begin();
sensors.begin();               // Initialize the Temperature measurement library
 
 // set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
 sensors.setResolution(Probe01, 10);
 sensors.setResolution(Probe02, 10);
 sensors.setResolution(Probe03, 10);
 sensors.setResolution(Probe04, 10);
 sensors.setResolution(Probe05, 10);
sensors.setResolution(Probe06, 10);
sensors.setResolution(Probe07, 10);
sensors.setResolution(Probe08, 10);
sensors.setResolution(Probe09, 10);
sensors.setResolution(Probe10, 10);
sensors.setResolution(Probe11, 10);
sensors.setResolution(Probe12, 10);
sensors.setResolution(Probe13, 10);
sensors.setResolution(Probe14, 10);
sensors.setResolution(Probe15, 10);
sensors.setResolution(Probe16, 10);
sensors.setResolution(Probe17, 10);
sensors.setResolution(Probe18, 10);
sensors.setResolution(Probe19, 10);
sensors.setResolution(Probe20, 10);
sensors.setResolution(Probe21, 10);
sensors.setResolution(Probe22, 10);

Serial.print(" Date/Time        Temp1    Temp2    Temp3   Temp4    Temp5    Temp6    Temp7    Temp8    Temp9    Temp10    Temp11    Temp12    Temp13    Temp14    Temp15    Temp16    Temp17    Temp18    Temp19    Temp20    Temp21    Temp22");    //Print headers
Serial.println();
}
void loop()
{
DateTime now = RTC.now();        // Clock call

//-------------Once we have called the clock ,we compare min and sec and print every 10 minutes---------


if(now.minute()==00 && now.second()==00){          

now = RTC.now();                 // Print date and time

Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);

// Command all devices on bus to read temperature  
 sensors.requestTemperatures(); 
  
 Serial.print(" ");              //Print temp
 printTemperature(Probe01);
 Serial.print(" ");

 Serial.print(" ");
 printTemperature(Probe02);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe03);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe04);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe05);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe06);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe07);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe08);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe09);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe10);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe11);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe12);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe13);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe14);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe15);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe16);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe17);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe18);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe19);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe20);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe21);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe22);
 Serial.println();

 
}

//-------------We are repeating the code, adding 10 20 30 40 50  -------------------------------------
if(now.minute()==10 && now.second()==00){          

now = RTC.now();                 // Print date and time

Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);

// Command all devices on bus to read temperature  
 sensors.requestTemperatures(); 
    
 Serial.print(" ");              //Print temp
 printTemperature(Probe01);
 Serial.print(" ");

 Serial.print(" ");
 printTemperature(Probe02);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe03);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe04);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe05);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe06);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe07);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe08);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe09);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe10);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe11);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe12);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe13);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe14);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe15);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe16);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe17);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe18);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe19);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe20);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe21);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe22);
 Serial.println();
}
if(now.minute()==20 && now.second()==00){          

now = RTC.now();                 // Print date and time

Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);

// Command all devices on bus to read temperature  
 sensors.requestTemperatures(); 
     
 Serial.print(" ");              //Print temp
 printTemperature(Probe01);
 Serial.print(" ");

 Serial.print(" ");
 printTemperature(Probe02);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe03);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe04);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe05);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe06);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe07);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe08);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe09);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe10);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe11);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe12);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe13);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe14);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe15);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe16);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe17);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe18);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe19);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe20);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe21);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe22);
 Serial.println();
 
}
if(now.minute()==30 && now.second()==00){         

now = RTC.now();                 // Print date and time

Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);

// Command all devices on bus to read temperature  
 sensors.requestTemperatures(); 
     
 Serial.print(" ");              //Print temp
 printTemperature(Probe01);
 Serial.print(" ");

 Serial.print(" ");
 printTemperature(Probe02);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe03);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe04);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe05);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe06);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe07);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe08);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe09);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe10);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe11);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe12);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe13);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe14);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe15);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe16);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe17);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe18);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe19);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe20);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe21);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe22);
 Serial.println();
 
}
if(now.minute()==40 && now.second()==00){          

now = RTC.now();                 // Print date and time

Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);

// Command all devices on bus to read temperature  
 sensors.requestTemperatures(); 
     
 Serial.print(" ");              //Print temp
 printTemperature(Probe01);
 Serial.print(" ");

 Serial.print(" ");
 printTemperature(Probe02);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe03);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe04);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe05);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe06);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe07);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe08);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe09);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe10);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe11);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe12);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe13);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe14);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe15);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe16);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe17);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe18);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe19);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe20);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe21);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe22);
 Serial.println();
 
}
if(now.minute()==50 && now.second()==00){          

now = RTC.now();                 // Print date and time

Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);

// Command all devices on bus to read temperature  
 sensors.requestTemperatures(); 
  
 Serial.print(" ");              //Print temp
 printTemperature(Probe01);
 Serial.print(" ");

 Serial.print(" ");
 printTemperature(Probe02);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe03);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe04);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe05);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe06);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe07);
 Serial.print(" ");
 
   Serial.print(" ");
 printTemperature(Probe08);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe09);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe10);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe11);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe12);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe13);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe14);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe15);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe16);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe17);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe18);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe19);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe20);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe21);
 Serial.print(" ");

   Serial.print(" ");
 printTemperature(Probe22);
 Serial.println();  

 
}
delay(1000);                        //One data per second
}


void printTemperature(DeviceAddress deviceAddress)
{

float tempC = sensors.getTempC(deviceAddress);


  Serial.print(tempC);
  Serial.print(" C");
  
  
}

 

Tak, wiem że skrypt trochę prostacki, ale dzięki takiemu "ręcznemu" wklepaniu czujników wiem, który jest który - a skrypty automatycznie wykrywające podpięte czujniki tego mnie pozwalały. To zapisywanie co pełne dziesiątki minut też pewnie mało eleganckie, ale działa :)

Odnośnik do komentarza
Udostępnij na innych stronach

Po długim procesie tentegotamowania w mojej mało programistycznej głowie udało mi się sklecić coś, co (chyba) działa. Wysyła na konsolę i zapisuje na kartę.

Sporo czasu mi zajęło a jeszcze się okazało, że karta microSD z adapterem Adata 2GB nie chce się dogadać z shieldem. Za to dogadują się podróbki kart Adata microSD (napisane 32GB, pokazują tyle we właściwościach, ale odczytać się daje tylko 2GB - po założeniu 2GB partycji działają jak 2GB karta bez problemu), ale nie w adapterach od kompletu. Oczywiście każda karta i adapter działa bez problemu w PC - a schield grymasi.

 

 

Może komuś jeszcze się przyda.

 

Wszelkie usprawnienia mile widziane.

 

 

#include #include #include                 #include #include File myFile;char filename[] = "DATA.CSV";#define ONE_WIRE_BUS_PIN 2OneWire oneWire(ONE_WIRE_BUS_PIN);DallasTemperature sensors(&oneWire);RTC_DS1307 rtc;const int chipSelect = 10;float tempC, Temp01, Temp02, Temp03, Temp04, Temp05, Temp06, Temp07, Temp08, Temp09, Temp10, Temp11, Temp12, Temp13, Temp14, Temp15, Temp16, Temp17, Temp18, Temp19, Temp20, Temp21, Temp22;// Assign the addresses of your  temp sensors.You must use 1 wire adress finderDeviceAddress Probe01  = {  0x28, 0xFF, 0x8D, 0x40, 0x80, 0x16, 0x5, 0x94  }; DeviceAddress Probe02  = {  0x28, 0xFF, 0xD5, 0x1D, 0x80, 0x16, 0x5, 0x7A  }; DeviceAddress Probe03  = {  0x28, 0xFF, 0xB9, 0x67, 0x80, 0x16, 0x5, 0xF9  }; DeviceAddress Probe04  = {  0x28, 0xFF, 0x91, 0x6A, 0x80, 0x16, 0x5, 0xA2  }; DeviceAddress Probe05  = {  0x28, 0xFF, 0x92, 0xD, 0x80, 0x16, 0x5, 0xFA   }; DeviceAddress Probe06  = {  0x28, 0xFF, 0x8A, 0x27, 0x80, 0x16, 0x4, 0x8D  }; DeviceAddress Probe07  = {  0x28, 0xFF, 0x8A, 0x13, 0x80, 0x16, 0x3, 0x48  }; DeviceAddress Probe08  = {  0x28, 0xFF, 0x99, 0x4A, 0x80, 0x16, 0x4, 0xB2  }; DeviceAddress Probe09  = {  0x28, 0xFF, 0x49, 0x27, 0x80, 0x16, 0x4, 0xE1  }; DeviceAddress Probe10  = {  0x28, 0xFF, 0xBF, 0x4D, 0x80, 0x16, 0x4, 0x50  }; DeviceAddress Probe11  = {  0x28, 0xFF, 0xFB, 0x2D, 0x80, 0x16, 0x3, 0xB5  }; DeviceAddress Probe12  = {  0x28, 0xFF, 0x35, 0x21, 0x80, 0x16, 0x4, 0xA4  }; DeviceAddress Probe13  = {  0x28, 0xFF, 0x4A, 0xD9, 0x43, 0x16, 0x3, 0xFF  }; DeviceAddress Probe14  = {  0x28, 0xFF, 0xC, 0xC3, 0x43, 0x16, 0x4, 0x2A   }; DeviceAddress Probe15  = {  0x28, 0xFF, 0x36, 0xC8, 0x43, 0x16, 0x3, 0x4   }; DeviceAddress Probe16  = {  0x28, 0xFF, 0xB2, 0x32, 0x44, 0x16, 0x3, 0xC0  }; DeviceAddress Probe17  = {  0x28, 0xFF, 0xD4, 0xFD, 0x43, 0x16, 0x4, 0x17  }; DeviceAddress Probe18  = {  0x28, 0xFF, 0xFB, 0xDC, 0x43, 0x16, 0x3, 0xFC  }; DeviceAddress Probe19  = {  0x28, 0xFF, 0x4C, 0xCB, 0x43, 0x16, 0x3, 0x5C  }; DeviceAddress Probe20  = {  0x28, 0xFF, 0x81, 0xFE, 0x43, 0x16, 0x3, 0x5B  }; DeviceAddress Probe21  = {  0x28, 0xFF, 0xFE, 0xE6, 0x43, 0x16, 0x4, 0xFE  }; DeviceAddress Probe22  = {  0x28, 0xFF, 0x94, 0xC2, 0x43, 0x16, 0x4, 0x2C  }; void setup()   /****** SETUP: RUNS ONCE ******/{ // start serial port to show results Serial.begin(9600);Serial.println("--- Serial started ---");   delay(300);//Wait for newly restarted system to stabilize   if (! rtc.begin()) {   Serial.println("Couldn't find RTC");   while (1); } // following line sets the rtc to the date & time this sketch was compiled//   rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); 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();}//--(end setup )---void loop()   /****** LOOP: RUNS CONSTANTLY ******/{ delay(600000); // mills between entries (reduce to take more/faster data) 10min=600000 Serial.println();// Serial.print("Date: "); Serial.print(get_RTC()); // Command all devices on bus to read temperature   sensors.requestTemperatures();     Serial.print(" ");              //Print temp printTemperature(Probe01); Serial.print(";");Temp01=tempC; // Serial.print(" "); printTemperature(Probe02); Serial.print(";");Temp02=tempC;   // Serial.print(" "); printTemperature(Probe03); Temp03=tempC; Serial.print(";");      // Serial.print(" "); printTemperature(Probe04); Temp04=tempC; Serial.print(";");    // Serial.print(" "); printTemperature(Probe05); Temp05=tempC; Serial.print(";");    // Serial.print(" "); printTemperature(Probe06); Temp06=tempC; Serial.print(";");    // Serial.print(" "); printTemperature(Probe07); Temp07=tempC; Serial.print(";");    // Serial.print(" "); printTemperature(Probe08); Temp08=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe09); Temp09=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe10); Temp10=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe11); Temp11=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe12); Temp12=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe13); Temp13=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe14); Temp14=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe15); Temp15=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe16); Temp16=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe17); Temp17=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe18); Temp18=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe19); Temp19=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe20); Temp20=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe21); Temp21=tempC; Serial.print(";");   // Serial.print(" "); printTemperature(Probe22); Temp22=tempC; Serial.println(); //   Serial.println("Storing data to SD card... ");       myFile = SD.open(filename, FILE_WRITE);//<<<<<<<<<<<<< OPEN myFile.print(get_RTC()); myFile.print(","); 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.print(Temp11); myFile.print(","); myFile.print(Temp12); myFile.print(","); myFile.print(Temp13); myFile.print(","); myFile.print(Temp14); myFile.print(","); myFile.print(Temp15); myFile.print(","); myFile.print(Temp16); myFile.print(","); myFile.print(Temp17); myFile.print(","); myFile.print(Temp18); myFile.print(","); myFile.print(Temp19); myFile.print(","); myFile.print(Temp20); myFile.print(","); myFile.print(Temp21); myFile.print(","); myFile.print(Temp22); myFile.print(",");   myFile.println();      myFile.close();//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>CLOSE // Serial.println("Data stored! ");   }//--(end main loop )---/*-----( Declare User-written Functions )-----*/// =========================================================================================================String get_RTC() { String RTC_String; DateTime now = rtc.now();  RTC_String+=now.day();RTC_String+='/'; RTC_String+=now.month();RTC_String+='/'; RTC_String+=now.year();RTC_String+=", "; if (now.hour()<10) RTC_String+='0'; RTC_String+=now.hour(); RTC_String+=':'; if (now.minute()<10) RTC_String+='0'; RTC_String+=now.minute(); RTC_String+=':'; if (now.second()<10) RTC_String+='0'; RTC_String+=now.second();   return RTC_String;}// =========================================================================================================void printTemperature(DeviceAddress deviceAddress){tempC = sensors.getTempC(deviceAddress);  if (tempC == -127.00)  {  Serial.print("N/A");  }  else  { // Serial.print("C: ");  Serial.print(tempC);  //Serial.print(" F: "); // Serial.print(DallasTemperature::toFahrenheit(tempC));  }}// End printTemperature//*********( THE END )***********

 

Odnośnik do komentarza
Udostępnij na innych stronach

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.

Gość
Odpowiedz w tym wątku

×   Wklejono zawartość z formatowaniem.   Usuń formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.



×
×
  • Dodaj nową pozycję...