WOW !! MUCH LOVE ! SO WORLD PEACE !
Fond bitcoin pour l'amélioration du site: 1memzGeKS7CB3ECNkzSn2qHwxU6NZoJ8o
  Dogecoin (tips/pourboires): DCLoo9Dd4qECqpMLurdgGnaoqbftj16Nvp


Home | Publier un mémoire | Une page au hasard

 > 

Realisation d'un systeme domotique commande par voix humaine via wifi « cas d'une maison d'habitation dans la ville de Goma »


par Guillaume CHERUBIN NDAKALA
ISIG- GOMA - Licence 2019
  

précédent sommaire suivant

Extinction Rebellion

ANNEXE

Nous avons codé notre système dans le langage Arduino et voici le code global e notre projet

- Code pour Arduino du projet complet

#include <SPI.h>

#include <WiFi.h>

//Declaration variables en les reliqnt aux differentesbroches{

constintexterieur = 2; //broche 2 du micro-contrôleur se nomme

constint porte = 3; //broche 3 du micro-contrôleur se nomme

constint salon = 4; //broche 4 du micro-contrôleur se nomme

constintmachambre = 5; //broche 5 du micro-contrôleur se nomme

constint visiteur = 6; //broche 6 du micro-contrôleur se nomme

constint alarme = 7; //broche 7 du micro-contrôleur se nomme

constint musique = 8; //broche 8 du micro-contrôleur se nomme

constintventillateur = 9; //broche 9 du micro-contrôleur se nomme

constint enfant = 10; //broche 10 du micro-contrôleur se nomme

constint bureau = 11; //broche 10 du micro-contrôleur se nomme

constintsejour = 12; //broche 11 du micro-contrôleur se nomme

//Fin declaration variable}

charssid[] = "housenet"; // your network SSID (name)

char pass[] = "0507"; // your network password

int status = WL_IDLE_STATUS; // the Wifi radio's status

voidsetup() {

// Definition des etat broche

pinMode(exterieur, OUTPUT);

pinMode(porte, OUTPUT);

pinMode(salon, OUTPUT);

pinMode(machambre, OUTPUT);

pinMode(visiteur, OUTPUT);

pinMode(alarme, OUTPUT);

pinMode(musique, OUTPUT);

pinMode(ventillateur, OUTPUT);

pinMode(enfant, OUTPUT);

pinMode(bureau, OUTPUT);

pinMode(sejour, OUTPUT);

// Fin definitionetat broche

//Initialize serial and wait for port to open:

Serial.begin(9600);

while (!Serial) {

; // wait for serial port to connect. Needed for native USB port only

}

// check for the presence of the shield:

if (WiFi.status() == WL_NO_SHIELD) {

Serial.println("WiFi shield not present");

// don't continue:

while (true);

}

}

// attempt to connect to Wifi network:

while (status != WL_CONNECTED) {

Serial.print("Attempting to connect to WPA SSID: ");

Serial.println(ssid);

// Connect to WPA/WPA2 network:

status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection:

delay(10000);

}

server.begin

// you're connected now, so print out the data:

// Serial.print("You're connected to the network");

// printCurrentNet();

// printWifiData();

}

void loop() {

WiFi client = server.available(); // listen for incoming clients

if (client) {

String currentLine = "";

while (client.connected()){

if (client.available()){

char c = client.read();

if (c == '\n') {

if(currentLine.length() ==0) {

client.println("HTTP/1.1 200 OK");

client.println("Content-type:text/html");

client.println();

client.println("Value at A0 is");

client.println(analogRead(A0));

client<print("<br>");

client.println();

break;

}

else {

currentLine = "";

}

}

else if (c != '\r'){

currentLine += c;

}

if (currentLine.endsWith ("GET /exterieuron")) {

digitalWrite(exterieur, HIGH);

}

if (currentLine.endsWith ("GET /exterieuroff")) {

digitalWrite(exterieur, LOW);

}

if (currentLine.endsWith ("GET /porteon")) {

digitalWrite(porte, HIGH);

delay(1000)

digitalWrite(porte, LOW);

}

if (currentLine.endsWith ("GET /porteoff")) {

digitalWrite(porte, HIGH);

delay(1000)

digitalWrite(porte, LOW);

}

if (currentLine.endsWith ("GET /salonon")) {

digitalWrite(salon, HIGH);

}

if (currentLine.endsWith ("GET /salonoff")) {

digitalWrite(salon, LOW);

}

if (currentLine.endsWith ("GET /machambreon")) {

digitalWrite(machambre, HIGH);

}

if (currentLine.endsWith ("GET /machambreoff")) {

digitalWrite(machambre, LOW);

}

if (currentLine.endsWith ("GET /visiteuron")) {

digitalWrite(visiteur, HIGH);

}

if (currentLine.endsWith ("GET /visiteuroff")) {

digitalWrite(visiteur, LOW);

}

if (currentLine.endsWith ("GET /enfanton")) {

digitalWrite(enfant, HIGH);

}

if (currentLine.endsWith ("GET /enfantoff")) {

digitalWrite(enfant, LOW);

}

if (currentLine.endsWith ("GET /alarmeon")) {

digitalWrite(alarme, HIGH);

}

if (currentLine.endsWith ("GET /alarmeoff")) {

digitalWrite(alarme, LOW);

}

if (currentLine.endsWith ("GET /musiqueon")) {

digitalWrite(musique, HIGH);

}

if (currentLine.endsWith ("GET /musiqueoff")) {

digitalWrite(musique, LOW);

}

if (currentLine.endsWith ("GET /ventillateuron")) {

digitalWrite(ventillateur, HIGH);

}

if (currentLine.endsWith ("GET /ventillateuroff")) {

digitalWrite(ventillateur, LOW);

}

if (currentLine.endsWith ("GET /bureauon")) {

digitalWrite(bureau, HIGH);

}

if (currentLine.endsWith ("GET /bureauoff")) {

digitalWrite(bureau, LOW);

}

if (currentLine.endsWith ("GET /sejouron")) {

digitalWrite(sejour, HIGH);

}

if (currentLine.endsWith ("GET /sejouroff")) {

digitalWrite(sejour, LOW);

}

if (currentLine.endsWith ("GET /touton")) {

digitalWrite(sejour, HIGH);

digitalWrite(exterieur, HIGH);

digitalWrite(salon, HIGH);

digitalWrite(enfant, HIGH);

digitalWrite(bureau, HIGH);

digitalWrite(machambre, HIGH);

}

if (currentLine.endsWith ("GET /toutoff")) {

digitalWrite(sejour, LOW);

digitalWrite(exterieur, LOW);

digitalWrite(salon, LOW);

digitalWrite(enfant, LOW);

digitalWrite(bureau, LOW);

digitalWrite(machambre, LOW);

}

}

}

client.stop();

}

}

voidprintWifiData() {

// print your WiFi shield's IP address:

IPAddressip = WiFi.localIP();

Serial.print("IP Address: ");

Serial.println(ip);

Serial.println(ip); }

précédent sommaire suivant






Extinction Rebellion





Changeons ce systeme injuste, Soyez votre propre syndic





"Il existe une chose plus puissante que toutes les armées du monde, c'est une idée dont l'heure est venue"   Victor Hugo