Frage wegen Datenlogger


hallo
ich brauche einen datenlogger , um eine temperatur eine warmwasserspeicher 60 grad celsius ( 400 liter) zu messen.
das problem ist , wenn ich mich morgen  waschen ist das wasser kalt., wenn ich dann in keller den  warmwasserspeicher  kontrolliere ist die temperatur nur noch ca 25 grad celsius). laut hersteller des warmwasserspeicher fällt die temperatur aber maximal um 5 grad celsuis pro nacht .  es wäre ja nicht mal aufgefallen , aber ich schalte jetzt aus kostengründen die heizung von ca 22.00 uhr bis ca 7.00 uhr komplett aus. da noch eine andere partei im haus wohnt muss da faul sein . mir langt es wenn er alle 10 miunten eine messung macht daher brauche ich keine uhr .
daher habe ich mal ein code geschrieben , der läuft auch aber er schreibt mit nichts in das datalog.csv file .
wäre sehr nett wenn mir da jemand helfen könnte.

danke alle


code: [select]
#include <onewire.h>
#include <dallastemperature.h>
#include <sd.h>
#define one_wire_bus 9
onewire onewire(one_wire_bus);
dallastemperature sensors(&onewire);
const int chipselect = 10; // cs pin

void setup(){
 serial.begin(9600);
 while (!serial)
   serial.print("initializing sd card...");
 sensors.begin();
 if (!sd.begin(chipselect)); {
   serial.println("card failed, or not present");
   return;
 }
 serial.println("card initialized.");
}

void loop(){
 file datafile = sd.open("datalog.csv", file_write);{
   string datastring = " ";
   datafile.println(datastring);
   sensors.requesttemperatures();
   if (datafile) {
     serial.println(sensors.gettempcbyindex(0));
     datafile.close();
     delay(60000);
     serial.println(datastring);
   }
   else {
     serial.println("error opening datalog.csv");
   }
 }
}

hallo,
irgentwie fehlt mir da ein wenig dallas-code: hier mal das original:
code: [select]
#include <onewire.h>

#include <liquidcrystal.h>

#include <wire.h>



// onewire ds18s20, ds18b20, ds1822 temperature example
//
// http://www.pjrc.com/teensy/td_libs_onewire.html
//
// dallastemperature library can work you!
// http://milesburton.com/dallas_temperature_control_library

onewire  ds(10);  // on pin 10

void setup(void) {
  serial.begin(19200);
}

void loop(void) {
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
 
  if ( !ds.search(addr)) {
    serial.println("no more addresses.");
    serial.println();
    ds.reset_search();
    delay(250);
    return;
  }
 
  serial.print("rom =");
  for( = 0; < 8; i++) {
    serial.write(' ');
    serial.print(addr[i], hex);
  }

  if (onewire::crc8(addr, 7) != addr[7]) {
      serial.println("crc not valid!");
      return;
  }
  serial.println();

  // first rom byte indicates chip
  switch (addr[0]) {
    case 0x10:
      serial.println("  chip = ds18s20");  // or old ds1820
      type_s = 1;
      break;
    case 0x28:
      serial.println("  chip = ds18b20");
      type_s = 0;
      break;
    case 0x22:
      serial.println("  chip = ds1822");
      type_s = 0;
      break;
    default:
      serial.println("device not ds18x20 family device.");
      return;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);         // start conversion, parasite power on @ end
 
  delay(750);     // maybe 750ms enough, maybe not
  // might ds.depower() here, reset take care of it.
 
  present = ds.reset();
  ds.select(addr);   
  ds.write(0xbe);         // read scratchpad

  serial.print("  data = ");
  serial.print(present,hex);
  serial.print(" ");
  ( = 0; < 9; i++) {           // need 9 bytes
    data[i] = ds.read();
    serial.print(data[i], hex);
    serial.print(" ");
  }
  serial.print(" crc=");
  serial.print(onewire::crc8(data, 8), hex);
  serial.println();

  // convert data actual temperature

  unsigned int raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // count remain gives full 12 bit resolution
      raw = (raw & 0xfff0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    if (cfg == 0x00) raw = raw << 3;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms
    // default 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
  fahrenheit = celsius * 1.8 + 32.0;
  serial.print("  temperature = ");
  serial.print(celsius,1);
  serial.print(" celsius, ");
  serial.print(fahrenheit);
  serial.println(" fahrenheit");
}


hier der original datenlogger der arduino sd lib

code: [select]
/*
  sd card datalogger

example shows how log data 3 analog sensors
sd card using sd library.

circuit:
* analog sensors on analog ins 0, 1, , 2
* sd card attached spi bus follows:
** mosi - pin 11
** miso - pin 12
** clk - pin 13
** cs - pin 4

created  24 nov 2010
modified 9 apr 2012
tom igoe

example code in public domain.

*/

#include <sd.h>

// on ethernet shield, cs pin 4. note if it's not
// used cs pin, hardware cs pin (10 on arduino boards,
// 53 on mega) must left output or sd library
// functions not work.
const int chipselect = 4;

void setup()
{
// open serial communications , wait port open:
  serial.begin(9600);
   while (!serial) {
    ; // wait serial port connect. needed leonardo only
  }


  serial.print("initializing sd card...");
  // make sure default chip select pin set to
  // output, if don't use it:
  pinmode(10, output);
 
  // see if card present , can initialized:
  if (!sd.begin(chipselect)) {
    serial.println("card failed, or not present");
    // don't more:
    return;
  }
  serial.println("card initialized.");
}

void loop()
{
  // make string assembling data log:
  string datastring = "";

  // read 3 sensors , append string:
  (int analogpin = 0; analogpin < 3; analogpin++) {
    int sensor = analogread(analogpin);
    datastring += string(sensor);
    if (analogpin < 2) {
      datastring += ",";
    }
  }

  // open file. note 1 file can open @ time,
  // have close 1 before opening another.
  file datafile = sd.open("datalog.txt", file_write);

  // if file available, write it:
  if (datafile) {
    datafile.println(datastring);
    datafile.close();
    // print serial port too:
    serial.println(datastring);
  } 
  // if file isn't open, pop error:
  else {
    serial.println("error opening datalog.txt");
  }
}




vielleicht hilft es dir ja.
gruß und spaß
andreas


Arduino Forum > International > Deutsch (Moderator: uwefed) > Frage wegen Datenlogger


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support