i made this… my goal is to find out temp cycle in my refrigerator.
I thought this maby could be useful for ppl.
Dalas Chips is four T92 (DS18B20)
here is the code.
// +-----------+-----------+-------------+
// ___ | ___ | ___ | ___ |
// /___\ | /___\ | /___\ | /___\ |
// |DALAS|| |DALAS|| |DALAS|| |DALAS| |
// | || | || | || | | |
// |_____|| |_____|| |_____|| |_____| |
// / | \! / | \! / | \! / | \---+--------------------+-`
// | | | | | | | | |-.
// | +--------\--+--------\--+-------\--+------+ |-.
// | | / / / +-[10k]-+ -|.
// | | +-+---------+----------+ | | |-.
// | +-------+ | +-[10k]-+ |.
// | :` | | | |-.
// | - | | BR BL OR| |-.
// +---\----------+ | | |-.
// | / | +---------------------------------+-----------+
// | |----|--------+ |
// | .---|-------------5v--------`
// | .--GND----------------------`
// | .---------------------------`
// | .-------ARDUINO UNO---------`
// | .---------------------------`
// | .------------------:::::----`
// | .-:/--::-----::----:( ):RST-`
// | `.D2 ...D7....D8....:::::....
// +------+ | |
// | | simple short out cable.
// +-SHRT+
#include <EEPROM.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int eeAddress;
float val;
void setup() {
Serial.begin(9600);
sensors.begin();
pinMode(13,OUTPUT);
pinMode(7,INPUT);digitalWrite(7,HIGH);
pinMode(8,OUTPUT);digitalWrite(8,LOW);
int sw = digitalRead(7);
if (!sw){Serial.println("LOW");}// shorting pin 7 and pin 8. // debug option // read eeprom from mem
if (sw){Serial.println("HIGH");}// degub option // write eeprom to mem
if (!sw){// if pin 7 and pin 8 is shorten to each other.
eeAddress = 0;
Serial.println("Reading...");
for (int a = 0;a < 10;a++){
for (int b = 0;b < 4;b++){
EEPROM.get(eeAddress,val);eeAddress += sizeof(float);
Serial.print("\t");Serial.print(val,2);Serial.print("\t");Serial.print(b,DEC);
}
Serial.println();
}Serial.println("Done.");
}
if (sw){// if pin 7 and pin 8 is NOT shorten to each other.
eeAddress = 0;
Serial.println("outputing");
for (int a = 0;a < 10;a++){
delay(1000);sensors.requestTemperatures();
for (int b = 0;b < 4;b++){
val = sensors.getTempCByIndex(b);
EEPROM.put(eeAddress,val);eeAddress += sizeof(float);
}
Serial.print(".");
}Serial.print("\n Done.");
}
}
void loop() {
// idle blink
digitalWrite(13,HIGH);delay(1000);
digitalWrite(13,LOW);delay(1000);
}