31 lines
842 B
C
31 lines
842 B
C
|
|
int sensorPin = sensorMoisturePin; // siehe pins.h
|
|
int sensorValue;
|
|
|
|
int dryAnalogValue = 4095;
|
|
|
|
int wetAnalogValue = 1023;
|
|
int DryValuePercent = 0;
|
|
int WetValuepercent = 100;
|
|
|
|
int moistureValuePercent;
|
|
|
|
int sensor_moisture_value;
|
|
void setupHumidity() {
|
|
Serial.print("Setting up Humidity");
|
|
}
|
|
void getHumidity() {
|
|
|
|
if (sensorValue = analogRead(sensorPin)) {
|
|
Serial.print("Analog moisture Value : ");
|
|
Serial.println(sensorValue);
|
|
moistureValuePercent = map(sensorValue, dryAnalogValue, wetAnalogValue, DryValuePercent, WetValuepercent);
|
|
Serial.print("moisture percent: ");
|
|
Serial.print(moistureValuePercent);
|
|
Serial.println("%");
|
|
if (moistureValuePercent < DryValuePercent) {
|
|
Serial.println("plant is dry !! ");
|
|
}
|
|
sensor_moisture_value = moistureValuePercent;
|
|
}
|
|
} |