#include <DS3231_Simple.h>
DS3231_Simple Clock;
void setup() {
Serial.begin(115200);
Clock.begin();
}
void loop() {
DateTime dt;
float temp;
dt=Clock.read();
temp=Clock.getTemperatureFloat();
Serial.print("20");
Serial.print(dt.Year);
Serial.print(".");
Serial.print(dt.Month);
Serial.print(".");
Serial.print(dt.Day);
Serial.print(" ");
Serial.print(dt.Hour);
Serial.print(":");
Serial.print(dt.Minute);
Serial.print(":");
Serial.print(dt.Second);
Serial.print(" - ");
Serial.print(temp);
Serial.println("");
delay(1000);
}
Nehme ich das Modul in die Hand (um es anzuwärmen), dauert es einige Zeit, bis sich der Temperatur-Wert ändert.
2016.11.19 11:10:18 - 19.50
2016.11.19 11:10:19 - 19.50
2016.11.19 11:10:20 - 19.50
2016.11.19 11:10:21 - 19.50
2016.11.19 11:10:22 - 19.50
2016.11.19 11:10:23 - 19.50
2016.11.19 11:10:24 - 19.50
[.....]
Beschaltung des Arduinos |
Programm für den Arduino |
![]() |
void setup() { Serial.begin(9600); } void loop() { Serial.print(analogRead(0)); Serial.print(" "); Serial.println(analogRead(1)); delay(1000); }
|
Programm für den
Raspberry Pi |
|
#!/usr/bin/env python # -*- coding: UTF-8 -*- import time dev="/dev/ttyACM0" term=open(dev, "r+") while True: ln=term.readline().strip() if ln!="": txt="%s - %s"%(time.strftime("%Y.%m.%d %H:%M:%S"), ln) print txt log=open("/home/dede/light.log", "a") log.write(txt+"\n") log.close() |