Outils pour utilisateurs

Outils du site


wiki:projets:lampeintelligente

Ceci est une ancienne révision du document !


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'éclaire varie en fonction de la luminosité de la pièce mais aussi de en fonction de l'heure. Si on se situe à un l'intervalle entre 8 heures et 16 heures la lampe émettra une lumière blanche. Dans le cas où on se situe à un intervalle entre 17 heures et minuit 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é :

{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 ((photocellReading > 0) && (photocellReading < 690 )) 
    Serial.println(" - Noir total");                                                  ** Si la luminosité est comprise entre 0 et 690 -> afficher noir total**
    
   else if ((photocellReading > 690) && (photocellReading < 890 )) 
    Serial.println(" - Sombre");
  
    
   else if ((photocellReading > 890) && (photocellReading < 1000 )) 
    Serial.println(" - Lumineux");

   
  delay(3000); }
    
 

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();
      int month = time_string.substring(4, 6).toInt();        
      int year = time_string.substring(6, 10).toInt();
      int hour = time_string.substring(10, 12).toInt();
      int minute = time_string.substring(12, 14).toInt();
      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 < 450 )) {          ** Si luminosité telle que x>300 et x<450 -> environnement noir total **
  Serial.println(" - Noir total");
  } 
 else if ((photocellReading > 450) && (photocellReading < 700 )) {      ** Si luminosité telle que x>300 et x<450 -> environnement sombre **
  Serial.println(" - Sombre");
}
  
 else if ((photocellReading > 700) && (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 if 1) { {

   digitalWrite(L2, HIGH); //allumer lampe jaune
   digitalWrite(L1, LOW);             ** Si luminosité telle que x>300 et x<700 et qu'il est entre 20 et 23h59 -> allumer lumière jaune **
 }
 }  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, LOW); 
   digitalWrite(L2, HIGH); // allumer lampe blanche      ** Si luminosité telle que x>300 et x<700 et qu'il est entre 14 et 19h59 -> allumer lumière jaune **
  }
   else
  {
   //
   digitalWrite (L1, LOW); 
   digitalWrite(L2, LOW);   ** Si aucune des ces conditions, éteindre les lumières **

}}

Journal de bord

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

21/11/18

Aujourd'hui nous avons fabriquer les première pièce de la structure structure extérieur 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 :

1)
photocellReading > 300) && (photocellReading < 700 ) && (now.hour() == 20) || (now.hour() == 21) || (now.hour() == 22) || (now.hour() == 23
LDAP: couldn't connect to LDAP server
wiki/projets/lampeintelligente.1544049999.txt.gz · Dernière modification: 2018/12/05 22:46 de yanndaniel