[Mac] Brodeuse numérique Toyota Expert ESP9000

IP_ADDRESS = "192.168.1.39"
Actions | Temps |
Introduction & Matériel | 15 min |
Histoire du robot | 15 min |
Découverte du robot Primo + test | 1h |
Découverte du robot thymio + test | 1h30 |
Découverte de la programmation du robot thymio via VPL | 2h |
Actions | Temps |
Introduction & Matériel | 15 min |
Création d’un visuel via Inkscape | 1h |
Création d’un badge personnalisé | 30min |
=====Fiche projet Exemple ===== ===Date=== ===Quoi ?=== ===Les objectifs pédagogiques=== ===Compétences psychosociales=== ===Pour qui ?=== ===Par qui ?=== ===Avec qui ?=== - Les partenaires : - Les prestataires : ===Où ?=== ===Quand ?=== ===Comment ?=== === Les méthodologies pédagogiques utilisées=== ===Les postes de dépenses=== ===Les critères d'évaluation=== ===Ressources===
Nom | Description | Quantité | Prix unitaire | Prix |
Lolin NodeMCU v3 | Microcontrolleur | 1 | 7€ | 7€ |
DFPlayer Mini | Lecteur MP3 | 1 | 1€ | 1€ |
Enceinte 4Ω 3W | Sortie sonore | 1 | 2€ | 2€ |
Ampli Audio | Amplification du signal sonore | 1 | 0.5€ | 0.5€ |
Connecteur micro USB | Pour l'alimentation | 1 | 0.2€ | 0.2€ |
Chargeur de batterie Li-Ion | Charge de la batterie du système | 1 | 0.2€ | 0.2€ |
Batterie Li-Ion 3.7V 18650 | Alimentation nomade | 1 | 2.5€ | 2.5€ |
LED RGB | Voyant lumineux | 1 | 0.03€ | 0.03€ |
Interrupeur | Marche/Arret du système | 1 | 0.75€ | 0.75€ |
Convertisseur de tension 3.3V | Alimentation des cartes électroniques | 1 | 1€ | 1€ |
Support batterie 18650 | Support batterie | 1 | 0.5€ | 0.5€ |
Condensateur 1000µF | Filtrage de l'alimentation | 1 | 0.07€ | 0.07€ |
Résistance 220Ω | Protection de la LED | 1 | 0.02€ | 0.02€ |
Total | 15.77€ |
#include <DFPlayerMini_Fast.h> #include <ESP8266WiFi.h> #include <SoftwareSerial.h> #define SSID "EnceinteWiFille1" #define PASSWD "wifilles" DFPlayerMini_Fast mp3Player; SoftwareSerial softSerial(D2,D3); WiFiServer server(80); #define Pin_R D7 #define Pin_G D6 #define Pin_B D5 int vol, song, R, G, B; void setup() { // Init serial lines Serial.begin(115200); softSerial.begin(9600); delay(10); WiFi.mode(WIFI_AP); WiFi.softAP(SSID, PASSWD); // Print IP address Serial.print("IP address : "); Serial.println(WiFi.softAPIP()); // Start web server server.begin(); // Start mp3 player mp3Player.begin(softSerial); vol = mp3Player.currentVolume(); song = mp3Player.currentSdTrack(); R = 1023; G = 0; B = 1023; analogWrite(Pin_R, R); analogWrite(Pin_G, G); analogWrite(Pin_B, B); } void loop() { // Init connection with client WiFiClient client = server.available(); if(!client) { return; } while(!client.available()) { delay(1); } // Read client request String req = client.readStringUntil('\r'); // Flush output client.flush(); String text = ""; // Return text if(req.indexOf("/volume") != -1) { uint8_t idx = req.indexOf("?vol="); vol = req.substring(idx+5).toInt(); vol = map(vol, 0, 100, 0, 30); mp3Player.volume(vol); } else if(req.indexOf("/play") != -1) { mp3Player.resume(); } else if(req.indexOf("/pause") != -1) { mp3Player.pause(); } else if(req.indexOf("/next") != -1) { mp3Player.playNext(); } else if(req.indexOf("/previous") != -1) { mp3Player.playPrevious(); } else if(req.indexOf("/change") != -1) { uint8_t idx = req.indexOf("?song="); song = req.substring(idx+6).toInt(); mp3Player.play(song); } else if(req.indexOf("/led") != -1) { uint8_t idx = req.indexOf("?R="); uint8_t idxFin = req.indexOf("&G="); R = req.substring(idx+3, idxFin).toInt(); idx = idxFin; idxFin = req.indexOf("&B="); G = req.substring(idx+3, idxFin).toInt(); idx = idxFin; B = req.substring(idx+3).toInt(); R = map(R, 100, 0, 0, 1023); G = map(G, 100, 0, 0, 1023); B = map(B, 100, 0, 0, 1023); analogWrite(Pin_R, R); analogWrite(Pin_G, G); analogWrite(Pin_B, B); } // Flush output client.flush(); // Generate HTML output String htmlPage = "HTTP/1.1 200 OK\r\n"; htmlPage += "Content-Type: text/html\r\n"; htmlPage += "\r\n"; htmlPage += "<!DOCTYPE html>\r\n"; htmlPage += "<html>\r\n"; htmlPage += " <head>\r\n"; htmlPage += " <meta charset=\"utf-8\" />\r\n"; htmlPage += " <title>Enceinte Wi-Fille</title>\r\n"; htmlPage += " <style type=\"text/css\">\r\n"; htmlPage += " body {\r\n"; htmlPage += " background-color: #c862b7;\r\n"; htmlPage += " }\r\n"; htmlPage += " svg {\r\n"; htmlPage += " border-radius: 20px;\r\n"; htmlPage += " }\r\n"; htmlPage += " </style>\r\n"; htmlPage += " </head>\r\n"; htmlPage += " <body>\r\n"; htmlPage += "<svg width=\"320\" height=\"118\" version=\"1.1\" viewBox=\"0 0 320 118\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"> <metadata> <rdf:RDF> <cc:Work rdf:about=\"\"> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/> <dc:title/> </cc:Work> </rdf:RDF> </metadata> <path d=\"m0 59v-59h320v118h-320zm169.72 53.423c9.4306-1.948 19.247-6.7898 25.909-12.78l5.0577-4.5473 45.406-0.2979c43.887-0.28793 45.557-0.36897 49.906-2.4221 6.0327-2.8476 10.799-7.7582 13.748-14.164 2.2926-4.9806 2.4145-6.1452 2.0934-20-0.32307-13.94-0.48502-14.957-3.09-19.388-1.512-2.572-4.4118-6.047-6.444-7.7221-7.2739-5.9957-8.2444-6.0995-57.235-6.1216l-44.572-0.020094-4.4084-4.4393c-2.4246-2.4416-7.421-6.0224-11.103-7.9572-20.944-11.006-46.616-7.8537-64.671 7.9405l-5.1398 4.4962h-44.411c-49.825 0-50.117 0.035437-58.072 7.0374-2.6181 2.3045-5.3152 5.9773-6.6245 9.0207-2.0157 4.6857-2.1805 6.4625-1.8894 20.371 0.31324 14.963 0.3737 15.327 3.3481 20.154 3.6638 5.9466 10.635 10.857 17.504 12.33 3.2034 0.68701 20.969 1.0864 48.329 1.0864h43.264l2.9371 3.1294c6.3215 6.7354 18.703 13.092 28.778 14.775 8.0268 1.3408 13.11 1.2263 21.38-0.48178zm-90.721-23.349c0-0.53382 1.0838-2.14 2.4085-3.5694 5.0877-5.4898 6.0233-9.0351 6.5985-25.004 0.46364-12.873 0.85177-15.589 2.7376-19.153 2.6923-5.0887 8.0945-9.6823 13.178-11.205 5.1669-1.548 181.84-1.6134 187.4-0.06931 4.8812 1.3554 11.471 7.2841 13.814 12.428 2.4581 5.3972 2.667 27.646 0.31261 33.282-1.97 4.7161-5.8422 8.8049-10.947 11.559l-4 2.1584-105.75 0.2721c-67.883 0.17467-105.75-0.075439-105.75-0.69848zm31-18.574v-5.5h19l2e-3 -7.5h-18.503l-0.615-8.5h21.115v-8.0521l-30.499 0.55209-0.27361 17.25-0.27362 17.25h10.047zm36-7v-12.5h-9v25h9zm133.92 11.524c6.9012-1.9793 10.487-8.2212 8.0717-14.052-1.2208-2.9472-6.5578-6.1743-12.488-7.5513-4.3308-1.0056-5.7963-2.3588-4.3899-4.0535 1.6689-2.0109 4.6604-1.6647 5.9178 0.68489 0.90994 1.7002 1.9022 2.0004 5.7852 1.75 4.0505-0.26118 4.6429-0.57377 4.3627-2.3022-0.58424-3.6046-4.627-6.6838-9.4957-7.2326-10.142-1.1432-16.68 2.4755-16.68 9.2326 0 4.7672 3.1591 7.8229 10.205 9.8712 6.5521 1.9048 8.6826 3.8543 6.753 6.1793-1.8258 2.2-6.2483 1.4274-7.4452-1.3006-0.81769-1.8638-1.776-2.25-5.5833-2.25-2.5279 0-4.8595 0.26326-5.1812 0.58501-0.92461 0.92461 1.1901 6.0493 3.2747 7.9358 3.342 3.0245 11.079 4.1708 16.894 2.503zm-95.106-3.7739-0.31037-3.75-15.5-0.58413v-24.916h-10v33h26.121zm33.19-0.25v-4h-14.938l-0.56156-24.5h-10l-0.54954 32.5h26.05zm35 0.5v-3.5h-17v-7h15v-6h-7.5c-7.3333 0-7.5-0.05556-7.5-2.5 0-2.4583 0.13333-2.5 8-2.5h8v-8.058l-26.5 0.55805-0.54954 32.5h28.05zm-108.58-25.107c2.2726-0.87207 1.9709-5.1144-0.45598-6.4132-4.0395-2.1619-8.9458 1.3138-6.9964 4.9563 1.096 2.0479 4.2868 2.6717 7.4524 1.4569zm-120.34 25.857c-1.7808-6.6649-7.0751-29.349-7.0751-30.314 0-0.51496 2.1884-0.93629 4.8631-0.93629h4.8631l2.8704 20.5 3.7258-20.596 9.1775 0.59641 3.9499 20 2.8238-20.5h4.8631c2.6747 0 4.8631 0.42454 4.8631 0.94342 0 0.51888-1.5676 7.3814-3.4837 15.25-1.916 7.8686-3.7246 15.319-4.0191 16.557-0.45511 1.9126-1.1972 2.25-4.949 2.25-4.9099 0-4.7104 0.29064-6.5188-9.5-2.0481-11.088-2.2655-11.542-3.0813-6.4359-0.40106 2.5103-1.2604 7.1228-1.9096 10.25l-1.1804 5.6859h-4.3906c-4.2287 0-4.4275-0.13821-5.3925-3.75zm39.925-8.75v-12.5h9v25h-9zm0.65499-17.329c-2.0662-2.2831-2.0858-3.5976-0.08356-5.5998 2.155-2.155 5.7566-1.9714 7.9054 0.40295 1.6732 1.8489 1.6816 2.1349 0.13194 4.5-1.964 2.9975-5.5847 3.3147-7.9538 0.69688z\" fill=\"#fcfcfc\"/> <path d=\"m100.23 58.75 0.27361-17.25 30.5-0.55209v8.0521h-21.115l0.615 8.5h18.503l-1e-3 3.75-0.0019 3.75h-19v11h-10.047zm36.774 4.75v-12.5h9v25h-9zm131.21 11.516c-4.0567-0.96115-6.7743-3.3296-8.0634-7.0276-1.2556-3.6018-0.79233-3.9879 4.7839-3.9879 3.8073 0 4.7656 0.3862 5.5833 2.25 1.1968 2.728 5.6194 3.5005 7.4452 1.3006 1.9296-2.3251-0.20086-4.2746-6.753-6.1793-7.046-2.0483-10.205-5.104-10.205-9.8712 0-6.7571 6.5377-10.376 16.68-9.2326 4.8687 0.54877 8.9114 3.628 9.4957 7.2326 0.28016 1.7284-0.3122 2.041-4.3627 2.3022-3.883 0.25038-4.8752-0.04978-5.7852-1.75-1.2575-2.3496-4.2489-2.6958-5.9178-0.68489-1.4064 1.6947 0.0591 3.0479 4.3899 4.0535 9.5575 2.2191 14.403 7.1927 13.042 13.388-1.553 7.0707-10.273 10.591-20.333 8.2072zm-109.21-16.516v-16.5h10v24.916l15.5 0.58413 0.31037 3.75 0.31036 3.75h-26.121zm33.225 0.25 0.27477-16.25h10l0.56156 24.5h14.938v8h-26.05zm33 0 0.27477-16.25 26.5-0.55805v8.058h-8c-7.8667 0-8 0.04167-8 2.5 0 2.4444 0.16667 2.5 7.5 2.5h7.5v6h-15v7h17v7h-28.05zm-88.259-13.814c-1.9494-3.6425 2.957-7.1182 6.9964-4.9563 2.4269 1.2989 2.7286 5.5412 0.45598 6.4132-3.1656 1.2148-6.3564 0.59098-7.4524-1.4569z\" fill=\"#9fb747\"/> <path d=\"m151 113.34c-10.6-1.6424-22.168-6.9883-29.62-13.689l-5.0487-4.5392-91.831-0.61211-5.7079-2.803c-5.9919-2.9424-10.763-7.9897-13.306-14.077-1.081-2.5872-1.4832-7.4472-1.4761-17.838 0.0088155-12.888 0.23954-14.776 2.3639-19.338 1.2948-2.7806 4.2679-6.6937 6.6068-8.6957 7.8301-6.7023 8.2288-6.7487 58.024-6.7487h44.649l4.8914-4.4908c20.621-18.932 54.349-19.239 74.595-0.67957l5.6402 5.1703h44.432c48.845 0 49.819 0.10413 57.095 6.1015 2.0322 1.6751 4.932 5.1501 6.444 7.7221 2.5938 4.4124 2.7685 5.4868 3.095 19.031 0.40389 16.757-0.63904 20.783-7.2518 27.992-8.0707 8.7986-6.8498 8.6117-58.51 8.9604l-45.416 0.30658-4.9392 4.4408c-11.267 10.13-30.356 16.013-44.729 13.786zm139.5-24.444c5.5089-1.3872 12.21-7.0453 14.615-12.34 2.6571-5.8498 2.6705-28.237 0.0205-34.056-2.3427-5.1438-8.9323-11.072-13.814-12.428-5.3055-1.4733-182.34-1.4733-187.64 0-4.688 1.3018-10.843 6.7061-13.326 11.701-1.4586 2.9338-1.9675 6.9175-2.392 18.727-0.45727 12.721-0.86394 15.618-2.6769 19.067-1.1758 2.2368-2.8702 4.6748-3.7654 5.4178-0.89523 0.74297-2.0689 2.1754-2.6083 3.1831-0.94777 1.7709 2.5061 1.8322 103.11 1.8322 72.617 0 105.42-0.33382 108.48-1.104zm-255.53-18.146c0.62214-2.8875 1.3991-7.1879 1.7265-9.5564 0.78681-5.6912 1.7256-4.3186 3.2875 4.8064 1.7438 10.188 1.6207 10 6.5601 10 3.2493 0 4.4587-0.43544 4.8602-1.75 0.94742-3.1012 7.6002-31.418 7.6002-32.35 0-0.49526-2.25-0.90046-5-0.90046-4.0791 0-5.0078 0.32232-5.0424 1.75-0.02331 0.9625-0.60572 5.5566-1.2942 10.209l-1.2519 8.459-3.7463-20.418h-9.3304l-3.7463 20.418-1.2519-8.459c-0.68853-4.6525-1.2709-9.2465-1.2942-10.209-0.03457-1.4277-0.96328-1.75-5.0424-1.75-2.9032 0-5 0.45139-5 1.0764 0 1.0194 6.6907 30.02 7.5381 32.674 0.24042 0.75285 2.1684 1.25 4.8477 1.25h4.4485zm38.035-7.25v-12.5h-9v25h9zm-0.56486-17.428c3.3884-3.7442-0.44315-8.0394-5.9407-6.6596-5.0433 1.2658-3.3334 8.588 2.0055 8.588 1.2045 0 2.9753-0.86775 3.9351-1.9283z\" fill=\"#88307a\"/> </svg>"; htmlPage += " <h1>Choix de musique</h1>\r\n"; htmlPage += " <form method=\"get\" action=\"change\">\r\n"; htmlPage += " <input type=\"number\" min=\"1\" max=\"256\" value=\"" + String(song) + "\" name=\"song\"/>\r\n"; htmlPage += " <input type=\"submit\" value=\"Jouer\" />\r\n"; htmlPage += " </form>\r\n"; htmlPage += " <h1>Reglage du volume</h1>\r\n"; htmlPage += " <form method=\"get\" action=\"volume\">\r\n"; htmlPage += " <input type=\"number\" min=\"0\" max=\"100\" value=\"" + String(map(vol, 0, 30, 0, 100)) + "\" name=\"vol\"/>\r\n"; htmlPage += " <input type=\"submit\" value=\"Changer le volume\"/>\r\n"; htmlPage += " </form>\r\n"; htmlPage += " <h1>Gestion de la lecture</h1>\r\n"; htmlPage += " <div style=\"display: flex;\">\r\n"; htmlPage += " <form action=\"previous\"><input type=\"submit\" value=\"Précédent\"/></form>\r\n"; htmlPage += " <form action=\"play\"><input type=\"submit\" value=\"Jouer\"/></form>\r\n"; htmlPage += " <form action=\"pause\"><input type=\"submit\" value=\"Stopper\"/></form>\r\n"; htmlPage += " <form action=\"next\"><input type=\"submit\" value=\"Suivant\"/></form>\r\n"; htmlPage += " </div>\r\n"; htmlPage += " <h1>Couleur LED (Rouge, Vert, Bleu)</h1>\r\n"; htmlPage += " <form method=\"get\" action=\"led\">\r\n"; htmlPage += " <input type=\"number\" min=\"0\" max=\"100\" value=\"" + String(map(R, 1023, 0, 0, 100)) + "\" name=\"R\"/>\r\n"; htmlPage += " <input type=\"number\" min=\"0\" max=\"100\" value=\"" + String(map(G, 1023, 0, 0, 100)) + "\" name=\"G\"/>\r\n"; htmlPage += " <input type=\"number\" min=\"0\" max=\"100\" value=\"" + String(map(B, 1023, 0, 0, 100)) + "\" name=\"B\"/>\r\n"; htmlPage += " <input type=\"submit\" value=\"Changer\" />\r\n"; htmlPage += " </form>\r\n"; htmlPage += " </body>\r\n"; htmlPage += "</html>\r\n"; // Send html output to client client.println(htmlPage); delay(1); }
Nom | Description | Quantité | Prix Unitaire | Prix |
Lolin NodeMCU v3 | Microcontrolleur principal | 1 | 7€ | 7€ |
Arduino Nano | Microcontrolleur secondaire | 1 | 5€ | 5€ |
Arduino relay shield | Carte 4 relais | 1 | 20€ | 20€ |
DHT11 | Capteur de temperature et d'humidité | 1 | 3€ | 3€ |
DS18B20 | Capteur de temperature | 3 | 4€ | 12€ |
Capacitive moisture sensor v1.2 | Capteur d'humidité du sol | 3 | 3€ | 9€ |
SSD1306 | Ecran OLED 128x64 i2c | 1 | 2€ | 2€ |
Bouton poussoir | Pour le contrôle manuel | 3 | 1€ | 3€ |
Résistance 220 Ω | Pour le diviseur de tension | 1 | 0.1€ | 0.1€ |
Résistance 430 Ω | Pour le diviseur de tension | 1 | 0.1€ | 0.1€ |
Résistance 4.7 kΩ | Pour le bus OneWire | 1 | 0.1€ | 0.1€ |
Pompe 12V | Pompe utilisée pour arroser les plantes | 3 | 10€ | 30€ |
Lampe 220V pour la pousse des plantes | Lampe utilisée pour illuminer les plantes (Emet uniquement dans les spectres bleu et rouge) | 1 | 5€ | 5€ |
Total | ~96€ |
| Contributeurs-ice-s | william | | Licence | CC-BY-NC-SA | | Dificulté | Facile | | Durée | 2h | | Temps de fabrication | 1 jour et 16h | | Coût | 15 € | | Outils | Creality ender 3 | | Ingrédients | PLA, Tinkercad |
Nom | Info | Quantité |
---|---|---|
Lolin NodeMCU v3 | Microcontrolleur | 1 |
FX29K0-100A-0100-L | Capteur de force (Mesure de poids) | 1 |
SSD1306 | Écran OLED 0.96" (128x64 px) | 1 |
Résistance 10k | Pull-Up I²C | 2 |
Condensateur 100nF | Filtre anti-rebonds | 2 |
Bouton poussoir | Gestion de l'interface | 2 |
Nom | Quantité | Lien |
---|---|---|
Bloc shredder pro precious plastic (en kit) | 1 | https://bazar.preciousplastic.com/machines/shredder-pro/shredder-pro-kits/shredder-pro-v4-kit |
Moteur triphasé 4kW 18tr/min 2037Nm |
1 | https://www.technoindus.com/motoreducteurs-coaxiaux/motoreducteur-coaxial-ith143-i7943-o60-taille112-4poles-4kw-ie2-b14-h-225-fonte-3665948151879-34744.html |
Accouplement flexible HRC230 | 1 | https://shop.expert-distribution.com/accouplement-hrc-230-complet-type-hh-3020-challenge-c2x31961134 |
Moyeu amovible 45mm (coté shredder) |
1 | https://shop.expert-distribution.com/moyeu-amovible-3020-045-c2x31963124 |
Moyeu amovible 60mm (coté moteur) |
1 | https://shop.expert-distribution.com/moyeu-amovible-3020-060-c2x31963128 |
Longueur (mm) | Largeur (mm) | Hauteur (mm) | Épaisseur (mm) | Quantité |
---|---|---|---|---|
61 | 40 | 40 | 4 | 6 |
79 | 40 | 40 | 4 | 2 |
47 | 40 | 40 | 4 | 3 |
170 | 80 | 40 | 4 | 2 |
55 | 80 | 40 | 4 | 2 |
47 | 80 | 40 | 4 | 5 |
41 | 80 | 40 | 4 | 2 |
33.65 | 80 | 40 | 4 | 2 |
Matériaux | Découpe | Gravure | Marquage | |||||||
---|---|---|---|---|---|---|---|---|---|---|
Matériaux | Epaisseur | P Max | P Min | Vitesse | P Max | P Min | Vitesse | P Max | P Min | Vitesse |
CONTREPLAQUE | ||||||||||
Contreplaqué | 3mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
4mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | |
5mm | 62 | 60 | 18 | 00 | 00 | 00 | 00 | 00 | 00 | |
6mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | |
9mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | |
10mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | |
MDF | ||||||||||
MDF | 3mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
4mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | |
5mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | |
6mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | |
9mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | |
10mm | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
Nom | Description | Quantité | Prix Unitaire | Prix |
ESP32 WROOM (Version 30 pins) | Microcontrolleur | 1 | ||
MQ-2 | Capteur de fumées | 1 | ||
MQ-7 | Capteur de monoxyde de carbone (CO) | 1 | ||
MQ-135 | Capteur de dioxyde de carbone (CO2) | 1 | ||
DHT11 | Capteur de température et humidité | 1 | ||
LED 1W Rouge+Bleu+Vert+Blanc """" | Alarme visuelle | 1 | ||
Buzzer | Alarme sonore | 1 | ||
Transistor 2N2222 | Transistor NPN (interrupteur électronique) | 5 | ||
Résistances 5ohm | Protection des LEDs | 4 | ||
Résistances 5.1k | Diviseur de tension | 3 | ||
Résistances 10k | Diviseur de tension et bus ""OneWire"" | 4 | ||
Condensateur 100nF | Filtrage d'alimentation | 1 | ||
Condensateur 100uF | Filtrage d'alimentation | 1 |
// Definition des pins #define PIN_MQ2 33 #define PIN_MQ7 35 #define PIN_ALIM_MQ7 26 #define PIN_MQ135 34 #define PIN_DHT11 16 #define PIN_LED_R 13 #define PIN_LED_G 12 #define PIN_LED_B 14 #define PIN_LED_W 27 #define PIN_BUZZER 18 // Gestion du capteur DHT11 #include <DHT.h> #define DHTTYPE DHT11 DHT dht(PIN_DHT11, DHTTYPE); // Gestion des capteurs MQ #include <MQUnifiedsensor.h> #define MQ_BOARD "ESP-32" #define MQ_VOLT_RES 3.3 #define MQ_ADC_RES 12 #define MQ2_R0 2.85 #define MQ7_R0 7.10 #define MQ135_R0 13.95 unsigned long mq7OldMillis = 0; int mq7State = 0; // 0 -> Chauffage | 1 -> Lecture MQUnifiedsensor MQ2(MQ_BOARD, MQ_VOLT_RES, MQ_ADC_RES, PIN_MQ2, "MQ-2"); MQUnifiedsensor MQ7(MQ_BOARD, MQ_VOLT_RES, MQ_ADC_RES, PIN_MQ7, "MQ-7"); MQUnifiedsensor MQ135(MQ_BOARD, MQ_VOLT_RES, MQ_ADC_RES, PIN_MQ135, "MQ-135"); // Gestion du WiFi #include <WiFi.h> #define SSID "XXXX" #define PASSWD "XXXX" WiFiClient tsClient; WiFiClient iftttClient; // Gestion Thingspeak #include <ThingSpeak.h> #define TS_API_KEY "XXXX" #define TS_CHANNEL XXXX #define TS_FUMEE_FIELD 1 #define TS_CO_FIELD 2 #define TS_CO2_FIELD 3 #define TS_TEMP_FIELD 4 #define TS_HUM_FIELD 5 // Gestion IFTTT #define IFTTT_HOST "maker.ifttt.com" #define IFTTT_API_KEY "XXXX" // Gases #define IFTTT_FIRE_EVENT "fire" #define IFTTT_FIRE_THRES 100 #define IFTTT_CO2_EVENT "co2" #define IFTTT_CO2_THRES 600 #define IFTTT_CO_EVENT "co" #define IFTTT_CO_THRES 100 // Temp #define IFTTT_HOT_EVENT "hot" #define IFTTT_HOT_THRES 35 #define IFTTT_COLD_EVENT "cold" #define IFTTT_COLD_THRES 15 // Hum #define IFTTT_DRY_EVENT "dry" #define IFTTT_DRY_THRES 20 #define IFTTT_WET_EVENT "wet" #define IFTTT_WET_THRES 80 bool co2EventSent = false; bool coEventSent = false; bool fireEventSent = false; bool hotEventSent = false; bool coldEventSent = false; bool wetEventSent = false; bool dryEventSent = false; // Gestion PWM #include <analogWrite.h> // Valeurs des capteurs int ppmFumee = 0; int ppmCO = 0; int ppmCO2 = 0; int temp = 0; int hum = 0; // Triggers LED et Buzzer bool fire = false; bool co = false; bool co2 = false; void setup() { Serial.begin(115200); ledInit(); pinMode(PIN_BUZZER, OUTPUT); sensorsInit(); wifiInit(); ThingSpeak.begin(tsClient); ledOff(); } void loop() { bool goodMQ7 = false; // Lecture des capteurs readMQ2(); goodMQ7 = readMQ7(); readMQ135(); readDHT(); // Envoi des valeurs sur ThingSpeak ThingSpeak.setField(TS_FUMEE_FIELD, ppmFumee); if(goodMQ7) { ThingSpeak.setField(TS_CO_FIELD, ppmCO); } ThingSpeak.setField(TS_CO2_FIELD, ppmCO2); ThingSpeak.setField(TS_TEMP_FIELD, temp); ThingSpeak.setField(TS_HUM_FIELD, hum); ThingSpeak.writeFields(TS_CHANNEL, TS_API_KEY); // Gestion des events et trigger IFTTT if(ppmFumee >= IFTTT_FIRE_THRES) { if(!fireEventSent) { sendIfttt(IFTTT_FIRE_EVENT); fireEventSent = true; } fire = true; } else { fireEventSent = false; fire = false; } if(goodMQ7 && ppmCO >= IFTTT_CO_THRES) { if(!coEventSent) { sendIfttt(IFTTT_CO_EVENT); coEventSent = true; } co = true; } else { coEventSent = false; co = false; } if(ppmCO2 >= IFTTT_CO2_THRES) { if(!co2EventSent) { sendIfttt(IFTTT_CO2_EVENT); co2EventSent = true; } co2 = true; } else { co2EventSent = false; co2 = false; } if(temp >= IFTTT_HOT_THRES) { if(!hotEventSent) { sendIfttt(IFTTT_HOT_EVENT); hotEventSent = true; } } else { hotEventSent = false; } if(temp <= IFTTT_COLD_THRES) { if (!coldEventSent) { sendIfttt(IFTTT_COLD_EVENT); coldEventSent = true; } } else { coldEventSent = false; } if(hum >= IFTTT_WET_THRES) { if(!wetEventSent) { sendIfttt(IFTTT_WET_EVENT); wetEventSent = true; } } else { wetEventSent = false; } if(hum <= IFTTT_DRY_THRES) { if(!dryEventSent) { sendIfttt(IFTTT_DRY_EVENT); dryEventSent = true; } } else { dryEventSent = false; } // Gestion des LEDs et du buzzer if(fire) { ledFire(); fireAlarm(); } else if (co) { ledCO(); coAlarm(); } else if (co2) { ledCO2(); co2Alarm(); } else { ledOff(); noTone(PIN_BUZZER); } // Delai delay(250); } // Function LEDs void ledInit() { pinMode(PIN_LED_R, OUTPUT); pinMode(PIN_LED_G, OUTPUT); pinMode(PIN_LED_B, OUTPUT); pinMode(PIN_LED_W, OUTPUT); analogWrite(PIN_LED_R, 100); analogWrite(PIN_LED_G, 100); analogWrite(PIN_LED_B, 100); analogWrite(PIN_LED_W, 100); } void ledOff() { analogWrite(PIN_LED_R, 0); analogWrite(PIN_LED_G, 0); analogWrite(PIN_LED_B, 0); analogWrite(PIN_LED_W, 0); } void ledFire() { analogWrite(PIN_LED_R, 255); analogWrite(PIN_LED_G, 0); analogWrite(PIN_LED_B, 0); analogWrite(PIN_LED_W, 0); } void ledCO() { analogWrite(PIN_LED_R, 0); analogWrite(PIN_LED_G, 255); analogWrite(PIN_LED_B, 0); analogWrite(PIN_LED_W, 0); } void ledCO2() { analogWrite(PIN_LED_R, 0); analogWrite(PIN_LED_G, 0); analogWrite(PIN_LED_B, 255); analogWrite(PIN_LED_W, 0); } // Fonctions buzzer void tone(uint8_t pin, int freq) { // On utilise le channel 15 pour eviter les conflits avec analogWrite ledcSetup(15, 50000, 13); ledcAttachPin(pin, 15); ledcWriteTone(15, freq); } void noTone(uint8_t pin) { tone(pin, 0); } void fireAlarm() { tone(PIN_BUZZER, 1000); } void coAlarm() { tone(PIN_BUZZER, 1500); } void co2Alarm() { tone(PIN_BUZZER, 2000); } // Fonctions capteurs void sensorsInit() { // DHT11 dht.begin(); // MQ-2 (Courbe CH4) MQ2.setRegressionMethod(true); MQ2.setA(4301.22); MQ2.setB(-2.65); MQ2.init(); MQ2.setR0(MQ2_R0); MQ2.setRL(1); // MQ-7 analogWrite(PIN_ALIM_MQ7, 255); MQ7.setRegressionMethod(true); MQ7.setA(99.042); MQ7.setB(-1.518); MQ7.init(); MQ7.setR0(MQ7_R0); MQ7.setRL(1); // MQ-135 MQ135.setRegressionMethod(true); MQ135.setA(110.47); MQ135.setB(-2.862); MQ135.init(); MQ135.setR0(MQ135_R0); MQ135.setRL(1); } void readMQ2() { MQ2.update(); ppmFumee = MQ2.readSensor(); } bool readMQ7() { // Temps de chauffe écoulé if(!mq7State && (millis() - mq7OldMillis) >= (60000UL)) { // Passage en mode lecture analogWrite(PIN_ALIM_MQ7, 20); mq7OldMillis = millis(); mq7State = 1; // Temps de lecture écoulé } else if (mq7State && (millis() - mq7OldMillis) >= (90000UL)) { // Passage en mode chauffage analogWrite(PIN_ALIM_MQ7, 255); mq7OldMillis = millis(); mq7State = 0; } if(mq7State) { analogWrite(PIN_ALIM_MQ7, 255); delay(5); MQ7.update(); ppmCO = MQ7.readSensor(); analogWrite(PIN_ALIM_MQ7, 20); // Valeur mise a jour return true; } // Pas de nouvelle valeur return false; } void readMQ135() { MQ135.update(); ppmCO2 = MQ135.readSensor() + 400; } void readDHT() { temp = dht.readTemperature(); hum = dht.readHumidity(); } // Fonctions WiFi et IOT void wifiInit() { WiFi.mode(WIFI_STA); // Init WiFi Serial.println(); Serial.print("Connexion en cours"); WiFi.begin(SSID, PASSWD); while(WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(); Serial.println("Connexion WiFi OK"); // Gestion MAC byte mac[6]; WiFi.macAddress(mac); // Affichage de l'adresse IP Serial.print("Adresse IP : "); Serial.println(WiFi.localIP()); } void sendIfttt(String event) { Serial.println(iftttClient.connect(IFTTT_HOST, 80)); iftttClient.println("GET http://maker.ifttt.com/trigger/"+event+"/with/key/"+IFTTT_API_KEY); }
Contributeurs-ice-s | michael |
Licence | CC-BY-NC-SA |
Dificulté | Moyenne |
Durée | 2h |
Temps de fabrication | à évaluer |
Coût | 25 € |
Outils | Découpeuse laser PerezCamp |