EYE WIN
Projet
Revue de Projet
Année 2020-2021


Guillaume BENHAMOU
Hugo SEFRIOUI
Luis BUISSON
Entreprise IES
57 Avenue de Bretagne
76100 ROUEN
SOMMAIRE
1.Présentation de l'entreprise
2.Le projet EYEWIN
3.Developpement du projet
Présentation l'entreprise
IES

Contexte du Projet

Démarche du groupe


Présentation du Projet



Présentation du Projet


Présentation du Projet


Batterie

Diagrame des cas d'utilisation

Mise en place d'un point d'accès WIFI

Mise en place d'un point d'accès WIFI


Mise en place d'un point d'accès WIFI

// Load Wi-Fi library
#include <WiFi.h>
#include <WebServer.h>
#include "index.h" //Web page header file
//===============================================================
// Web server constants & variables
//===============================================================
/*SSID & Password */
const char* ssid = "EYE_WIN"; // Enter SSID here
const char* password = "12345678"; //Enter Password here
/*IP Address details */
IPAddress local_ip(192, 168, 4, 1);
IPAddress gateway(192, 168, 4, 1); // 192.168.4.1
IPAddress subnet(255, 255, 255, 0);
WebServer server(80);
//init page of the local server
void serv_Connection();
WiFi.softAP(ssid, password);
WiFi.softAPConfig(local_ip, gateway, subnet);
delay(100);
Développement de L'IHM

Z1
Z2
Z3
Z4
Z5
Z6
Z7

L3
L1
L2
L4
L5
L6
L7
L8
L9
L10
L11
Valeur
Temps
Valeur
Batterrie
Valeur
Luminosité
Z1
Z2
Z3
Z4
Z5
Z6
Z7
Random


L+
L-
Valeur
Temps
T-
T+
Valeur
Batterrie
Valeur
Luminosité
Z1
Z2
Z3
Z4
Z5
Z6
Z7
Random

L+
L-
Valeur
Temps
T-
T+
Valeur
Batterrie
Valeur
Luminosité
Z1
Z2
Z3
Z4
Z5
Z6
Z7
Random

Etude du materiel

?
Etude du materiel

Etude du materiel


Réglage de la luminosité des bandeaux de Leds

Fréquence :5kHz


Bloc driver + mosfet
// configure LED PWM functionalitites
for (size_t i = 0; i < 11; i++) {
ledcSetup(ledChannels[i], freq, resolution);
}
// attach the channel to the GPIO to be controlled
for (size_t i = 0; i < 11; i++) {
ledcAttachPin(leds[i], ledChannels[i]);
}
Réglage de la luminosité des bandeaux de Leds

// LED pin position
const unsigned short int leds[11] = {16, 17, 5,
18, 19, 14, 27, 26, 25, 33, 32};
// LED PWM channel
const int ledChannels[11] = {0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10};
// array of the zone
const int zone[7][3] = {
{0, 1, 15}, //Z1
{1, 2, 3}, //Z2
{3, 4, 15}, //Z3
{4, 5, 6}, //Z4
{6, 7, 15}, //Z5
{7, 8, 9}, //Z6
{9, 10, 15}, //Z7
};
// LED PWM channel
const int freq = 5000; //5KHz
const int resolution = 8; //8 bits <0-255>
int ratio = 125;
int Up_time = 4;
// LED pin position
const unsigned short int leds[11] = {16, 17, 5,
18, 19, 14, 27, 26, 25, 33, 32};
// LED PWM channel
const int ledChannels[11] = {0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10};
// array of the zone
const int zone[7][3] = {
{0, 1, 15}, //Z1
{1, 2, 3}, //Z2
{3, 4, 15}, //Z3
{4, 5, 6}, //Z4
{6, 7, 15}, //Z5
{7, 8, 9}, //Z6
{9, 10, 15}, //Z7
};
// LED PWM channel
const int freq = 5000; //5KHz
const int resolution = 8; //8 bits <0-255>
int ratio = 125;
int Up_time = 4;
// configure LED PWM functionalitites
for (size_t i = 0; i < 11; i++) {
ledcSetup(ledChannels[i], freq, resolution);
}
// attach the channel to the GPIO to be controlled
for (size_t i = 0; i < 11; i++) {
ledcAttachPin(leds[i], ledChannels[i]);
}
Réglage de la luminosité des bandeaux de Leds

Communication entre L'IHM et le code de L'ESP32

Allumage des Zones/
Paramétrage du système
Temps /Batterie / Luminosité
//===============================================================
// libraries and depandancies
//===============================================================
// Load Wi-Fi library
#include <WiFi.h>
#include <WebServer.h>
#include "index.h" //Web page header file
//===============================================================
// Init of the Timers
//===============================================================
// create a hardware timer
hw_timer_t * timer = NULL;
//===============================================================
// Web server constants & variables
//===============================================================
/*SSID & Password */
const char* ssid = "EYE_WIN"; // Enter SSID here
const char* password = "12345678"; //Enter Password here
/*IP Address details */
IPAddress local_ip(192, 168, 4, 1);
IPAddress gateway(192, 168, 4, 1); // 192.168.4.1
IPAddress subnet(255, 255, 255, 0);
WebServer server(80);
//init page of the local server
void serv_Connection();
//===============================================================
// Led pannel constants & variables
//===============================================================
// LED pin position
const unsigned short int leds[11] = {16, 17, 5, 18, 19, 14, 27, 26, 25, 33, 32};
const int zone[7][3] = {
{0, 1, 15}, //Z1
{1, 2, 3}, //Z2
{3, 4, 15}, //Z3
{4, 5, 6}, //Z4
{6, 7, 15}, //Z5
{7, 8, 9}, //Z6
{9, 10, 15}, //Z7 {9,10,15}
};
// LED PWM channel
const int ledChannels[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
// LED PWM channel
const int freq = 5000; //5KHz
const int resolution = 8; //8 bits <0-255>
int ratio = 125;
int Up_time = 4;
//===============================================================
// Timer interrupt
//===============================================================
volatile int ticTimer = 0;
void IRAM_ATTR onTimer() {
Serial.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
Serial.println("timer");
ticTimer++;
if (ticTimer == Up_time)
shutdown_leds();
Serial.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
}
void timerReset() {
ticTimer = 0;
}
//===============================================================
// Routines
//===============================================================
// connection au fichier html
void serv_Connection() {
Serial.println("serv_Connection");
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void enableALL() {
Serial.println("enableALL");
timerReset();
for (size_t i = 0; i < 10; i++) {
if (leds[0] != 15) {
ledcWrite(ledChannels[zone[0][i]], ratio);
}
}
}
void enableZ1() {
Serial.println("enableZ1");
timerReset();
for (size_t i = 0; i < 3; i++) {
if (zone[0][i] != 15) {
ledcWrite(ledChannels[zone[0][i]], ratio);
}
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void enableZ2() {
Serial.println("enableZ2");
timerReset();
for (size_t i = 0; i < 3; i++) {
if (zone[1][i] != 15) {
ledcWrite(ledChannels[zone[1][i]], ratio);
}
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void enableZ3() {
Serial.println("enableZ3");
timerReset();
for (size_t i = 0; i < 3; i++) {
if (zone[2][i] != 15) {
ledcWrite(ledChannels[zone[2][i]], ratio);
}
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void enableZ4() {
Serial.println("enableZ4");
timerReset();
for (size_t i = 0; i < 3; i++) {
if (zone[3][i] != 15) {
ledcWrite(ledChannels[zone[3][i]], ratio);
}
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void enableZ5() {
Serial.println("enableZ5");
timerReset();
for (size_t i = 0; i < 3; i++) {
if (zone[4][i] != 15) {
ledcWrite(ledChannels[zone[4][i]], ratio);
}
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void enableZ6() {
Serial.println("enableZ6");
timerReset();
for (size_t i = 0; i < 3; i++) {
if (zone[5][i] != 15) {
ledcWrite(ledChannels[zone[5][i]], ratio);
}
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void enableZ7() {
Serial.println("enableZ7");
timerReset();
for (size_t i = 0; i < 3; i++) {
if (zone[6][i] != 15) {
ledcWrite(ledChannels[zone[6][i]], ratio);
}
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void serv_RandBtn() {
Serial.println("enableRandom");
timerReset();
int randomValue = random(6);
for (size_t i = 0; i < 3; i++) {
if (zone[randomValue][i] != 15) {
ledcWrite(ledChannels[zone[randomValue][i]], ratio);
}
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void shutdown_leds() {
Serial.println("shutdown_leds");
timerReset();
for (size_t y = 0; y < 6; y++) {
for (size_t i = 0; i < 3; i++) {
if (zone[6][i] != 15) {
ledcWrite(ledChannels[zone[y][i]], 0);
}
}
}
}
//===============================================================
// Luminosity management
//===============================================================
void serv_UpBtn_Lum() {
Serial.println("serv_UpBtn");
if (ratio < 250) {
ratio += 25;
}
else {
ratio = 250;
}
Serial.println("DutyCycle = ");
Serial.println(ratio);
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void serv_DownBtn_Lum() {
Serial.println("serv_DownBtn");
if (ratio > 0) {
ratio -= 25;
}
else {
ratio = 0;
}
Serial.println("Ratio = ");
Serial.println(ratio);
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
String getLum(){
Serial.println("getLum");
int ratioPercent =(ratio/250.00)*100;
server.send(200, "text/plane", String(ratioPercent)); //Send web page
return (String(ratioPercent));
}
//===============================================================
// On/Off Tempo management
//===============================================================
void serv_UpBtn_Temp() {
Serial.println("serv_UpBtn_Temp");
Serial.println(Up_time);
if (Up_time >= 20) {
Up_time = 20;
} else {
Up_time++ ;
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
void serv_DownBtn_Temp() {
Serial.println("serv_DownBtn_Temp");
Serial.println(Up_time);
if (Up_time <= 1) {
Up_time = 1;
} else {
Up_time--;
}
String s = MAIN_page; //Read HTML contents
server.send(200, "text/html", s); //Send web page
}
String getTemps() {
Serial.println("getTemps");
server.send(200, "text/plane", String(Up_time)); //Send web page
return (String(Up_time));
}
//===============================================================
// Entry Tension management
//===============================================================
int getTensionValue() {
return (analogRead(A0));
}
void setLedState() {
Serial.println("setLedState");
pinMode(2, OUTPUT);
if (getTensionValue() <= 1856)
{
digitalWrite(2, 1);
}
else {
digitalWrite(2, 0);
}
}
String getTesionPercent() {
Serial.println("getTesionPercent");
long resultatTension = (100.00 - (((1960.00 - getTensionValue()) / 103.00) * 100.00)); //100-[(Diff act - DIff max)*100]
server.send(200, "text/plane", String(resultatTension)); //Send web page
return (String(resultatTension));
}
//===============================================================
// Box'LED
//===============================================================
const int caseLed = 23;
//===============================================================
// Setup
//===============================================================
void setup(void) {
//configure the type of the case's led
pinMode(caseLed,OUTPUT);
digitalWrite(caseLed, HIGH);
// configure LED PWM functionalitites
for (size_t i = 0; i < 11; i++) {
ledcSetup(ledChannels[i], freq, resolution);
}
// attach the channel to the GPIO to be controlled
for (size_t i = 0; i < 11; i++) {
ledcAttachPin(leds[i], ledChannels[i]);
}
// liaison serie
Serial.begin(115200);
Serial.println("===========");
WiFi.softAP(ssid, password);
WiFi.softAPConfig(local_ip, gateway, subnet);
delay(100);
// setup the get request
server.on("/", serv_Connection);
server.on("/z1_on", enableZ1);
server.on("/z2_on", enableZ2);
server.on("/z3_on", enableZ3);
server.on("/z4_on", enableZ4);
server.on("/z5_on", enableZ5);
server.on("/z6_on", enableZ6);
server.on("/z7_on", enableZ7);
server.on("/dw_btn", serv_DownBtn_Lum);
server.on("/up_btn", serv_UpBtn_Lum);
server.on("/rand_btn", serv_RandBtn);
server.on("/temp_+", serv_UpBtn_Temp);
server.on("/temp_-", serv_DownBtn_Temp);
server.on("/battVal", getTesionPercent);
server.on("/tempsVal", getTemps);
server.on("/lumVal", getLum);
server.begin();
Serial.println("EYE WINNER server started");
// timer setup
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 1000000, true);
timerAlarmEnable(timer);
Serial.println("Timer is setup");
}
//===============================================================
// This routine is executed when you open his IP in browser
//===============================================================
void loop(void) {
Serial.print("Valeur du CAN: ");
Serial.println(getTensionValue());
enableALL();
server.handleClient();
delay(100);
}
//===============================================================
Allumage des Zones/Paramétrage du système
Requêtes GET:


Url / paramètre
ex :192.168.4.1/up_btn

192.168.4.1/z1_on

server.on("/", serv_Connection);
server.on("/z1_on", enableZ1);
server.on("/z2_on", enableZ2);
server.on("/z3_on", enableZ3);
server.on("/z4_on", enableZ4);
server.on("/z5_on", enableZ5);
server.on("/z6_on", enableZ6);
server.on("/z7_on", enableZ7);
server.on("/dw_btn", serv_DownBtn_Lum);
server.on("/up_btn", serv_UpBtn_Lum);
server.on("/rand_btn", serv_RandBtn);
server.on("/temp_+", serv_UpBtn_Temp);
server.on("/temp_-", serv_DownBtn_Temp);
server.on("/battVal", getTesionPercent);
server.on("/tempsVal", getTemps);
server.on("/lumVal", getLum);
server.begin();
Allumage des Zones/Paramétrage du système

void enableZ1() {
Serial.println("enableZ1");
timerReset();
for (size_t i = 0; i < 3; i++) {
if (zone[0][i] != 15) {
ledcWrite(ledChannels[zone[0][i]], ratio);
}
}
Allumage des Zones/Paramétrage du système
Affichage des valeurs: Temps/Batterie /Luminosité
String sendTemps() {
Serial.println("sendTemps");
server.send(200, "text/plane", String(Up_time)); //Send web page
return (String(Up_time));
}
String sendTesionPercent() {
Serial.println("getTesionPercent");
//100-[(Diff act - DIff max)*100]
long resultatTension = (100.00 - (((1960.00 - getTensionValue()) / 103.00) * 100.00));
server.send(200, "text/plane", String(resultatTension)); //Send web page
return (String(resultatTension));
}
String sendLum(){
Serial.println("sendLum");
int ratioPercent =(ratio/250.00)*100;
server.send(200, "text/plane", String(ratioPercent)); //Send web page
return (String(ratioPercent));
}



Affichage Temps/Batterie /Luminosité
<script>
setInterval(function(){getData();}, 1000);
function getData(){
//++++++++++++++++++
// Battery
//++++++++++++++++++
var xhttpBatt=new XMLHttpRequest();
xhttpBatt.onreadystatechange = function(){
if(this.readyState==4 && this.status == 200)
{
document.getElementById("dataBatt").innerHTML=this.responseText;
}
};
xhttpBatt.open("get", "battVal", true);
xhttpBatt.send();
//++++++++++++++++++
// Luminosity
//++++++++++++++++++
var xhttplum=new XMLHttpRequest();
xhttplum.onreadystatechange = function(){
if(this.readyState==4 && this.status == 200)
{
document.getElementById("dataLum").innerHTML=this.responseText;
}
};
xhttplum.open("get", "lumVal", true);
xhttplum.send();
//++++++++++++++++++
// Timer
//++++++++++++++++++
var xhttptemps=new XMLHttpRequest();
xhttptemps.onreadystatechange = function(){
if(this.readyState==4 && this.status == 200)
{
document.getElementById("dataTemps").innerHTML=this.responseText;
}
};
xhttptemps.open("get", "tempsVal", true);
xhttptemps.send();
};
</script>

Affichage de valeurs: Batterie/ Temps /Luminosité
utilisation de requêtes html et de XML

Récupération des Valeurs
Batterie/ Temps /Luminosité

String sendTemps() {
Serial.println("sendTemps");
server.send(200, "text/plane", String(Up_time)); //Send web page
return (String(Up_time));
}
String sendTesionPercent() {
Serial.println("getTesionPercent");
//100-[(Diff act - DIff max)*100]
long resultatTension = (100.00 - (((1960.00 - getTensionValue()) / 103.00) * 100.00));
server.send(200, "text/plane", String(resultatTension)); //Send web page
return (String(resultatTension));
}
String sendLum(){
Serial.println("sendLum");
int ratioPercent =(ratio/250.00)*100;
server.send(200, "text/plane", String(ratioPercent)); //Send web page
return (String(ratioPercent));
}
Conclusion

Organisation



Versions
Drive
Organisation


deck
By guillaume benhamou
deck
- 37