|
|
@@ -2,7 +2,7 @@ |
|
|
|
// |
|
|
|
/* |
|
|
|
Name: Teensy4.1_Datalogger new.ino |
|
|
|
Created: 03.05.2022 12:04:32 |
|
|
|
Created: 31.08.2022 18:39:32 |
|
|
|
Author: GAMINGMASHEEN\Julian Graf |
|
|
|
*/ |
|
|
|
|
|
|
@@ -49,11 +49,11 @@ const char software_name[] = "Software: Teensy_datalog V.2"; |
|
|
|
const int min_voltage_batterie = 13; |
|
|
|
const int fixed_resistor_temperatur = 500; |
|
|
|
|
|
|
|
const int power_Temp_sensor = 34, power_Windfahne = 36, LED_Fail = 24, |
|
|
|
LED_Write = 5, LED_Normal = 6, LED_Batterie = 7, |
|
|
|
const int power_Temp_sensor = 34, power_Windfahne = 36, LED_Fail = 24, R_Temp_fix = 500, |
|
|
|
LED_Write = 5, LED_Normal = 6, LED_Batterie = 7, Grenz_U_Batterie = 13, |
|
|
|
taster_manuell_speichern = 28, Windfahne = 20, T_sensor_input = 17, Batterie_input = 38; |
|
|
|
|
|
|
|
int last_second, last_minute, last_hour; |
|
|
|
int last_second, last_minute, last_hour, seconds_for_blink; |
|
|
|
|
|
|
|
|
|
|
|
struct calculations { |
|
|
@@ -114,7 +114,7 @@ public: |
|
|
|
|
|
|
|
|
|
|
|
struct anemomenter_maessurement { |
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
void setup(int pin) { |
|
|
|
this->reed_contact = Bounce(pin, 10); |
|
|
@@ -125,7 +125,7 @@ public: |
|
|
|
count_per_second++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void save_wind_speed() { |
|
|
|
wind_speed_per_second[saved_seconds] = 0.4 * count_per_second; |
|
|
|
saved_seconds++; |
|
|
@@ -144,15 +144,15 @@ public: |
|
|
|
file.printf("Arith. Mittel: % f,\tStandard Abw.: %f\t", values[i].arithmetic_mean, values[i].arithmetic_deviation); |
|
|
|
file.printf("Quadr. Mittel: % f,\tStandard Abw.: %f\t", values[i].square_mean, values[i].square_deviation); |
|
|
|
file.printf("Kub. Mittel: %f,\tStandard Abw.: %f\t", values[i].cubic_mean, values[i].cubic_deviation); |
|
|
|
file.printf("Übersprungene Sek.: %i\n", values[i].seconds_skipped); |
|
|
|
file.printf("Ãœbersprungene Sek.: %i\n", values[i].seconds_skipped); |
|
|
|
} |
|
|
|
|
|
|
|
file.printf("Übersprungene Min.: %i\n", 60 - saved_minutes); |
|
|
|
|
|
|
|
file.printf("Ãœbersprungene Min.: %i\n", 60 - saved_minutes); |
|
|
|
|
|
|
|
saved_minutes = 0; |
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
private: |
|
|
|
int count_per_second = 0; |
|
|
|
int saved_seconds = 0; |
|
|
|
int saved_minutes = 0; |
|
|
@@ -164,14 +164,60 @@ private: |
|
|
|
|
|
|
|
}anemometer_1, anemometer_2, anemometer_3; |
|
|
|
|
|
|
|
struct temp_sensor { |
|
|
|
private: |
|
|
|
int U_Temp; |
|
|
|
int R_Temp; |
|
|
|
float Temp = 0; |
|
|
|
short int array_Temp_datenblatt[20] = { -30, -20, -10, 0, 10, 20, 25, 30, 40, 50, |
|
|
|
391, 424, 460, 498, 538, 581, 603, 626, 672, 722}; |
|
|
|
public: |
|
|
|
void measure() { |
|
|
|
digitalWrite(power_Temp_sensor, HIGH); |
|
|
|
U_Temp = analogRead(T_sensor_input); |
|
|
|
digitalWrite(power_Temp_sensor, LOW); |
|
|
|
R_Temp = R_Temp_fix / (1023 - U_Temp); |
|
|
|
|
|
|
|
for (int t = 0; t < 9; t++) { |
|
|
|
if ((R_Temp >= array_Temp_datenblatt[t + 10]) && (R_Temp <= array_Temp_datenblatt[t + 11])) { |
|
|
|
Temp = array_Temp_datenblatt[t] + ((R_Temp - array_Temp_datenblatt[t + 10]) * (array_Temp_datenblatt[t + 1] - array_Temp_datenblatt[t]) / (array_Temp_datenblatt[t + 11] - array_Temp_datenblatt[t + 10])); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void file_print() { |
|
|
|
printf("Temperatur: %f.2 °C\n", Temp); |
|
|
|
} |
|
|
|
} temp_sensor_1; |
|
|
|
|
|
|
|
// Define Function Prototypes that use User Types below here or use a .h file |
|
|
|
// |
|
|
|
struct wind_vain { |
|
|
|
private: |
|
|
|
float wind_sec; |
|
|
|
float wind_summ = 0; |
|
|
|
int values[60]; |
|
|
|
int saved_minutes = 0; |
|
|
|
|
|
|
|
public: |
|
|
|
void measure() { |
|
|
|
digitalWrite(power_Windfahne, HIGH); |
|
|
|
wind_sec = map(analogRead(Windfahne), 0, 1023, 20, 350); |
|
|
|
digitalWrite(power_Windfahne, LOW); |
|
|
|
wind_summ += wind_sec; |
|
|
|
} |
|
|
|
void calculate() { |
|
|
|
values[saved_minutes] = wind_summ; |
|
|
|
wind_summ = 0; |
|
|
|
saved_minutes++; |
|
|
|
} |
|
|
|
void file_print() { |
|
|
|
for (int i = 0; i < saved_minutes; i++) { |
|
|
|
printf("Windrichtung in ° Winkel: %f.2\n", values[i]); |
|
|
|
} |
|
|
|
saved_minutes = 0; |
|
|
|
} |
|
|
|
|
|
|
|
}wind_vain_1; |
|
|
|
|
|
|
|
// Define Functions below here or use other .ino or cpp files |
|
|
|
// |
|
|
|
|
|
|
|
void dateTime(uint16_t* date, uint16_t* time, uint8_t* ms10) { |
|
|
|
|
|
|
@@ -186,16 +232,16 @@ void dateTime(uint16_t* date, uint16_t* time, uint8_t* ms10) { |
|
|
|
} |
|
|
|
|
|
|
|
void write_sd() { |
|
|
|
digitalWrite(LED_Write, HIGH); |
|
|
|
char file_name[50]; |
|
|
|
|
|
|
|
FsDateTime::setCallback(dateTime); |
|
|
|
|
|
|
|
|
|
|
|
sprintf(file_name, "Windmessmast-%d.%d.%d_%d:%d.txt", year(), month(), day(), hour(), minute()); |
|
|
|
sd.begin(SD_CONFIG); |
|
|
|
if (file.open(file_name, FILE_WRITE)) { |
|
|
|
Serial.println("Start SD schreiben"); |
|
|
|
|
|
|
|
file.println("Messdaten von Windmessmasst"); |
|
|
|
file.println("Messdaten von Windmessmasst"); |
|
|
|
file.println(); |
|
|
|
file.println("Data logger : Teensy 4.1"); |
|
|
|
file.println(software_name); |
|
|
@@ -207,25 +253,47 @@ void write_sd() { |
|
|
|
anemometer_2.file_print(); |
|
|
|
file.println("Anemometer_3 Werte:"); |
|
|
|
anemometer_3.file_print(); |
|
|
|
file.println("Temperatursensor_1 Werte:"); |
|
|
|
temp_sensor_1.file_print(); |
|
|
|
file.println("Windfahne_1 Werte:"); |
|
|
|
wind_vain_1.file_print(); |
|
|
|
|
|
|
|
file.close(); |
|
|
|
Serial.println("Ende des Schreibvorgangs"); |
|
|
|
} |
|
|
|
|
|
|
|
digitalWrite(LED_Write, LOW); |
|
|
|
} |
|
|
|
|
|
|
|
void every_second() { |
|
|
|
|
|
|
|
anemometer_1.save_wind_speed(); |
|
|
|
anemometer_2.save_wind_speed(); |
|
|
|
anemometer_3.save_wind_speed(); |
|
|
|
wind_vain_1.measure(); |
|
|
|
|
|
|
|
if (digitalRead(taster_manuell_speichern) == HIGH){ |
|
|
|
write_sd(); |
|
|
|
} |
|
|
|
|
|
|
|
digitalWrite(LED_Normal, LOW); |
|
|
|
seconds_for_blink++; |
|
|
|
if (seconds_for_blink % 10 == 0) { |
|
|
|
digitalWrite(LED_Normal, HIGH); |
|
|
|
} |
|
|
|
|
|
|
|
last_second = second(); |
|
|
|
} |
|
|
|
|
|
|
|
void every_minute() { |
|
|
|
|
|
|
|
anemometer_1.calculate(); |
|
|
|
anemometer_2.calculate(); |
|
|
|
anemometer_3.calculate(); |
|
|
|
wind_vain_1.calculate(); |
|
|
|
|
|
|
|
if((analogRead(Batterie_input) * 15.3 / float(1023)) < Grenz_U_Batterie) { |
|
|
|
digitalWrite(LED_Batterie, HIGH); |
|
|
|
} |
|
|
|
|
|
|
|
last_minute = minute(); |
|
|
|
} |
|
|
@@ -269,7 +337,7 @@ void setup() |
|
|
|
anemometer_1.setup(2); |
|
|
|
anemometer_2.setup(9); |
|
|
|
anemometer_3.setup(22); |
|
|
|
|
|
|
|
seconds_for_blink = 0; |
|
|
|
|
|
|
|
Serial.println("Messung startet"); |
|
|
|
last_second = second(); |
|
|
@@ -296,4 +364,4 @@ void loop() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |