Guten Tag, Ich habe folgendes Programm:
#include <MPL3115A2.h>
#include <SPI.h>
#include <SD.h>
#include "DHT.h"
#include <Wire.h>
#include <ds3231.h>
//#include "SparkFunMPL3115A2.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
MPL3115A2 myPressure;
DS3231 clock;
RTCDateTime dt;
const int chipSelect = 4;
const int trigPin = 24;
const int echoPin = 22;
long duration;
int distance;
int interruptPin = 3;
volatile int state = 0 ;
uint32_t millis_alt;
uint32_t millis_alt1;
#define DHT22PIN 32
#define DHT22TYPE DHT22
DHT dht22(DHT22PIN, DHT22TYPE);
void setup() {
Wire.begin();
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), change_status, LOW);
Serial.println("Initialize DS3231");
clock.begin();
clock.setDateTime(__DATE__, __TIME__);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
lcd.begin(16, 2);
myPressure.begin();
dht22.begin();
myPressure.setModeBarometer();
myPressure.setOversampleRate(7);
myPressure.enableEventFlags();
while (!Serial) {
;
}
Serial.print("Initialisiere SD-Karte");
if (!SD.begin(chipSelect)) {
Serial.println("Karte nicht gefunden");
return;
}
Serial.println("Karte erfolgreich initialisiert");
}
void change_status() {
state = state+1 ;
if
(state >= 4) { // Wenn Status > 4 ,dann ...
state = 0 ; // ... Status zurücksetzen , default = 0
}
}
void printValues(String sensor, float humidy, float temp) {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
float helligkeit = analogRead(A0);
float standorthoehe = 278 ;
float pressure = myPressure.readPressure();
float press_hPa = pressure / 100 ;
float differenz = standorthoehe / 8 ;
float pressure_1 = differenz + press_hPa ;
float pressure_hPa = pressure_1 ;
// File dataFile = SD.open("datalog.txt", FILE_WRITE);
//
//
//
// if (dataFile) {
// dataFile.print(clock.dateFormat("d-m-Y", dt));
// dataFile.print(" ");
// dataFile.print(clock.dateFormat("H:i:s", dt));
// dataFile.print(" ");
// dataFile.print(helligkeit); //Speichern der Messwerte in der geöffneten Datei
// dataFile.print(" "); //Trennzeichen für die .txt (DATALOG.txt) Datei
// dataFile.print(distance);
// dataFile.print(" ");
// dataFile.print(humidy);
// dataFile.print(" ");
// dataFile.print(temp);
// dataFile.print(" ");
// dataFile.print(pressure_hPa, 1);
// dataFile.println(" ");
// dataFile.close();
Serial.print(clock.dateFormat("d-m-Y", dt));
Serial.print(";");
Serial.print(clock.dateFormat("H:i:s", dt));
Serial.print(";");
Serial.print(helligkeit);
Serial.print(";");
Serial.print(distance);
Serial.print(";");
Serial.print(humidy);
Serial.print(";");
Serial.print(temp);
Serial.print(";");
Serial.print(pressure_hPa, 1);
Serial.println(";");
//
// } else {
// Serial.println("Fehler beim Öffnen!");
// }
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
float helligkeit = analogRead(A0);
float standorthoehe = 278 ;
float pressure = myPressure.readPressure();
float press_hPa = pressure / 100 ;
float differenz = standorthoehe / 8 ;
float pressure_1 = differenz + press_hPa ;
float pressure_hPa = pressure_1 ;
dt = clock.getDateTime();
float humidyDHT22 = dht22.readHumidity(); //relative Luftfeuchtigkeit vom Sensor DHT22 lesen
float tempDHT22 = dht22.readTemperature(); //Temperatur vom Sensor DHT22 lesen
if (isnan(humidyDHT22) || isnan(tempDHT22)) {
Serial.println("DHT22 konnte nicht ausgelesen werden");
} else {
if (millis() - millis_alt > 5000)
{ millis_alt = millis();
printValues("DHT22", humidyDHT22, tempDHT22);
// Serial.print(state);
}
if (millis() - millis_alt1 > 200)
{ millis_alt1 = millis();
if (state == 0) // Wenn Zähler gleich null
{
lcd.clear();
// set up the LCD's number of columns and rows:
// Print a message to the LCD.
lcd.setCursor(3, 0);
lcd.print(clock.dateFormat("d-m-Y", dt));
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(4, 1);
// print the number of seconds since reset:
lcd.print((clock.dateFormat("H:i:s", dt)));
}
if (state == 1) // Wenn Zähler gleich 1
{
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("LUFTDRUCK");
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(3, 1);
// print the number of seconds since reset:
lcd.print(pressure_hPa);
lcd.print("hPa");
}
if (state == 2) // Wenn Zähler gleich 1
{
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("LUFTFEUCHTIGKEIT");
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(3, 1);
// print the number of seconds since reset:
lcd.print(humidyDHT22);
lcd.print("%");
}
if (state == 3) // Wenn Zähler gleich 1
{
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("TEMPERATUR.");
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(3, 1);
// print the number of seconds since reset:
lcd.print(tempDHT22);
lcd.print("°C");
}
if (state == 4) // Wenn Zähler gleich 1
{
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("HELLIGKEIT");
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(3, 1);
// print the number of seconds since reset:
lcd.print(helligkeit);
}
}
}
}
Und bekomme folgende Fehlermeldung, ich bin mit meinem Latein am Ende
version_april01.ino:13:1: error: 'DS3231' does not name a type
version_april01.ino:14:1: error: 'RTCDateTime' does not name a type
version_april01.ino: In function 'void setup()':
version_april01.ino:38:53: error: 'digitalPinToInterrupt' was not declared in this scope
version_april01.ino:40:3: error: 'clock' was not declared in this scope
version_april01.ino: In function 'void printValues(String, float, float)':
version_april01.ino:125:18: error: 'clock' was not declared in this scope
version_april01.ino:125:44: error: 'dt' was not declared in this scope
version_april01.ino: In function 'void loop()':
version_april01.ino:170:3: error: 'dt' was not declared in this scope
version_april01.ino:170:8: error: 'clock' was not declared in this scope
Vielen Dank fuer jede hilfreiche Antwort!