|
@@ -1,13 +1,13 @@
|
|
|
|
|
|
|
|
#include <OneWire.h>
|
|
#include <OneWire.h>
|
|
|
-#include <DS18B20.h>
|
|
|
|
|
-#include <DS3231.h>
|
|
|
|
|
|
|
+#include <DS18B20.h> //DS18B20_RT by rob tillaart
|
|
|
|
|
+#include <DS3231.h> //DS3231 by andrew wickert
|
|
|
#include <Wire.h>
|
|
#include <Wire.h>
|
|
|
|
|
|
|
|
-#define ONE_WIRE_BUS 2
|
|
|
|
|
|
|
+#define ONE_WIRE_BUS 3
|
|
|
|
|
|
|
|
//pin relay
|
|
//pin relay
|
|
|
-const int ExtracteurPin = 3;
|
|
|
|
|
|
|
+const int ExtracteurPin = 2;
|
|
|
const int Rouge1Pin = 4;
|
|
const int Rouge1Pin = 4;
|
|
|
const int Rouge2Pin = 5;
|
|
const int Rouge2Pin = 5;
|
|
|
const int Bleu1Pin = 6;
|
|
const int Bleu1Pin = 6;
|
|
@@ -28,6 +28,13 @@ const int inter9 = 30;
|
|
|
const int inter10 = 31;
|
|
const int inter10 = 31;
|
|
|
const int inter11 = 32;
|
|
const int inter11 = 32;
|
|
|
|
|
|
|
|
|
|
+//Variable lumiere
|
|
|
|
|
+ int newDay = 1; // Variable pour savoir si nouveau jour.
|
|
|
|
|
+ int HAFlo; //heure allumage floraison en minute (9H45 ou 10H15)
|
|
|
|
|
+ int HEFlo; //heure extinction floraison en minute (HaFlo +12H +/-15min)
|
|
|
|
|
+ int HACro; //heure allumage croissance en minute (4H45 ou 5H15)
|
|
|
|
|
+ int HECro; //heure extinction croissance en minute (HaFlo +18H +/-15min)
|
|
|
|
|
+
|
|
|
OneWire oneWire(ONE_WIRE_BUS);
|
|
OneWire oneWire(ONE_WIRE_BUS);
|
|
|
DS18B20 sensor(&oneWire);
|
|
DS18B20 sensor(&oneWire);
|
|
|
DS3231 Clock;
|
|
DS3231 Clock;
|
|
@@ -69,6 +76,7 @@ void setup() {
|
|
|
Wire.begin();
|
|
Wire.begin();
|
|
|
sensor.begin();
|
|
sensor.begin();
|
|
|
sensor.setResolution(12);
|
|
sensor.setResolution(12);
|
|
|
|
|
+ delay(1000);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -79,15 +87,20 @@ void loop() {
|
|
|
* *********************************************************************
|
|
* *********************************************************************
|
|
|
*/
|
|
*/
|
|
|
//temperature
|
|
//temperature
|
|
|
|
|
+ Serial.println("salut1");
|
|
|
sensor.requestTemperatures();
|
|
sensor.requestTemperatures();
|
|
|
|
|
+ Serial.println("salut2");
|
|
|
while (!sensor.isConversionComplete());
|
|
while (!sensor.isConversionComplete());
|
|
|
|
|
+ Serial.println("salut3");
|
|
|
float temp = sensor.getTempC();
|
|
float temp = sensor.getTempC();
|
|
|
|
|
+ Serial.println(temp);
|
|
|
|
|
|
|
|
//heure
|
|
//heure
|
|
|
bool h24, am;
|
|
bool h24, am;
|
|
|
int heure = Clock.getHour(h24, am );
|
|
int heure = Clock.getHour(h24, am );
|
|
|
int minu = Clock.getMinute();
|
|
int minu = Clock.getMinute();
|
|
|
int HMin = heure * 60 + minu; // heure en minute
|
|
int HMin = heure * 60 + minu; // heure en minute
|
|
|
|
|
+ Serial.println(HMin);
|
|
|
|
|
|
|
|
//Hydrometrie
|
|
//Hydrometrie
|
|
|
|
|
|
|
@@ -95,18 +108,21 @@ void loop() {
|
|
|
Gestion de la lumiere
|
|
Gestion de la lumiere
|
|
|
* *********************************************************************
|
|
* *********************************************************************
|
|
|
*/
|
|
*/
|
|
|
- int newDay = 1; // Variable pour savoir si nouveau jour.
|
|
|
|
|
- int HAFlo; //heure allumage floraison en minute (9H45 ou 10H15)
|
|
|
|
|
- int HEFlo; //heure extinction floraison en minute (HaFlo +12H +/-15min)
|
|
|
|
|
- int HACro; //heure allumage croissance en minute (4H45 ou 5H15)
|
|
|
|
|
- int HECro; //heure extinction croissance en minute (HaFlo +18H +/-15min)
|
|
|
|
|
|
|
|
|
|
- if (newDay) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (newDay==1) {
|
|
|
newDay = 0;
|
|
newDay = 0;
|
|
|
|
|
+ Serial.println("newDay");
|
|
|
|
|
+ Serial.println(HMin);
|
|
|
HAFlo = random (585, 615);
|
|
HAFlo = random (585, 615);
|
|
|
|
|
+ Serial.println(HAFlo);
|
|
|
HEFlo = HAFlo + 705 + random(30);
|
|
HEFlo = HAFlo + 705 + random(30);
|
|
|
|
|
+ Serial.println(HEFlo);
|
|
|
HACro = random (285, 315);
|
|
HACro = random (285, 315);
|
|
|
|
|
+ Serial.println(HACro);
|
|
|
HECro = HACro + 1065 + random(30);
|
|
HECro = HACro + 1065 + random(30);
|
|
|
|
|
+ Serial.println(HECro);
|
|
|
|
|
+ Serial.println("fin newDay");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (HMin == 0)
|
|
if (HMin == 0)
|
|
@@ -115,13 +131,15 @@ void loop() {
|
|
|
if (HMin >= HAFlo & HMin < HEFlo) {
|
|
if (HMin >= HAFlo & HMin < HEFlo) {
|
|
|
digitalWrite(Rouge1Pin, LOW);
|
|
digitalWrite(Rouge1Pin, LOW);
|
|
|
digitalWrite(Rouge2Pin, LOW);
|
|
digitalWrite(Rouge2Pin, LOW);
|
|
|
|
|
+ Serial.println("Alum Flo");
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
digitalWrite(Rouge1Pin, HIGH);
|
|
digitalWrite(Rouge1Pin, HIGH);
|
|
|
digitalWrite(Rouge2Pin, HIGH);
|
|
digitalWrite(Rouge2Pin, HIGH);
|
|
|
|
|
+ Serial.println("Ext Flo");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (HMin >= HAFlo & HMin < HEFlo) {
|
|
|
|
|
|
|
+ if (HMin >= HACro & HMin < HECro) {
|
|
|
digitalWrite(Bleu1Pin, LOW);
|
|
digitalWrite(Bleu1Pin, LOW);
|
|
|
digitalWrite(Bleu2Pin, LOW);
|
|
digitalWrite(Bleu2Pin, LOW);
|
|
|
digitalWrite(Bleu3Pin, LOW);
|
|
digitalWrite(Bleu3Pin, LOW);
|
|
@@ -143,5 +161,5 @@ void loop() {
|
|
|
digitalWrite(ExtracteurPin, HIGH);
|
|
digitalWrite(ExtracteurPin, HIGH);
|
|
|
|
|
|
|
|
|
|
|
|
|
- delay(1000);
|
|
|
|
|
|
|
+ delay(10000);
|
|
|
}
|
|
}
|