ARDUINO: Supervision Centrale électrique d’un Aéroport

Supervision Centrale électrique d’un Aéroport

Cet exemple montre l’exemple d’un système de supervision d’une centrale d’un aéroport. Le projet consiste à mettre en place un serveur web afin de visualiser en temps réel la température dans une centrale d’un aéroport. Si la température ou le gaz dépasse la limite une alerte s’affiche sur notre pas web et allume la led rouge sinon une led verte est allumée. La communication peut être établie via Wifi ou via Ethernet. La température est affichée en permanence sur un LCD.
Matériel requis
      ·      Carte Arduino Yun
      ·      Capteur de température LM35
      ·      Capteur Gaz
      ·      Leds
      ·      LCD
      ·      Fils de raccordement
Simulation


Routage
Code
/ *
      DIY Electronics par Bessem BELGHITH 
      Supervision centrale d'un aéroport 
 
* / 

//adresse 192.168.0.224/arduino/test
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
#include <Process.h>
#include <LiquidCrystal.h>

// Listen on default port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
YunServer server;

// declaration des pins
//pins led
int ledvert=8;
int ledrouge=9;
// PINS LCD
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
int val;
const int tempPin = A1;
//float analogInPin = A5;
int sensorValue = 0;        // value read from the sensor
int cel;
String msg1,msg2;
//constantes
char c;
int b=0;

int GASdigital=10;
void setup() {
 lcd.clear();
   // Affichage Message d'entrée " projet SUPERVISION CENTRALE"
  lcd.clear();
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("PROJET CONTROL   ");
  lcd.setCursor(0,1);
  lcd.print("   CENTRALE   ");
  delay(2500);
  lcd.clear();
  
  Serial.begin(9600);

  // Bridge startup
  pinMode(13,OUTPUT);
 digitalWrite(13, LOW);
  Bridge.begin();
  digitalWrite(13, HIGH);

  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
 // server.listenOnLocalhost();
  server.begin();
 
 pinMode(tempPin,INPUT);
  pinMode(GASdigital,INPUT);
// pinMode(analogInPin,INPUT);
 pinMode(ledvert,OUTPUT);
  pinMode(ledrouge,OUTPUT);
 pinMode(A0, OUTPUT);
  pinMode(A2, OUTPUT);
  digitalWrite(A0, HIGH);
  digitalWrite(A2, LOW);
  digitalWrite(ledrouge, LOW);  
    digitalWrite(ledvert, LOW);
   // analogReference(DEFAULT);
}

void loop() {

val = analogRead(tempPin);
float mv = ( val/1024.0)*5000;
float cel = mv/10;
delay(500);
 if (cel > 21)
    {
   digitalWrite(ledvert, LOW);   // sets the LED on
   digitalWrite(ledrouge, HIGH);   // sets the LED on
    msg1="ALERTE CHAUFFAGE CENTRALE";
  
   }
   else{
     digitalWrite(ledvert, HIGH);   // sets the LED on
   digitalWrite(ledrouge, LOW);   // sets the LED on
   msg1="";
     }
// Affichage Message
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TEMPERATURE = ");
lcd.setCursor(3,1);
lcd.print(cel);
lcd.print("*C");
//lcd.setCursor(0,1);
//lcd.print("GAZ = ");
//lcd.print(sensorValue);

//sensorValue = analogRead(analogInPin);


  // Get clients coming from server
  YunClient client = server.accept();

  // There is a new client?
  if (client) {
    // Process request
  
  /////////////////////////////////////////////////////////////////
          // Enable HTML
          client.println("TEST PAGE HTML ");
          client.println("BY BESSEM BELGHITH");
          client.println();

           //Show UI
           client.println("<HTML>");
           client.println("<HEAD>");
           client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
           client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
           client.println("<link rel='stylesheet' type='text/css' href='http://randomnerdtutorials.com/ethernetcss.css' />");
           client.println("<TITLE>Projet Supervision Centrale Aeroport de Monastir </TITLE>");
           client.println("</HEAD>");
           client.println("<BODY>");
           client.println("<H1>PROJET SUPERVISION CENTRALE AEROPORT MONASTIR</H1>");
           client.println("<hr />");
           client.println("<br />"); 
           client.print("<H2>TEMPERATURE EN °C:  <H2>");
           client.print(cel);
           client.print("<br>");
            client.println("<br />"); 
           client.print(msg1);
            client.print("<br>");
            client.println("<br />"); 
           client.print(msg2);
         
           client.print("<br>");
           client.println("<br />");
           client.println("<p>Réalisé par Bessem BELGHITH</p>"); 
           client.println("<br />");
           client.println("</BODY>");
           client.println("</HTML>");
           client.print("<head>");
           client.print("<meta http-equiv=\"refresh\" content=\"1\">");
           client.print("</head>");
  
    int value = client.parseInt();
    Serial.println(value); 
   

    // Close connection and free resources.
    client.stop();
  }
  delay(50); // Poll every 50ms
if (digitalRead(GASdigital) == HIGH)
{
  msg2="ALERTE GAZ DANS LA CENTRALE";
}
 else{
   msg2="";
 }
}