articles:domotique:suivi_de_la_teleinformation_erdf_avec_arduino
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| articles:domotique:suivi_de_la_teleinformation_erdf_avec_arduino [10/08/2019 22:22] – [Fonctionnement de la téléinformation EDF] antoineve | articles:domotique:suivi_de_la_teleinformation_erdf_avec_arduino [10/08/2019 23:22] (Version actuelle) – [Liens] antoineve | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~DISCUSSION~~ | ~~DISCUSSION~~ | ||
| **Tags** : {{tagging:: | **Tags** : {{tagging:: | ||
| + | {{ : | ||
| --------------------------------------- | --------------------------------------- | ||
| ====== Suivi de la téléinformation ERDF avec arduino ====== | ====== Suivi de la téléinformation ERDF avec arduino ====== | ||
| Ligne 19: | Ligne 20: | ||
| ===== Partie arduino ===== | ===== Partie arduino ===== | ||
| ==== Hardware ==== | ==== Hardware ==== | ||
| + | |||
| + | Composants necessaires : | ||
| + | |||
| + | * une carte arduino (Uno, mini, ou nano) ; | ||
| + | * un shield [[wpfr> | ||
| + | * un [[wpfr> | ||
| + | * une [[wpfr> | ||
| + | * deux [[wpfr> | ||
| + | * une [[wpfr> | ||
| + | |||
| + | La DEL permet d’avoir un retour de l’activité : elle clignote quand il y a un transfert d’information. Cette partie du montage est optionnelle. | ||
| + | |||
| + | La diode permet de supprimer une alternance du signal, le photocoupleur permet d’isoler le signal du circuit électronique. | ||
| + | |||
| + | D’après [[http:// | ||
| + | |||
| + | * Le signal sur les bornes I1/I2 est un signal modulé à 50kHz. | ||
| + | * La présence de modulation correspond à un 0 logique, et l’absence à un 1 logique. | ||
| + | * Ces informations sont émises cycliquement sous forme de messages composés d’une étiquette d’identification suivie généralement d’une valeur. | ||
| + | * Il est donc nécessaire de démoduler ce signal. Après quoi on obtient une suite de caractères ASCII émise à 1200 bits/s, 7 bits/ | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | |||
| + | | ||
| ==== Software ==== | ==== Software ==== | ||
| + | <file c teleinfo.ino> | ||
| + | #include < | ||
| + | byte mac[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x25 }; | ||
| + | byte ip[] = { 192, 168, 1, 25 }; | ||
| + | EthernetServer server(80); | ||
| + | |||
| + | #include < | ||
| + | SoftwareSerial cptSerial(2, | ||
| + | #define startFrame 0x02 | ||
| + | #define endFrame 0x03 | ||
| + | #define startLine 0x0A | ||
| + | #define endLine 0x0D | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | cptSerial.begin(1200); | ||
| + | Ethernet.begin(mac, | ||
| + | server.begin(); | ||
| + | } | ||
| + | |||
| + | String GetTeleInfo() | ||
| + | { | ||
| + | String TeleInfo = ""; | ||
| + | char charIn = 0; | ||
| + | while (charIn != startLine) | ||
| + | { | ||
| + | charIn = cptSerial.read() & 0x7F; | ||
| + | } | ||
| + | while (charIn != endLine) | ||
| + | { | ||
| + | if (cptSerial.available() > 0) | ||
| + | { | ||
| + | charIn = cptSerial.read() & 0x7F; | ||
| + | TeleInfo += charIn; | ||
| + | } | ||
| + | } | ||
| + | return TeleInfo; | ||
| + | } | ||
| + | |||
| + | String ShowTeleInfo(String keyword, String unit, int length) | ||
| + | { | ||
| + | int essai = 0; | ||
| + | // Nombre d' | ||
| + | int max_essais = 33; | ||
| + | String data = ""; | ||
| + | String msg = ""; | ||
| + | while(data.substring(0, | ||
| + | { | ||
| + | data = GetTeleInfo(); | ||
| + | essai++; | ||
| + | } | ||
| + | msg = " | ||
| + | msg += keyword; | ||
| + | msg += " unit=\""; | ||
| + | msg += unit; | ||
| + | msg += " | ||
| + | if (essai != max_essais) | ||
| + | { | ||
| + | msg += data.substring((keyword.length() + 1),(length + (keyword.length() + 1))); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | msg += " | ||
| + | } | ||
| + | msg += "</"; | ||
| + | msg += keyword; | ||
| + | msg += ">"; | ||
| + | return msg; | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | EthernetClient client = server.available(); | ||
| + | if (client) | ||
| + | { | ||
| + | boolean current_line_is_blank = true; | ||
| + | while (client.connected()) | ||
| + | { | ||
| + | if (client.available()) | ||
| + | { | ||
| + | char c = client.read(); | ||
| + | if (c == ' | ||
| + | { | ||
| + | client.println(" | ||
| + | client.println(" | ||
| + | client.println(); | ||
| + | client.println("<? | ||
| + | client.println("< | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | client.println(ShowTeleInfo(" | ||
| + | // On ne retiens pas ADIR(1,2,3) ou ADPS (peuvent être calculés) | ||
| + | client.println("</ | ||
| + | break; | ||
| + | } | ||
| + | if (c == ' | ||
| + | { | ||
| + | current_line_is_blank = true; | ||
| + | } | ||
| + | else if (c != ' | ||
| + | { | ||
| + | current_line_is_blank = false; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | delay(200); | ||
| + | client.stop(); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| === Exemple de sortie XML === | === Exemple de sortie XML === | ||
| + | <code xml> | ||
| + | <?xml version=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Il est bien sûr tout à fait possible de faire la même chose avec une sortie [[wpfr> | ||
| ===== Plugin munin ===== | ===== Plugin munin ===== | ||
| + | [[wpfr> | ||
| + | |||
| + | <file python teleinfo.py> | ||
| + | # | ||
| + | from lxml import etree | ||
| + | import sys | ||
| + | |||
| + | ARDUINO_URL = ' | ||
| + | |||
| + | if " | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | else: | ||
| + | root = etree.parse(' | ||
| + | infos = root.xpath('/ | ||
| + | HP = infos[0].find(' | ||
| + | HC = infos[0].find(' | ||
| + | print(" | ||
| + | print(" | ||
| + | </ | ||
| + | |||
| + | {{ : | ||
| ===== Exemples d’applications ===== | ===== Exemples d’applications ===== | ||
| + | |||
| + | * Déclencher certains appareils uniquement lors des heures creuses, les jours « EJP », les jours « bleus » ; | ||
| + | * Afficher en direct la consommation, | ||
| + | * Créer un système de délestage, afin d’éviter une coupure en cas de surconsommation. | ||
| + | * ... | ||
| ===== Liens ===== | ===== Liens ===== | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
articles/domotique/suivi_de_la_teleinformation_erdf_avec_arduino.1565475746.txt · Dernière modification : de antoineve
