Created
November 1, 2015 19:05
-
-
Save michaelsarduino/f3d34ce9360e373fa78b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <SD.h> | |
#include <Time.h> | |
File Datei; | |
void setup() { | |
Serial.begin(9600); | |
setTime(13,58,10,01,11,15); | |
Serial.print(hour()); | |
Serial.print(":"); | |
Serial.print(minute()); | |
Serial.print(":"); | |
Serial.print(second()); | |
Serial.print("|"); | |
Serial.print(day()); | |
Serial.print("."); | |
Serial.print(month()); | |
Serial.print("."); | |
Serial.println(year()); | |
pinMode(10, OUTPUT); | |
SD.begin(10); | |
Datei = SD.open("temp.txt", FILE_WRITE); | |
} | |
void loop() { | |
long temp = readTemp(); | |
long zwe = temp / 10000; | |
long temperaturinc = zwe - 5; | |
int tag_g = day(); | |
int mon_g = month(); | |
int jahr_g = year(); | |
String doppel = " : "; | |
String datum = tag_g + doppel + mon_g + doppel + jahr_g; | |
int stunde_g = hour(); | |
int minute_g = minute(); | |
String zeit = stunde_g + doppel + minute_g; | |
String zeile = datum + " | " + zeit + " | " + temperaturinc; | |
Datei.println(zeile); | |
Datei.flush(); | |
delay(60000); | |
} | |
long readTemp() { | |
long result; | |
// Read temperature sensor against 1.1V reference | |
ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3); | |
delay(2); // Wait for Vref to settle | |
ADCSRA |= _BV(ADSC); // Convert | |
while (bit_is_set(ADCSRA,ADSC)); | |
result = ADCL; | |
result |= ADCH<<8; | |
result = (result - 125) * 1075; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment