Systemstart "interne Aufzeichnung"
Anbei ist der Code für die interne Aufzeichnung der Temperaturdaten zu finden.
1. #include <LiquidCrystal_I2C.h>
2. #include <DallasTemperature.h>
3. #include <OneWire.h>
4. #include <DS3231.h>
5. #include <Wire.h>
6. #include <SPI.h>
7. #include <SD.h>
8.
9.
10. // Displays einbinden
11. LiquidCrystal_I2C Info(0x20, 16, 2);
12. LiquidCrystal_I2C Uhrzeit_Datum(0x21, 16, 2);
13. LiquidCrystal_I2C Sensor1(0x25, 16, 2);
14. LiquidCrystal_I2C Sensor2(0x26, 16, 2);
15. LiquidCrystal_I2C Sensor3(0x22, 16, 2);
16. LiquidCrystal_I2C Sensor4(0x24, 16, 2);
17. LiquidCrystal_I2C Sensor5(0x27, 16, 2);
18. LiquidCrystal_I2C Sensor6(0x23, 16, 2);
19.
20.
21.
22. // Datenleitung Sensor
23. #define ONE_WIRE_BUS 13
24.
25. // Anzahl Sensoren
26. int sen_number = 0;
27.
28. // Zeit Sensoren auslesen in Millis
29. const unsigned long Ausleseabstand = 1000;
30. unsigned long bisherigeZeit = 0;
31.
32. // Speicherabstand SD_Karte in Millis
33. // 60.000 = 1 Min; 300.000 = 5 Min; 600.000 = 10 Min
34. const unsigned long Speicherabstand = 120000;
35. unsigned long bisherigeZeit_2 = 0;
36.
37. // Datenleitung SD-Kartenspeicherung
38. const int chipSelect = 53;
39.
40. // Eingang Schalter Speichervorgang start/stopp
41. int Schalter = 2;
42.
43. // zu Beginn gesetzter Schalter-Speicherzustand
44. int Schalterstatus = 0;
45.
46. OneWire oneWire(ONE_WIRE_BUS);
47. DallasTemperature sensors(&oneWire);
48. DeviceAddress T1, T2, T3, T4, T5, T6;
49.
50. DS3231 clock;
51. RTCDateTime dt;
52.
53. File dataFile;
54.
55.
56.
57. void setup(void) {
58.
59. Uhrzeit_Datum.begin();
60. Serial.begin(9600);
61. sensors.begin();
62. Sensor1.begin();
63. Sensor2.begin();
64. Sensor3.begin();
65. Sensor4.begin();
66. Sensor5.begin();
67. Sensor6.begin();
68. clock.begin();
69. Info.begin();
70.
71.
72. // neue Uhrzeit einlernen (nach dem ersten Upload auskommentieren)
73. clock.setDateTime(__DATE__, __TIME__);
74.
75.
76. // SD-Karte initialisieren
77. pinMode(chipSelect, OUTPUT);
78.
79. if (SD.begin(chipSelect)) {
80.
81. Info.print("Karte vorhanden");
82. Serial.println("SD-Karte ");
83.
84. } else {
85.
86. Info.clear();
87. Info.print("Karte fehlerhaft");
88. Serial.println("Fehler SD-Karte");
89. Serial.println(" ");
90. }
91.
92. Serial.println(" ");
93.
94.
95. // Sensorsuche
96. if (!sensors.getAddress(T1, 0)) Serial.println("Sensor 1 nicht gefunden");
97. if (!sensors.getAddress(T2, 1)) Serial.println("Sensor 2 nicht gefunden");
98. if (!sensors.getAddress(T3, 2)) Serial.println("Sensor 3 nicht gefunden");
99. if (!sensors.getAddress(T4, 3)) Serial.println("Sensor 4 nicht gefunden");
100. if (!sensors.getAddress(T5, 4)) Serial.println("Sensor 5 nicht gefunden");
101. if (!sensors.getAddress(T6, 5)) Serial.println("Sensor 6 nicht gefunden");
102. Serial.println(" ");
103. Serial.println(" ");
104.
105.
106. // Abfrage Sensoranzahl
107. Serial.print("Gefunden: ");
108. Serial.print(sensors.getDeviceCount(), DEC);
109. Serial.println(" Sensoren");
110.
111.
112. // Anzeige Sensoradressen
113. for (int k = 0; k < sensors.getDeviceCount(); k++) {
114. Serial.print("Sensor "); Serial.print(k + 1);
115. Serial.print(" Address: ");
116. if (k == 0) {
117. printAddress(T1); Serial.println();
118. } else if (k == 1) {
119. printAddress(T2); Serial.println();
120. } else if (k == 2) {
121. printAddress(T3); Serial.println();
122. } else if (k == 3) {
123. printAddress(T4); Serial.println();
124. } else if (k == 4) {
125. printAddress(T5); Serial.println();
126. } else if (k == 5) {
127. printAddress(T6); Serial.println();
128. }
129. }
130. Serial.println(" ");
131. Serial.println(" ");
132. Serial.println(" ");
133.
134.
135.
136. // Text Display Sensor 1
137. Sensor1.clear();
138. Sensor1.setCursor(0, 0);
139. Sensor1.print("Sensor 1");
140.
141. // Text Display Sensor 2
142. Sensor2.clear();
143. Sensor2.setCursor(0, 0);
144. Sensor2.print("Sensor 2");
145.
146. // Text Display Sensor 3
147. Sensor3.clear();
148. Sensor3.setCursor(0, 0);
149. Sensor3.print("Sensor 3");
150.
151. // Text Display Sensor 4
152. Sensor4.clear();
153. Sensor4.setCursor(0, 0);
154. Sensor4.print("Sensor 4");
155.
156. // Text Display Sensor 5
157. Sensor5.clear();
158. Sensor5.setCursor(0, 0);
159. Sensor5.print("Sensor 5");
160.
161. // Text Display Sensor 6
162. Sensor6.clear();
163. Sensor6.setCursor(0, 0);
164. Sensor6.print("Sensor 6");
165.
166. Info.clear();
167. Info.setCursor(5, 0);
168. Info.print("keine");
169. Info.setCursor(2, 1);
170. Info.print("Aufzeichnung");
171. }
172.
173.
174. // Funktion Adressdaten abfragen
175. void printAddress(DeviceAddress deviceAddress)
176. {
177. for (uint8_t i = 0; i < 6; i++)
178. {
179. if (deviceAddress[i] < 6) Serial.print("0");
180. Serial.print(deviceAddress[i], HEX);
181. }
182. }
183.
184.
185.
186. // Funktion Temperatur schreiben
187. // "tempC, 5" bedeutet 5 Nachkommastellen werden angezeigt
188. void printTemperature(DeviceAddress deviceAddress) {
189. float tempC = sensors.getTempC(deviceAddress);
190. Serial.print(" Temp: ");
191. Serial.print(tempC, 5);
192. Serial.print(" Grad ");
193. }
194.
195.
196. // Funktion Adressdaten Schreiben
197. void printData(DeviceAddress deviceAddress) {
198. Serial.print("; Sensoradresse: ");
199. printAddress(deviceAddress);
200. Serial.print(" ");
201. printTemperature(deviceAddress);
202. Serial.println();
203. pinMode(Schalter, INPUT_PULLUP);
204. }
205.
206.
207.
208.
209.
210. void loop(void) {
211.
212.
213. // Abfrage Schalterstatus
214. Schalterstatus = digitalRead(Schalter);
215.
216.
217. // Erzeuge Millis
218. unsigned long currentTime = millis();
219. dt = clock.getDateTime();
220.
221.
222. // Datum
223. Uhrzeit_Datum.setCursor(0, 0);
224. Uhrzeit_Datum.print("Date: ");
225. Uhrzeit_Datum.print(dt.day); Uhrzeit_Datum.print(".");
226. Uhrzeit_Datum.print(dt.month); Uhrzeit_Datum.print(".");
227. Uhrzeit_Datum.print(dt.year); Uhrzeit_Datum.print(" ");
228.
229.
230. // Uhrzeit
231. Uhrzeit_Datum.setCursor(0, 1);
232. Uhrzeit_Datum.print("Time: ");
233. Uhrzeit_Datum.print(dt.hour); Uhrzeit_Datum.print(":");
234. Uhrzeit_Datum.print(dt.minute); Uhrzeit_Datum.print(":");
235. Uhrzeit_Datum.print(dt.second); Uhrzeit_Datum.print(" ");
236.
237.
238. // Schleife Sensordaten auslesen
239. if (currentTime - bisherigeZeit >= Ausleseabstand) {
240.
241. Serial.println("Lese Daten...");
242. sensors.requestTemperatures();
243. Serial.print(dt.hour); Serial.print(":");
244. Serial.print(dt.minute); Serial.print(":");
245. Serial.print(dt.second); Serial.println(" ");
246.
247. for (int k = 0; k < sensors.getDeviceCount(); k++) {
248. Serial.print("Sensor "); Serial.print(k + 1); Serial.print(" ");
249. if (k == 0) {
250. printData(T1);
251. } else if (k == 1) {
252. printData(T2);
253. } else if (k == 2) {
254. printData(T3);
255. } else if (k == 3) {
256. printData(T4);
257. } else if (k == 4) {
258. printData(T5);
259. } else if (k == 5) {
260. printData(T6);
261. }
262. }
263.
264.
265. // Sensordaten auf Displays schreiben
266. if (sen_number == sensors.getDeviceCount()) {
267. sen_number = 0; // reset counter
268. }
269. if (sen_number == 0) {
270.
271. // Text Display Sensor 1
272. Sensor1.setCursor(0, 0);
273. Sensor1.print("Sensor 1");
274. Sensor1.setCursor(0, 1);
275. Sensor1.print("Temp: ");
276. Sensor1.print(sensors.getTempC(T1), 5); Sensor1.write((char)223); Sensor1.print("C");
277.
278. } else if (sen_number == 1) {
279.
280. // Text Display Sensor 2
281. Sensor2.setCursor(0, 0);
282. Sensor2.print("Sensor 2");
283. Sensor2.setCursor(0, 1);
284. Sensor2.print("Temp: ");
285. Sensor2.print(sensors.getTempC(T2), 5); Sensor2.write((char)223); Sensor2.print("C");
286.
287. } else if (sen_number == 2) {
288.
289. // Text Display Sensor 3
290. Sensor3.setCursor(0, 0);
291. Sensor3.print("Sensor 3");
292. Sensor3.setCursor(0, 1);
293. Sensor3.print("Temp: ");
294. Sensor3.print(sensors.getTempC(T3), 5); Sensor3.write((char)223); Sensor3.print("C");
295.
296. } else if (sen_number == 3) {
297.
298. // Text Display Sensor 4
299. Sensor4.setCursor(0, 0);
300. Sensor4.print("Sensor 4");
301. Sensor4.setCursor(0, 4);
302. Sensor4.print("Temp: ");
303. Sensor4.print(sensors.getTempC(T4), 5); Sensor4.write((char)223); Sensor4.print("C");
304.
305. } else if (sen_number == 4) {
306.
307. // Text Display Sensor 5
308. Sensor5.setCursor(0, 0);
309. Sensor5.print("Sensor 5");
310. Sensor5.setCursor(0, 1);
311. Sensor5.print("Temp: ");
312. Sensor5.print(sensors.getTempC(T5), 5); Sensor5.write((char)223); Sensor5.print("C");
313.
314. } else if (sen_number == 5) {
315.
316. // Text Display Sensor 6
317. Sensor6.setCursor(0, 0);
318. Sensor6.print("Sensor 6");
319. Sensor6.setCursor(0, 1);
320. Sensor6.print("Temp: ");
321. Sensor6.print(sensors.getTempC(T6), 5); Sensor6.write((char)223); Sensor6.print("C");
322.
323. }
324. Serial.println(" ");
325. sen_number++ ;
326. bisherigeZeit = currentTime;
327. }
328.
329.
330. if (SD.begin(chipSelect) && Schalterstatus == LOW) {
331.
332. Info.clear();
333. Info.setCursor(2, 0);
334. Info.print("Aufzeichnung");
335. Info.setCursor(5, 1);
336. Info.print("aktiv");
337.
338.
339. // Datenträgerspeicherung bei Schalter betätigt und SD-Karte vorhanden
340. if (currentTime - bisherigeZeit_2 >= Speicherabstand) {
341.
342. float a = sensors.getTempC(T1);
343. float b = sensors.getTempC(T2);
344. float c = sensors.getTempC(T3);
345. float d = sensors.getTempC(T4);
346. float e = sensors.getTempC(T5);
347. float f = sensors.getTempC(T6);
348.
349. String DatenString = "";
350.
351. DatenString += String(a);
352. DatenString += ";";
353.
354. DatenString += String(b);
355. DatenString += ";";
356.
357. DatenString += String(c);
358. DatenString += ";";
359.
360. DatenString += String(d);
361. DatenString += ";";
362.
363. DatenString += String(e);
364. DatenString += ";";
365.
366. DatenString += String(f);
367.
368.
369.
370. // Speicherdatei erzeugen
371. dataFile = SD.open("DATEN.csv", FILE_WRITE);
372.
373. if (dataFile) {
374.
375. // Datum
376. dataFile.print(dt.day); dataFile.print(".");
377. dataFile.print(dt.month); dataFile.print(".");
378. dataFile.print(dt.year); dataFile.print(";");
379.
380. // Uhrzeit
381. dataFile.print(dt.hour); dataFile.print(":");
382. dataFile.print(dt.minute); dataFile.print(":");
383. dataFile.print(dt.second); dataFile.print(";");
384.
385. // Sensordaten
386. dataFile.print(DatenString);
387. dataFile.println(" ");
388.
389. dataFile.close();
390. }
391. bisherigeZeit_2 = currentTime;
392. }
393. } else {
394.
395. dataFile.close();
396. Info.clear();
397. Info.setCursor(5, 0);
398. Info.print("keine");
399. Info.setCursor(2, 1);
400. Info.print("Aufzeichnung");
401.
402. }
403. }
2. #include <DallasTemperature.h>
3. #include <OneWire.h>
4. #include <DS3231.h>
5. #include <Wire.h>
6. #include <SPI.h>
7. #include <SD.h>
8.
9.
10. // Displays einbinden
11. LiquidCrystal_I2C Info(0x20, 16, 2);
12. LiquidCrystal_I2C Uhrzeit_Datum(0x21, 16, 2);
13. LiquidCrystal_I2C Sensor1(0x25, 16, 2);
14. LiquidCrystal_I2C Sensor2(0x26, 16, 2);
15. LiquidCrystal_I2C Sensor3(0x22, 16, 2);
16. LiquidCrystal_I2C Sensor4(0x24, 16, 2);
17. LiquidCrystal_I2C Sensor5(0x27, 16, 2);
18. LiquidCrystal_I2C Sensor6(0x23, 16, 2);
19.
20.
21.
22. // Datenleitung Sensor
23. #define ONE_WIRE_BUS 13
24.
25. // Anzahl Sensoren
26. int sen_number = 0;
27.
28. // Zeit Sensoren auslesen in Millis
29. const unsigned long Ausleseabstand = 1000;
30. unsigned long bisherigeZeit = 0;
31.
32. // Speicherabstand SD_Karte in Millis
33. // 60.000 = 1 Min; 300.000 = 5 Min; 600.000 = 10 Min
34. const unsigned long Speicherabstand = 120000;
35. unsigned long bisherigeZeit_2 = 0;
36.
37. // Datenleitung SD-Kartenspeicherung
38. const int chipSelect = 53;
39.
40. // Eingang Schalter Speichervorgang start/stopp
41. int Schalter = 2;
42.
43. // zu Beginn gesetzter Schalter-Speicherzustand
44. int Schalterstatus = 0;
45.
46. OneWire oneWire(ONE_WIRE_BUS);
47. DallasTemperature sensors(&oneWire);
48. DeviceAddress T1, T2, T3, T4, T5, T6;
49.
50. DS3231 clock;
51. RTCDateTime dt;
52.
53. File dataFile;
54.
55.
56.
57. void setup(void) {
58.
59. Uhrzeit_Datum.begin();
60. Serial.begin(9600);
61. sensors.begin();
62. Sensor1.begin();
63. Sensor2.begin();
64. Sensor3.begin();
65. Sensor4.begin();
66. Sensor5.begin();
67. Sensor6.begin();
68. clock.begin();
69. Info.begin();
70.
71.
72. // neue Uhrzeit einlernen (nach dem ersten Upload auskommentieren)
73. clock.setDateTime(__DATE__, __TIME__);
74.
75.
76. // SD-Karte initialisieren
77. pinMode(chipSelect, OUTPUT);
78.
79. if (SD.begin(chipSelect)) {
80.
81. Info.print("Karte vorhanden");
82. Serial.println("SD-Karte ");
83.
84. } else {
85.
86. Info.clear();
87. Info.print("Karte fehlerhaft");
88. Serial.println("Fehler SD-Karte");
89. Serial.println(" ");
90. }
91.
92. Serial.println(" ");
93.
94.
95. // Sensorsuche
96. if (!sensors.getAddress(T1, 0)) Serial.println("Sensor 1 nicht gefunden");
97. if (!sensors.getAddress(T2, 1)) Serial.println("Sensor 2 nicht gefunden");
98. if (!sensors.getAddress(T3, 2)) Serial.println("Sensor 3 nicht gefunden");
99. if (!sensors.getAddress(T4, 3)) Serial.println("Sensor 4 nicht gefunden");
100. if (!sensors.getAddress(T5, 4)) Serial.println("Sensor 5 nicht gefunden");
101. if (!sensors.getAddress(T6, 5)) Serial.println("Sensor 6 nicht gefunden");
102. Serial.println(" ");
103. Serial.println(" ");
104.
105.
106. // Abfrage Sensoranzahl
107. Serial.print("Gefunden: ");
108. Serial.print(sensors.getDeviceCount(), DEC);
109. Serial.println(" Sensoren");
110.
111.
112. // Anzeige Sensoradressen
113. for (int k = 0; k < sensors.getDeviceCount(); k++) {
114. Serial.print("Sensor "); Serial.print(k + 1);
115. Serial.print(" Address: ");
116. if (k == 0) {
117. printAddress(T1); Serial.println();
118. } else if (k == 1) {
119. printAddress(T2); Serial.println();
120. } else if (k == 2) {
121. printAddress(T3); Serial.println();
122. } else if (k == 3) {
123. printAddress(T4); Serial.println();
124. } else if (k == 4) {
125. printAddress(T5); Serial.println();
126. } else if (k == 5) {
127. printAddress(T6); Serial.println();
128. }
129. }
130. Serial.println(" ");
131. Serial.println(" ");
132. Serial.println(" ");
133.
134.
135.
136. // Text Display Sensor 1
137. Sensor1.clear();
138. Sensor1.setCursor(0, 0);
139. Sensor1.print("Sensor 1");
140.
141. // Text Display Sensor 2
142. Sensor2.clear();
143. Sensor2.setCursor(0, 0);
144. Sensor2.print("Sensor 2");
145.
146. // Text Display Sensor 3
147. Sensor3.clear();
148. Sensor3.setCursor(0, 0);
149. Sensor3.print("Sensor 3");
150.
151. // Text Display Sensor 4
152. Sensor4.clear();
153. Sensor4.setCursor(0, 0);
154. Sensor4.print("Sensor 4");
155.
156. // Text Display Sensor 5
157. Sensor5.clear();
158. Sensor5.setCursor(0, 0);
159. Sensor5.print("Sensor 5");
160.
161. // Text Display Sensor 6
162. Sensor6.clear();
163. Sensor6.setCursor(0, 0);
164. Sensor6.print("Sensor 6");
165.
166. Info.clear();
167. Info.setCursor(5, 0);
168. Info.print("keine");
169. Info.setCursor(2, 1);
170. Info.print("Aufzeichnung");
171. }
172.
173.
174. // Funktion Adressdaten abfragen
175. void printAddress(DeviceAddress deviceAddress)
176. {
177. for (uint8_t i = 0; i < 6; i++)
178. {
179. if (deviceAddress[i] < 6) Serial.print("0");
180. Serial.print(deviceAddress[i], HEX);
181. }
182. }
183.
184.
185.
186. // Funktion Temperatur schreiben
187. // "tempC, 5" bedeutet 5 Nachkommastellen werden angezeigt
188. void printTemperature(DeviceAddress deviceAddress) {
189. float tempC = sensors.getTempC(deviceAddress);
190. Serial.print(" Temp: ");
191. Serial.print(tempC, 5);
192. Serial.print(" Grad ");
193. }
194.
195.
196. // Funktion Adressdaten Schreiben
197. void printData(DeviceAddress deviceAddress) {
198. Serial.print("; Sensoradresse: ");
199. printAddress(deviceAddress);
200. Serial.print(" ");
201. printTemperature(deviceAddress);
202. Serial.println();
203. pinMode(Schalter, INPUT_PULLUP);
204. }
205.
206.
207.
208.
209.
210. void loop(void) {
211.
212.
213. // Abfrage Schalterstatus
214. Schalterstatus = digitalRead(Schalter);
215.
216.
217. // Erzeuge Millis
218. unsigned long currentTime = millis();
219. dt = clock.getDateTime();
220.
221.
222. // Datum
223. Uhrzeit_Datum.setCursor(0, 0);
224. Uhrzeit_Datum.print("Date: ");
225. Uhrzeit_Datum.print(dt.day); Uhrzeit_Datum.print(".");
226. Uhrzeit_Datum.print(dt.month); Uhrzeit_Datum.print(".");
227. Uhrzeit_Datum.print(dt.year); Uhrzeit_Datum.print(" ");
228.
229.
230. // Uhrzeit
231. Uhrzeit_Datum.setCursor(0, 1);
232. Uhrzeit_Datum.print("Time: ");
233. Uhrzeit_Datum.print(dt.hour); Uhrzeit_Datum.print(":");
234. Uhrzeit_Datum.print(dt.minute); Uhrzeit_Datum.print(":");
235. Uhrzeit_Datum.print(dt.second); Uhrzeit_Datum.print(" ");
236.
237.
238. // Schleife Sensordaten auslesen
239. if (currentTime - bisherigeZeit >= Ausleseabstand) {
240.
241. Serial.println("Lese Daten...");
242. sensors.requestTemperatures();
243. Serial.print(dt.hour); Serial.print(":");
244. Serial.print(dt.minute); Serial.print(":");
245. Serial.print(dt.second); Serial.println(" ");
246.
247. for (int k = 0; k < sensors.getDeviceCount(); k++) {
248. Serial.print("Sensor "); Serial.print(k + 1); Serial.print(" ");
249. if (k == 0) {
250. printData(T1);
251. } else if (k == 1) {
252. printData(T2);
253. } else if (k == 2) {
254. printData(T3);
255. } else if (k == 3) {
256. printData(T4);
257. } else if (k == 4) {
258. printData(T5);
259. } else if (k == 5) {
260. printData(T6);
261. }
262. }
263.
264.
265. // Sensordaten auf Displays schreiben
266. if (sen_number == sensors.getDeviceCount()) {
267. sen_number = 0; // reset counter
268. }
269. if (sen_number == 0) {
270.
271. // Text Display Sensor 1
272. Sensor1.setCursor(0, 0);
273. Sensor1.print("Sensor 1");
274. Sensor1.setCursor(0, 1);
275. Sensor1.print("Temp: ");
276. Sensor1.print(sensors.getTempC(T1), 5); Sensor1.write((char)223); Sensor1.print("C");
277.
278. } else if (sen_number == 1) {
279.
280. // Text Display Sensor 2
281. Sensor2.setCursor(0, 0);
282. Sensor2.print("Sensor 2");
283. Sensor2.setCursor(0, 1);
284. Sensor2.print("Temp: ");
285. Sensor2.print(sensors.getTempC(T2), 5); Sensor2.write((char)223); Sensor2.print("C");
286.
287. } else if (sen_number == 2) {
288.
289. // Text Display Sensor 3
290. Sensor3.setCursor(0, 0);
291. Sensor3.print("Sensor 3");
292. Sensor3.setCursor(0, 1);
293. Sensor3.print("Temp: ");
294. Sensor3.print(sensors.getTempC(T3), 5); Sensor3.write((char)223); Sensor3.print("C");
295.
296. } else if (sen_number == 3) {
297.
298. // Text Display Sensor 4
299. Sensor4.setCursor(0, 0);
300. Sensor4.print("Sensor 4");
301. Sensor4.setCursor(0, 4);
302. Sensor4.print("Temp: ");
303. Sensor4.print(sensors.getTempC(T4), 5); Sensor4.write((char)223); Sensor4.print("C");
304.
305. } else if (sen_number == 4) {
306.
307. // Text Display Sensor 5
308. Sensor5.setCursor(0, 0);
309. Sensor5.print("Sensor 5");
310. Sensor5.setCursor(0, 1);
311. Sensor5.print("Temp: ");
312. Sensor5.print(sensors.getTempC(T5), 5); Sensor5.write((char)223); Sensor5.print("C");
313.
314. } else if (sen_number == 5) {
315.
316. // Text Display Sensor 6
317. Sensor6.setCursor(0, 0);
318. Sensor6.print("Sensor 6");
319. Sensor6.setCursor(0, 1);
320. Sensor6.print("Temp: ");
321. Sensor6.print(sensors.getTempC(T6), 5); Sensor6.write((char)223); Sensor6.print("C");
322.
323. }
324. Serial.println(" ");
325. sen_number++ ;
326. bisherigeZeit = currentTime;
327. }
328.
329.
330. if (SD.begin(chipSelect) && Schalterstatus == LOW) {
331.
332. Info.clear();
333. Info.setCursor(2, 0);
334. Info.print("Aufzeichnung");
335. Info.setCursor(5, 1);
336. Info.print("aktiv");
337.
338.
339. // Datenträgerspeicherung bei Schalter betätigt und SD-Karte vorhanden
340. if (currentTime - bisherigeZeit_2 >= Speicherabstand) {
341.
342. float a = sensors.getTempC(T1);
343. float b = sensors.getTempC(T2);
344. float c = sensors.getTempC(T3);
345. float d = sensors.getTempC(T4);
346. float e = sensors.getTempC(T5);
347. float f = sensors.getTempC(T6);
348.
349. String DatenString = "";
350.
351. DatenString += String(a);
352. DatenString += ";";
353.
354. DatenString += String(b);
355. DatenString += ";";
356.
357. DatenString += String(c);
358. DatenString += ";";
359.
360. DatenString += String(d);
361. DatenString += ";";
362.
363. DatenString += String(e);
364. DatenString += ";";
365.
366. DatenString += String(f);
367.
368.
369.
370. // Speicherdatei erzeugen
371. dataFile = SD.open("DATEN.csv", FILE_WRITE);
372.
373. if (dataFile) {
374.
375. // Datum
376. dataFile.print(dt.day); dataFile.print(".");
377. dataFile.print(dt.month); dataFile.print(".");
378. dataFile.print(dt.year); dataFile.print(";");
379.
380. // Uhrzeit
381. dataFile.print(dt.hour); dataFile.print(":");
382. dataFile.print(dt.minute); dataFile.print(":");
383. dataFile.print(dt.second); dataFile.print(";");
384.
385. // Sensordaten
386. dataFile.print(DatenString);
387. dataFile.println(" ");
388.
389. dataFile.close();
390. }
391. bisherigeZeit_2 = currentTime;
392. }
393. } else {
394.
395. dataFile.close();
396. Info.clear();
397. Info.setCursor(5, 0);
398. Info.print("keine");
399. Info.setCursor(2, 1);
400. Info.print("Aufzeichnung");
401.
402. }
403. }