Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
arduino [2024/02/29 13:36] – Externe Bearbeitung 127.0.0.1arduino [2024/04/20 17:22] (aktuell) – [Joystick] gerald
Zeile 75: Zeile 75:
  
 {{ ::arduinojoysticklibrary-version-1.0.zip |}} {{ ::arduinojoysticklibrary-version-1.0.zip |}}
 +
 +
 +==== Bewässerungsautomatik ====
 +
 +
 +4 Pumpen, 4 Feuchtigkeitssensoren, Board mit 4 Relais bei Ali für cs 13 EU.
 +
 +{{::4bewaesserung_ali.png?400|}}
 +
 +{{:4bewaesserung.png?400|}}
 +
 +Quelle((https://forum.arduino.cc/t/capacitive-soil-moisture-sensor-4-relay/1244826/6))
 +
 +<code>
 +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<channels; c++) {
 +    pinMode(moisturePin[c], INPUT);
 +    pinMode(relayPin[c], OUTPUT);
 +  }
 +  pinMode(moisturePinTorr, INPUT);
 +}
 +
 +void loop() {
 +  int moistureLeveltorr = analogRead(moisturePinTorr);
 +  for (byte c=0; c<channels; c++) {
 +    int moistureLevel = analogRead(moisturePin[c]);
 +
 +    if (moistureLevel > threshold[c] && moistureLeveltorr < thresholdTorr) {
 +      Serial.print("Soil moisture ");
 +      Serial.print(c);
 +      Serial.println(" is DRY => activating pump");
 +      digitalWrite(relayPin[c], LOW);  // Turn on the pump
 +
 +      // 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);         // Convert to milliseconds
 +</code>
 +
 +
 +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.
  
  
  
 
Nach oben
arduino.txt · Zuletzt geändert: 2024/04/20 17:22 von gerald
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0
DFmW2CEce3htPL1uNQuHUVu4Tk6WXigFQp   Dogecoin Donations Accepted Here    DFmW2CEce3htPL1uNQuHUVu4Tk6WXigFQp  DFmW2CEce3htPL1uNQuHUVu4Tk6WXigFQp