Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
|
projets:cctv_disco:start [2021/11/22 13:31] admin [Code] |
projets:cctv_disco:start [2022/04/06 17:31] (Version actuelle) risbo [Photos et médias] |
||
|---|---|---|---|
| Ligne 21: | Ligne 21: | ||
| ===== Notes techniques et matériaux ===== | ===== Notes techniques et matériaux ===== | ||
| - | * Esp 32 | + | * **ESP32 cam** [[https:// |
| - | | + | la camera envoie un flux video en wifi...eventuellement avec Motioneye (sur linux) on peut ajouter des fonction de detection mouvement/ |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| + | * **ESP8266 :** Permet de commander en wifi l' | ||
| - | **ESP32 cam** [[https:// | + | |
| - | la camera envoie un flux video en wifi...eventuellement avec Motioneye | + | * :!: **Led 4mm** [[https:// |
| - | **ESP8266 :** Permet de commander en wifi l' | + | |
| + | | ||
| + | | ||
| + | * Enceinte Bluetooth si besoin son fort | ||
| - | **Lecteur mp3** (se declenche avec une arduino ou esp..) necessite une carte micro SD ! | ||
| - | [[https:// | ||
| - | necessite un ampli et enceinte pour faire :!: un son assez puissant.... ou enceinte bluetooth...batterie integrée.. | ||
| - | * Fonctionne avec librairie Redmp3.h | ||
| - | :!: **Led 4mm** ne seront pas puissante a cette taille.... | ||
| - | [[https:// | ||
| ==== Esp8266 page web controle ==== | ==== Esp8266 page web controle ==== | ||
| Ligne 55: | Ligne 49: | ||
| ==== Code ==== | ==== Code ==== | ||
| - | Pour l' | + | Code qui cree une pageweb |
| + | L'url de la page est donné en serie. (en l' | ||
| <code c+> | <code c+> | ||
| - | /********* | + | // MP3 lib |
| - | Rui Santos | + | #include < |
| - | | + | #include " |
| - | *********/ | + | |
| + | #define MP3_RX 12//RX of Serial MP3 module connect to D7 of wemos | ||
| + | #define MP3_TX 13//TX to D8, wemos | ||
| + | MP3 mp3(MP3_RX, MP3_TX); | ||
| + | |||
| + | int8_t track = 0x01;//the first song in the TF card | ||
| + | int8_t track2 | ||
| + | int8_t volume = 0x1a;//0~0x1e (30 adjustable level) | ||
| + | |||
| // Load Wi-Fi library | // Load Wi-Fi library | ||
| #include < | #include < | ||
| + | |||
| // Replace with your network credentials | // Replace with your network credentials | ||
| const char* ssid = " | const char* ssid = " | ||
| const char* password = " | const char* password = " | ||
| + | |||
| // Set web server port number to 80 | // Set web server port number to 80 | ||
| WiFiServer server(80); | WiFiServer server(80); | ||
| + | |||
| // Variable to store the HTTP request | // Variable to store the HTTP request | ||
| String header; | String header; | ||
| + | |||
| // Auxiliar variables to store the current output state | // Auxiliar variables to store the current output state | ||
| String output5State = " | String output5State = " | ||
| String output4State = " | String output4State = " | ||
| + | |||
| // Assign output variables to GPIO pins | // Assign output variables to GPIO pins | ||
| const int output5 = 5; | const int output5 = 5; | ||
| const int output4 = 4; | const int output4 = 4; | ||
| + | |||
| // Current time | // Current time | ||
| unsigned long currentTime = millis(); | unsigned long currentTime = millis(); | ||
| Ligne 90: | Ligne 94: | ||
| // Define timeout time in milliseconds (example: 2000ms = 2s) | // Define timeout time in milliseconds (example: 2000ms = 2s) | ||
| const long timeoutTime = 2000; | const long timeoutTime = 2000; | ||
| + | |||
| void setup() { | void setup() { | ||
| Serial.begin(115200); | Serial.begin(115200); | ||
| Ligne 99: | Ligne 103: | ||
| digitalWrite(output5, | digitalWrite(output5, | ||
| digitalWrite(output4, | digitalWrite(output4, | ||
| + | |||
| // Connect to Wi-Fi network with SSID and password | // Connect to Wi-Fi network with SSID and password | ||
| Serial.print(" | Serial.print(" | ||
| Ligne 115: | Ligne 119: | ||
| server.begin(); | server.begin(); | ||
| } | } | ||
| + | |||
| void loop(){ | void loop(){ | ||
| WiFiClient client = server.available(); | WiFiClient client = server.available(); | ||
| + | |||
| if (client) { // If a new client connects, | if (client) { // If a new client connects, | ||
| Serial.println(" | Serial.println(" | ||
| Ligne 140: | Ligne 144: | ||
| client.println(" | client.println(" | ||
| client.println(); | client.println(); | ||
| - | | + | |
| // turns the GPIOs on and off | // turns the GPIOs on and off | ||
| if (header.indexOf(" | if (header.indexOf(" | ||
| Ligne 146: | Ligne 150: | ||
| output5State = " | output5State = " | ||
| digitalWrite(output5, | digitalWrite(output5, | ||
| + | mp3.playWithVolume(track2, | ||
| + | delay(50); | ||
| + | |||
| + | | ||
| } else if (header.indexOf(" | } else if (header.indexOf(" | ||
| Serial.println(" | Serial.println(" | ||
| output5State = " | output5State = " | ||
| digitalWrite(output5, | digitalWrite(output5, | ||
| + | mp3.stopPlay(); | ||
| + | delay(50); | ||
| + | |||
| + | | ||
| } else if (header.indexOf(" | } else if (header.indexOf(" | ||
| Serial.println(" | Serial.println(" | ||
| output4State = " | output4State = " | ||
| + | |||
| + | // | ||
| digitalWrite(output4, | digitalWrite(output4, | ||
| + | mp3.playWithVolume(track, | ||
| + | delay(50); | ||
| + | |||
| + | | ||
| } else if (header.indexOf(" | } else if (header.indexOf(" | ||
| Serial.println(" | Serial.println(" | ||
| output4State = " | output4State = " | ||
| digitalWrite(output4, | digitalWrite(output4, | ||
| + | mp3.stopPlay(); | ||
| + | delay(50); | ||
| } | } | ||
| - | | + | |
| // Display the HTML web page | // Display the HTML web page | ||
| client.println("< | client.println("< | ||
| Ligne 170: | Ligne 190: | ||
| client.println(" | client.println(" | ||
| client.println(" | client.println(" | ||
| - | | + | |
| // Web Page Heading | // Web Page Heading | ||
| client.println("< | client.println("< | ||
| - | | + | |
| // Display current state, and ON/OFF buttons for GPIO 5 | // Display current state, and ON/OFF buttons for GPIO 5 | ||
| client.println("< | client.println("< | ||
| Ligne 182: | Ligne 202: | ||
| client.println("< | client.println("< | ||
| } | } | ||
| - | + | ||
| // Display current state, and ON/OFF buttons for GPIO 4 | // Display current state, and ON/OFF buttons for GPIO 4 | ||
| client.println("< | client.println("< | ||
| Ligne 192: | Ligne 212: | ||
| } | } | ||
| client.println("</ | client.println("</ | ||
| - | | + | |
| // The HTTP response ends with another blank line | // The HTTP response ends with another blank line | ||
| client.println(); | client.println(); | ||
| Ligne 213: | Ligne 233: | ||
| } | } | ||
| } | } | ||
| - | |||
| </ | </ | ||
| - | ===== Photos et médias===== | + | {{: |
| Code pour afficher les images du projet : | Code pour afficher les images du projet : | ||
| {{gallery>?& | {{gallery>?& | ||