Es kann doch nicht so schwierig sein, in die Funktion ein paar Kontrollausgaben ein zu bauen.
Außerdem sind die Funktionen auf Papier durchspielbar.
Dann sieht man doch GENAU was passiert.
Aber ich kann dir schon eins sagen, was mich stört:
Mittelwert = Mittelwert + analogRead(Sens[SensorNr]);
Würde ich auf jeden Fall eher so schreiben:
summe += analogRead(Sens[SensorNr]);
Warum?
- kürzer.
- es ist an der Stelle eine Summe, und noch lange kein Mittelwert.
- summe ist eine Variable, beginnt also mit einem Kleinbuchstaben.
Logisch und konsequent folgt daraus:
Mittelwert = Mittelwert / SensReadTimes; // unschön
mittelwert = summe / SensReadTimes; // besser
Der Grund:
Wenn Variablen während des Programmlaufs ihre Bedeutung ändern, dann hat man einen excellenten Weg gefunden sich selber zu verwirren und sich dabei Frikadellen ans Knie zu nageln.
Am Rande.
Dein geposteter Code kompiliert nicht.
Ist also untestbar.
sketch_aug12b:27:16: error: 'RecordingSize' was not declared in this scope
27 | int SensData[RecordingSize]; // Daten des Sensors
| ^~~~~~~~~~~~~
E:\Programme\arduino\portable\sketchbook\sketch_aug12b\sketch_aug12b.ino: In function 'void setup()':
sketch_aug12b:38:13: error: 'Sens' was not declared in this scope; did you mean 'Sensor'?
38 | pinMode(Sens[i], INPUT);
| ^~~~
| Sensor
sketch_aug12b:39:13: error: 'Pump' was not declared in this scope
39 | pinMode(Pump[i], OUTPUT);
| ^~~~
sketch_aug12b:40:13: error: 'SensLED' was not declared in this scope
40 | pinMode(SensLED[i], OUTPUT);
| ^~~~~~~
E:\Programme\arduino\portable\sketchbook\sketch_aug12b\sketch_aug12b.ino: In function 'bool ReadCalibButton()':
sketch_aug12b:59:24: error: 'LastButtonStatus' was not declared in this scope
59 | if (ButtonReading != LastButtonStatus) { // Wenn Button noch bounced resette debounce timer
| ^~~~~~~~~~~~~~~~
sketch_aug12b:60:5: error: 'DebounceTimer' was not declared in this scope
60 | DebounceTimer = millis();
| ^~~~~~~~~~~~~
sketch_aug12b:62:18: error: 'DebounceTimer' was not declared in this scope
62 | if (millis() - DebounceTimer > DebounceTime) { // Wenn debounced auslesen
| ^~~~~~~~~~~~~
sketch_aug12b:62:34: error: 'DebounceTime' was not declared in this scope
62 | if (millis() - DebounceTimer > DebounceTime) { // Wenn debounced auslesen
| ^~~~~~~~~~~~
sketch_aug12b:63:26: error: 'ButtonStatus' was not declared in this scope
63 | if (ButtonReading != ButtonStatus) { // Wenn sich der Status geaendert hat
| ^~~~~~~~~~~~
sketch_aug12b:66:9: error: 'LastButtonStatus' was not declared in this scope
66 | LastButtonStatus = ButtonReading;
| ^~~~~~~~~~~~~~~~
sketch_aug12b:71:3: error: 'LastButtonStatus' was not declared in this scope
71 | LastButtonStatus = ButtonReading;
| ^~~~~~~~~~~~~~~~
E:\Programme\arduino\portable\sketchbook\sketch_aug12b\sketch_aug12b.ino: In function 'int CalibrateSens(int)':
sketch_aug12b:82:16: error: 'Pump' was not declared in this scope
82 | digitalWrite(Pump[SensorNr], LOW); // Pumpe aus
| ^~~~
sketch_aug12b:88:5: error: 'Err' was not declared in this scope
88 | Err = 0;
| ^~~
sketch_aug12b:89:18: error: 'ErrorLED' was not declared in this scope
89 | digitalWrite(ErrorLED, RGBoff);
| ^~~~~~~~
sketch_aug12b:89:28: error: 'RGBoff' was not declared in this scope
89 | digitalWrite(ErrorLED, RGBoff);
| ^~~~~~
sketch_aug12b:90:18: error: 'SensLED' was not declared in this scope
90 | digitalWrite(SensLED[SensorNr], LEDon);
| ^~~~~~~
sketch_aug12b:91:27: error: 'ADC_Differenz' was not declared in this scope
91 | Messwert = Messwert - ADC_Differenz; // Kalibration veringern, damit nicht gleich gegossen wird, wenn Messwert minimal schwankt
| ^~~~~~~~~~~~~
sketch_aug12b:97:18: error: 'SensLED' was not declared in this scope
97 | digitalWrite(SensLED[SensorNr], LEDoff);
| ^~~~~~~
E:\Programme\arduino\portable\sketchbook\sketch_aug12b\sketch_aug12b.ino: In function 'int ReadSens(int)':
sketch_aug12b:106:42: error: 'Sens' was not declared in this scope; did you mean 'Sensor'?
106 | Mittelwert = Mittelwert + analogRead(Sens[SensorNr]);
| ^~~~
| Sensor
sketch_aug12b:111:5: error: 'SaveData' was not declared in this scope
111 | SaveData(SensorNr, Mittelwert); // Sensordaten speichern
| ^~~~~~~~
E:\Programme\arduino\portable\sketchbook\sketch_aug12b\sketch_aug12b.ino: In function 'void SaveCalib(int, int)':
sketch_aug12b:121:18: error: 'EEData' was not declared in this scope
121 | for (int i = EEData; i < EEPROM.length(); i++) { // EEProm Datenbereich loeschen
| ^~~~~~
sketch_aug12b:121:30: error: 'EEPROM' was not declared in this scope
121 | for (int i = EEData; i < EEPROM.length(); i++) { // EEProm Datenbereich loeschen
| ^~~~~~
sketch_aug12b:124:5: error: 'EEPROM' was not declared in this scope
124 | EEPROM.update(EECalib, map(Calibwert, Calibwert - EEMapSpan, Calibwert + EEMapSpan, 0, 255)); // Mappe Kalibration um den Calibwert-Bereich auf 256 und schreibe in EEProm Speicher fuer Kalibration
| ^~~~~~
sketch_aug12b:124:19: error: 'EECalib' was not declared in this scope
124 | EEPROM.update(EECalib, map(Calibwert, Calibwert - EEMapSpan, Calibwert + EEMapSpan, 0, 255)); // Mappe Kalibration um den Calibwert-Bereich auf 256 und schreibe in EEProm Speicher fuer Kalibration
| ^~~~~~~
sketch_aug12b:124:55: error: 'EEMapSpan' was not declared in this scope
124 | EEPROM.update(EECalib, map(Calibwert, Calibwert - EEMapSpan, Calibwert + EEMapSpan, 0, 255)); // Mappe Kalibration um den Calibwert-Bereich auf 256 und schreibe in EEProm Speicher fuer Kalibration
| ^~~~~~~~~
sketch_aug12b:125:5: error: 'EE_Rec_Enable' was not declared in this scope; did you mean 'EE_Enable'?
125 | EE_Rec_Enable = 1; // Aufzeichnung wieder aktivieren - Wird deaktiviert durch Savedata()
| ^~~~~~~~~~~~~
| EE_Enable
sketch_aug12b:128:25: error: 'RecordingSize' was not declared in this scope
128 | for (int i = 0; i < RecordingSize; i++) { // Datenbereich loeschen
| ^~~~~~~~~~~~~
sketch_aug12b:129:33: error: 'struct Sensoren' has no member named 'SensData'
129 | SaveData(Sensor[SensorNr].SensData[i], 0);
| ^~~~~~~~
sketch_aug12b:129:7: error: 'SaveData' was not declared in this scope
129 | SaveData(Sensor[SensorNr].SensData[i], 0);
| ^~~~~~~~
sketch_aug12b:132:5: error: 'Rec_Enable' was not declared in this scope; did you mean 'EE_Enable'?
132 | Rec_Enable = 1; // Aufzeichnung wieder aktivieren - Wird deaktiviert durch Savedata()
| ^~~~~~~~~~
| EE_Enable
exit status 1
'RecordingSize' was not declared in this scope
Testest du selber überhaupt, was du hier zeigst?