Untitled
unknown
c_cpp
2 years ago
2.8 kB
4
Indexable
void loop() { // try to parse packett int packetSize = LoRa.parsePacket (); Donnee donnee; if (packetSize) { uint8_t* x_tab = new uint8_t [sizeof (Donnee)]; int i = 0; while (LoRa.available()) { uint8_t incoming = LoRa.read(); x_tab[i] = incoming; i++; } Donnee* x = (Donnee *) x_tab; Serial.print("L'identicatif de l'émetteur: "); Serial.println(x->id); Serial.println(x->description); Serial.print("Wind speed : "); Serial.print(x->speed); Serial.println("m/s"); Serial.println("-----------------------------------"); float t = dht.readTemperature(); float h = dht.readHumidity(); donnee.id = ObjectID; delay(1000); Serial.print("L'identifiant est: "); Serial.println( donnee.id); Serial.print("Temperature : "); Serial.print( t); Serial.print( "°C"); Serial.print(" | Humidité1: "); Serial.print( h); Serial.println("%"); Serial.println("-----------------------------------"); bool prevRelay_1 = Relay_1; bool prevRelay_2 = Relay_2; bool prevRelay_3 = Relay_3; bool prevRelay_4 = Relay_4; if ( h < 40 || t >30){ digitalWrite(Elctrovanne_1,HIGH); Relay_1 = true; } else { digitalWrite(Elctrovanne_1,LOW); Relay_1 = false; } if ( h < 40 || t >30){ digitalWrite(Elctrovanne_2,HIGH); Relay_2 = true; } else { digitalWrite(Elctrovanne_2,LOW); Relay_2 = false; } if ( h < 40 || t > 30){ digitalWrite(Elctrovanne_3,HIGH); Relay_3 = true; } else { digitalWrite(Elctrovanne_3,LOW); Relay_3 = false; } if (Relay_1 || Relay_2 || Relay_3 ){ //delay(10000); digitalWrite(Pompe,HIGH); Relay_4 = true; } else { digitalWrite(Pompe,LOW); Relay_4 = false; } if (strstr(x->description, "rain") != NULL) { digitalWrite(Pompe, LOW); Relay_4 = 0; } if (x->speed > 30) { digitalWrite(Pompe, HIGH); } display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(1, 0); display.println("Etat du systeme:"); display.println(" "); if (Relay_4 ) { display.println("La pompe est ouvert"); } else { display.println("La pompe est fermée "); } if (Relay_1) { display.println("Vanne 1 est ouvert"); } else { display.println("Vanne 1 est fermée"); } if (Relay_2) { display.println("Vanne 2 est ouvert"); } else { display.println("Vanne 2 est fermée"); } if (Relay_3) { display.println("Vanne 3 est ouvert"); } else { display.println("Vanne 3 est fermée"); } display.display(); delete x_tab; } delay(50); }
Editor is loading...