Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| arduino [2023/11/22 13:09] – [Flipper] gerald | arduino [2024/04/20 17:22] (aktuell) – [Joystick] gerald | ||
|---|---|---|---|
| Zeile 75: | Zeile 75: | ||
| {{ :: | {{ :: | ||
| + | |||
| + | |||
| + | ==== Bewässerungsautomatik ==== | ||
| + | |||
| + | |||
| + | 4 Pumpen, 4 Feuchtigkeitssensoren, | ||
| + | |||
| + | {{:: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Quelle((https:// | ||
| + | |||
| + | < | ||
| + | const byte channels = 3; | ||
| + | const byte relayPin[channels] = {3, 5, 7}; // Pins controlling the relays | ||
| + | const byte moisturePin[channels] = {A0, A1, A2}; // Analog pins connected to the moisture sensors | ||
| + | const int threshold[channels] = {350, 400, 400}; // Adjust these values based on your soil conditions | ||
| + | const byte moisturePinTorr = A3; // Analog pins connected to the moisture sensors | ||
| + | const int thresholdTorr = 530; // Adjust these values based on your soil conditions | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(9600); | ||
| + | for (byte c=0; c< | ||
| + | pinMode(moisturePin[c], | ||
| + | pinMode(relayPin[c], | ||
| + | } | ||
| + | pinMode(moisturePinTorr, | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | int moistureLeveltorr = analogRead(moisturePinTorr); | ||
| + | for (byte c=0; c< | ||
| + | int moistureLevel = analogRead(moisturePin[c]); | ||
| + | |||
| + | if (moistureLevel > threshold[c] && moistureLeveltorr < thresholdTorr) { | ||
| + | Serial.print(" | ||
| + | Serial.print(c); | ||
| + | Serial.println(" | ||
| + | digitalWrite(relayPin[c], | ||
| + | |||
| + | // Decide how long the pump should run (e.g., 5-10 seconds) | ||
| + | int pumpRunTime = random(15, 19); // Random time between 5 and 10 seconds | ||
| + | delay(pumpRunTime * 1000); | ||
| + | </ | ||
| + | |||
| + | |||
| + | 3 pumps and 3 relay coils are too much load on USB supply, you need a separate 5 volt supply of at least 2 Amps. Also, you should have a kickback suppression diode in parallel with each pump, cathode (end with band) toward + (positive) voltage. | ||