Outils pour utilisateurs

Outils du site


wiki:projets:lampeintelligente

Porteur(s) du projet: Lampe intelligente
Biampinga Yann-Daniel (contact : yann_biampinga@hotmail.fr)

  • * Pauline BEALU (contact : pauline.bealu@gmail.com)
    Date de début : Septembre/2018-2019. ====== Description du projet ====== Le sujet du devoir était de concevoir un dispositif possédant un ou plusieurs capteurs à partir d'Arduino. Nous avons choisi comme dispositif une lampe de bureau intelligente dont l'éclairage varie en fonction de la luminosité de la pièce mais aussi en fonction de l'heure. Si on se situe à un l'intervalle entre 8 heures et 14 heures la lampe émettra une lumière blanche. Dans le cas où on se situe à un intervalle entre 14 heures et 23 heures la lampe émettra une lumière douce orangé. ====== Liste de Matériel ====== - une lampe en bois - normes électriques - LED - carte Arduino UNO - module RTC - capteur de luminosité - Câble Connexion Jack Mâle Ruban LED 12V ====== Codes pour le capteur de luminosité ====== (On a enlevé les accolades pour plus de lisibilité) Le code pour le capteur de luminosité : <code> {int photocellPin = 0; the cell and 10K pulldown are connected to a0 Ici l'information du capteur sera envoyé à la pin A0
    int photocellReading;
    the analog reading from the analog resistor
    Ici on devra lire l'information void setup(void) We'll send debugging information via the Serial monitor Serial.begin(9600); void loop(void) photocellReading = analogRead(photocellPin); Serial.print(“Analog reading = ”); Serial.print(photocellReading); the raw analog reading We'll have a few threshholds, qualitatively determined if 1) Serial.println(“ - Noir total”); affiche dans le terminal “noir total” Si la luminosité est comprise entre 0 et 690 → afficher noir total else if 2) Si la luminosité est compris entre 690 et 890 → afficher sombre Serial.println(“ - Sombre”); affiche dans le terminal “sombre” else if 3) Sinon → afficher lumineux Serial.println(“ - Lumineux”); affiche dans le terminal “lumineux” delay(3000); } </code> ====== Code pour le RTC ====== { #include <Wire.h> #include “RTClib.h” #define BUFFER_SIZE 20 #define VERSION “1.0” RTC object RTC_DS1307 RTC; Buffer for incoming data char serial_buffer[BUFFER_SIZE]; int buffer_position; void setup() Serial.begin(9600); Wire.begin(); RTC.begin(); buffer_position = 0; void loop() Wait for incoming data on serial port if (Serial.available() > 0) { Read the incoming character char incoming_char = Serial.read(); End of line? if(incoming_char == '\n') Parse the command ## if(serial_buffer[0] == '#' && serial_buffer[1] == '#') Serial.println(“!!”); ?V else if(serial_buffer[0] == '?' && serial_buffer[1] == 'V') Serial.println(VERSION); ?T else if(serial_buffer[0] == '?' && serial_buffer[1] == 'T') DateTime now = RTC.now(); char time_string[20]; sprintf(time_string, “%02d/%02d/%d %02d:%02d:%02d”, now.day(), now.month(), now.year(), now.hour(), now.minute(), now.second()); Serial.println(time_string); !T else if(serial_buffer[0] == '!' && serial_buffer[1] == 'T') String time_string = String(serial_buffer); int day = time_string.substring(2, 4).toInt(); initialisation du jour int month = time_string.substring(4, 6).toInt(); initialisation du mois int year = time_string.substring(6, 10).toInt(); initialisation du l'année int hour = time_string.substring(10, 12).toInt(); initialisation de l'heure int minute = time_string.substring(12, 14).toInt(); initialisation des minutes

int second = time_string.substring(14, 16).toInt();

      DateTime set_time = DateTime(year, month, day, hour, minute, second);
      RTC.adjust(set_time);
      Serial.println("OK");
    
    
    // Reset the buffer
    buffer_position = 0;
  
  
  // Carriage return, do nothing
  else if(incoming_char == '\r');
  
  // Normal character
  else 
    
    // Buffer full, we need to reset it
    if(buffer_position == BUFFER_SIZE - 1) buffer_position = 0;
    // Store the character in the buffer and move the index
    serial_buffer[buffer_position] = incoming_char;
    buffer_position++;      
  }

Code final

int photocellPin = 0; the cell and 10K pulldown are connected to a0 Envoyer les informations à la pin AO int photocellReading; the analog reading from the analog resistor divider Lire les informations

# include <Wire.h> Inclure le fichier Wire # include “RTClib.h” Inclure le fichier RTClib

# define BUFFER_SIZE 20 # define VERSION “1.0”

RTC object RTC_DS1307 RTC; Buffer for incoming data char serial_buffer[BUFFER_SIZE]; int buffer_position;

RTC_DS1307 rtc; const int L1 = 2; (blanche) Pin pour lumière blanche const int L2 = 8; (jaune) Pin pour lumière jaune

void setup() {

Serial.begin(9600);
Wire.begin();
rtc.begin();
pinMode(L1, OUTPUT); //L1 est une broche de sortie
pinMode(L2, OUTPUT);
  

}

void loop() {

photocellReading = analogRead(photocellPin);
Serial.print("Analog reading = ");
Serial.print(photocellReading); // the raw analog reading
// We'll have a few threshholds, qualitatively determined

if ((photocellReading > 300) && (photocellReading < 500 )) {          ** Si luminosité telle que x>300 et x<450 -> environnement noir total **
  Serial.println(" - Noir total");
  } 
 else if ((photocellReading > 500) && (photocellReading < 780 )) {      ** Si luminosité telle que x>300 et x<450 -> environnement sombre **
  Serial.println(" - Sombre");
}
  
 else if ((photocellReading > 780) && (photocellReading < 1000 )) {       ** Si luminosité telle que x>300 et x<450 -> environnement lumineux **
  Serial.println(" - Lumineux");
 }
delay(5000);       ** répéter avec un delay de 5000 **
 

{ DateTime now = rtc.now();

L1 : lumière blanche et L2 : lumière jaune if4) { {

   digitalWrite(L2, HIGH); //allumer lampe jaune
   digitalWrite(L1, LOW);   //éteindre lampe blanche          ** Si luminosité telle que x>300 et x<700 et qu'il est entre 20 et 23h59 -> allumer lumière jaune et éteindre lumière blanche **
 }
 }  else if ((photocellReading > 300) && (photocellReading < 700 ) && (now.hour() == 14) || (now.hour() == 15 )  || (now.hour() == 16)  || (now.hour() == 17) || (now.hour() == 18) || (now.hour() == 19))          
  {
    //
    digitalWrite(L1, HIGH); // allumer lumière blanche
   digitalWrite(L2, LOW); // éteindre lumière jaune     ** Si luminosité telle que x>300 et x<700 et qu'il est entre 14 et 19h59 -> allumer lumière blanche éteindre lumière jaune**
  }
   else
  {
   //
   digitalWrite (L1, LOW); //éteindre la lampe blanche 
   digitalWrite(L2, LOW);  //éteindre la lampe jaune                     ** Si aucune des ces conditions correspondent, éteindre les lumières blanche et jaune **

}}

Journal de bord

09/11/18 Aujourd'hui nous allons coder le module RTC afin de fixer l'heure de la lampe. Ainsi on va commencer le codage pour le capteur de luminosité.

21/11/18

Aujourd'hui nous avons fabriquer les premières pièces de la structure extérieure de la lampe:

. La première structure servira de support pour le tissu de led, il mesure 25 cm de longueur et 10 cm de largeur

. Le deuxième servira de pilier. Il serra l’intermédiaire entre le socle et le support de led, de plus il sera traversé de fil

22/11/18

Suite à l'assemblage à la colle, la structure extérieure de la lampe est enfin fini voici quelques images :

Voici l'assemblage de l'ensemble des pièces :

24/11/18:

On a rassemblé le code pour le RTC et le code pour le capteur de lumière voici un aperçut avec des petites leds :

Reste plus qu'a faire de même avec des grandes leds et le transistor.

27/11/18:

On a souder les leds jaunes mais elles ne s'allument pas avec notre programme principal et le rajout du transistor. Mais marche bizarrement avec des petites leds :

05/12/18 :

Aujourd'hui nous avons finalisé notre projet en améliorer les branchements sur la carte. Mais aussi en améliorant les branchement des grandes leds. Et puis en collant les leds sur la planche à leds horizontal.

Voici la finalisation de notre lampe (avec les leds blanche et jaune) vue de bas :

1)
photocellReading > 300) && (photocellReading < 500
2)
photocellReading > 500) && (photocellReading < 780
3)
photocellReading > 780) && (photocellReading < 1000
4)
photocellReading > 300) && (photocellReading < 700 ) && (now.hour() == 20) || (now.hour() == 21) || (now.hour() == 22) || (now.hour() == 23
wiki/projets/lampeintelligente.txt · Dernière modification: 2020/10/05 16:39 (modification externe)