
Le code que j'ai mis sur l'arduino, je ne vois pas ou cela pose un souci?
Code : Tout sélectionner
#include <Wire.h>
#include <SPI.h>
#include <LiquidCrystal.h>
#include <RTClib.h>
#include <DallasTemperature.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define MY_DEBUG
#define MY_RS485
#define MY_RS485_DE_PIN -1
#define MY_RS485_HWSERIAL Serial1
#define MY_GATEWAY_SERIAL // serial gateway
#define MY_RS485_BAUD_RATE 115200
#include <MySensors.h>// /!\ Pas trouvé comment "concatener" ou pas les sensors, l'ordre y est pour Qch, mais la logique?????
#define CHILD_ID_SWITCH_1 15
#define CHILD_ID_HUM_1 1
#define CHILD_ID_TEMP_1 2
#define CHILD_ID_HUM_2 3
#define CHILD_ID_TEMP_2 4
#define CHILD_ID_TEMP_3 10
#define CHILD_ID_TEMP_4 11
#define CHILD_ID_TEMP_5 12
#define CHILD_ID_TEMP_6 13
#define CHILD_ID_TEMP_7 14
#define CHILD_ID_MOIST_1 5
#define CHILD_ID_MOIST_2 6
#define CHILD_ID_MOIST_3 7
#define CHILD_ID_MOIST_4 8
#define CHILD_ID_MOIST_5 9
MyMessage msgTemp3(CHILD_ID_TEMP_3, V_TEMP);
MyMessage msgTemp4(CHILD_ID_TEMP_4, V_TEMP);
MyMessage msgTemp5(CHILD_ID_TEMP_5, V_TEMP);
MyMessage msgTemp6(CHILD_ID_TEMP_6, V_TEMP);
MyMessage msgTemp7(CHILD_ID_TEMP_7, V_TEMP);
MyMessage msgMoist1(CHILD_ID_MOIST_1, V_LEVEL);
MyMessage msgMoist2(CHILD_ID_MOIST_2, V_LEVEL);
MyMessage msgMoist3(CHILD_ID_MOIST_3, V_LEVEL);
MyMessage msgMoist4(CHILD_ID_MOIST_4, V_LEVEL);
MyMessage msgMoist5(CHILD_ID_MOIST_5, V_LEVEL);
MyMessage msgsw1(CHILD_ID_SWITCH_1, V_STATUS);
MyMessage msgHum1(CHILD_ID_HUM_1, V_HUM);
MyMessage msgTemp1(CHILD_ID_TEMP_1, V_TEMP);
MyMessage msgHum2(CHILD_ID_HUM_2, V_HUM);
MyMessage msgTemp2(CHILD_ID_TEMP_2, V_TEMP);
#define DHTIN_PIN 28
#define DHTIN_TYPE DHT22
#define DHTEXT_PIN 29
#define DHTEXT_TYPE DHT22
DHT DHT_IN(DHTIN_PIN, DHTIN_TYPE);
DHT DHT_EXT(DHTEXT_PIN, DHTEXT_TYPE);
RTC_DS1307 rtc;
const int rs = 23, en = 22, d4 = 25, d5 = 24, d6 = 27, d7 = 26; //LCD Pin
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int Photosensor_Pin = A5;
int Photosensor = 0;
int Seuil = 200;
boolean Jour = false;
int Active_Pin = 30;
int Disp_Val = 1 ;
int H_Pot1_Pin = A0;
int H_Pot2_Pin = A1;
int H_Pot3_Pin = A2;
int H_Pot4_Pin = A3;
int H_Pot5_Pin = A4;
int H_Pot_Pin[5]={ H_Pot1_Pin, H_Pot2_Pin, H_Pot3_Pin, H_Pot4_Pin, H_Pot5_Pin };
int H_Pot1;
int H_Pot2;
int H_Pot3;
int H_Pot4;
int H_Pot5;
int H_Pot[5]={ H_Pot1, H_Pot2, H_Pot3, H_Pot4, H_Pot5 };
int Pot_H_1;
int Pot_H_2;
int Pot_H_3;
int Pot_H_4;
int Pot_H_5;
int Pot_H_[5]={ Pot_H_1, Pot_H_2, Pot_H_3, Pot_H_4, Pot_H_5 };
#define ONE_WIRE_BUS 31 //Pin Sondes
#define TEMPERATURE_PRECISION 10
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
//Adresse Sonde Température DS18S20//
DeviceAddress Sonde_0 = {0x28, 0x39, 0x59, 0x2D, 0x63, 0x20, 0x01, 0x30};
DeviceAddress Sonde_1 = {0x28, 0xAD, 0x2C, 0x31, 0x63, 0x20, 0x01, 0xC8};
DeviceAddress Sonde_2 = {0x28, 0x78, 0x54, 0x5C, 0x62, 0x20, 0x01, 0x12};
DeviceAddress Sonde_3 = {0x28, 0x8C, 0x35, 0x1E, 0x63, 0x20, 0x01, 0x2C};
DeviceAddress Sonde_4 = {0x28, 0xDA, 0x50, 0x25, 0x63, 0x20, 0x01, 0xAF};
DeviceAddress Sonde_5 = {0x28, 0x1E, 0x19, 0x1D, 0x63, 0x20, 0x01, 0xA2};
DeviceAddress Sonde_6 = {0x28, 0x26, 0x8F, 0x2C, 0x62, 0x20, 0x01, 0xA9};
DeviceAddress Sonde_7 = {0x28, 0xF4, 0x61, 0x2B, 0x63, 0x20, 0x01, 0x56};
DeviceAddress Sonde_8 = {0x28, 0x1F, 0x19, 0x3F, 0x63, 0x20, 0x01, 0xE2};
DeviceAddress Sonde_9 = {0x28, 0x1E, 0x26, 0x32, 0x62, 0x20, 0x01, 0x08};
int Sonde_Pot[5]={ Sonde_0, Sonde_1, Sonde_2, Sonde_3, Sonde_4 };
//Test Charactére Spécial Horloge//
byte Pot_Char[8] = {//Pot avec Pousse
B00010,
B01100,
B00100,
B10101,
B11111,
B11111,
B11101,
B01110,
};
void presentation() /* -----void MySensors----*/
{
/* Envoi inf de version d'esquisse à la passerelle */
sendSketchInfo("Ardui_Seed", "1.1");
/* Enregistrez tous les capteurs sur gw */
/*(ils seront créés en tant qu'appareils enfants)*/
present(CHILD_ID_TEMP_3, S_TEMP,"Pot_1");
present(CHILD_ID_TEMP_4, S_TEMP,"Pot_2");
present(CHILD_ID_TEMP_5, S_TEMP,"Pot_3");
present(CHILD_ID_TEMP_6, S_TEMP,"Pot_4");
present(CHILD_ID_TEMP_7, S_TEMP,"Pot_5");
present(CHILD_ID_MOIST_1, S_MOISTURE,"Pot_1H");
present(CHILD_ID_MOIST_2, S_MOISTURE,"Pot_2H");
present(CHILD_ID_MOIST_3, S_MOISTURE,"Pot_3H");
present(CHILD_ID_MOIST_4, S_MOISTURE,"Pot_4H");
present(CHILD_ID_MOIST_5, S_MOISTURE,"Pot_5H");
present(CHILD_ID_SWITCH_1, S_BINARY,"Jour/Nuit");
present(CHILD_ID_TEMP_1, S_TEMP,"DHT_EXT");
present(CHILD_ID_HUM_1, S_HUM ,"DHT_EXT");
present(CHILD_ID_TEMP_2, S_TEMP,"DHT_IN");
present(CHILD_ID_HUM_2, S_HUM,"DHT_IN");
// metric = getControllerConfig().isMetric;
}
void setup() {
analogReference(DEFAULT);
Wire.begin();
Serial1.begin(115200);
Serial.begin(115200);
for ( int h = 0 ; h <= 4 ; h++) pinMode(H_Pot_Pin[h], INPUT);
pinMode(Photosensor_Pin, INPUT);
pinMode(Active_Pin, OUTPUT);
lcd.createChar(0, Pot_Char);
lcd.begin(20, 4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Ardui_Seed Test");
lcd.setCursor(6,1);
lcd.print("Beta_1.0");
DHT_IN.begin();
DHT_EXT.begin();
sensors.begin();
delay(2000);
lcd.clear();
}
void loop() {
DateTime now=rtc.now(); //Récupère l'heure et le date courante
sensors.requestTemperatures();
lcd.setCursor(0,0);
char buf2[] = "hh:mm DD/MM/YY";
lcd.print(now.toString(buf2));
lcd.setCursor(0,1);
lcd.print("IN:");
lcd.setCursor(3,1);
lcd.print(DHT_IN.readTemperature(),0)+lcd.write((char)223);
lcd.setCursor(6,1);
lcd.print(DHT_IN.readHumidity(),0)+lcd.write((char)37);
lcd.setCursor(9,1);
lcd.write((char)208);
lcd.setCursor(10,1);
lcd.print("OUT:");
lcd.setCursor(14,1);
lcd.print(DHT_EXT.readTemperature(),0)+lcd.write((char)223);
lcd.setCursor(17,1);
lcd.print(DHT_EXT.readHumidity(),0)+lcd.write((char)37);
for(int a = 1 , x = 2 ; a < 20 , x < 20 ; a=a+4 , x=x+4){
lcd.setCursor(a,2);
lcd.write(byte(0));
lcd.setCursor(x,2);
lcd.print(a/4+1);
}
lcd.setCursor(0,3);
lcd.print(" ");
digitalWrite(Active_Pin, HIGH);
for (int b = 0 ; b <= 4 ; b++){
H_Pot[b]= map (analogRead(H_Pot_Pin[b]),400,1023,100,0);
H_Pot[b] = constrain(H_Pot[b], 0, 100);
}
for( int y = 1, s = 0 ; y < 20, s <=4 ; y=y+4, s++ ){
lcd.setCursor(y,3);
if (Disp_Val == 1 ){
lcd.print(sensors.getTempC(Sonde_Pot[s]),0)+lcd.write((char)223);
if (y == 17)Disp_Val ++;
}else{
lcd.print(H_Pot[s])+lcd.write((char)37);
if (y == 17)Disp_Val --;
}
}
Photosensor = analogRead(Photosensor_Pin);
if (Photosensor >= Seuil)Jour = true;
else Jour = false;
float dht_temp_1 = DHT_EXT.readTemperature();
float dht_hum_1 = DHT_EXT.readHumidity();
float dht_temp_2 = DHT_IN.readTemperature();
float dht_hum_2 = DHT_IN.readHumidity();
for(int s = 0; s <=4 ;s++){
Pot_H_[s] = map(analogRead(H_Pot_Pin[s]),200,1023,0,100);
Pot_H_[s] = constrain(Pot_H_[s], 0, 100);
}
send(msgTemp1.set(dht_temp_1, 1));
send(msgHum1.set(dht_hum_1, 1));
send(msgTemp2.set(dht_temp_2, 1));
send(msgHum2.set(dht_hum_2, 1));
send(msgTemp3.set(sensors.getTempC(Sonde_Pot[0]), 1));
send(msgTemp4.set(sensors.getTempC(Sonde_Pot[1]), 1));
send(msgTemp5.set(sensors.getTempC(Sonde_Pot[2]), 1));
send(msgTemp6.set(sensors.getTempC(Sonde_Pot[3]), 1));
send(msgTemp7.set(sensors.getTempC(Sonde_Pot[4]), 1));
send(msgMoist1.set(Pot_H_[0], 1));
send(msgMoist2.set(Pot_H_[1], 1));
send(msgMoist3.set(Pot_H_[2], 1));
send(msgMoist4.set(Pot_H_[3], 1));
send(msgMoist5.set(Pot_H_[4], 1));
send(msgsw1.set(Jour, 0));
//Serial.print(analogRead(H_Pot_Pin[0]));
//Serial.print(Pot_H_[1]);
//Serial.print("H_Pot");
delay(3000);
}
A+