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:39] – [Hardware] 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 45: | Ligne 46: | ||
| | | ||
| ==== 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.1565476754.txt · Dernière modification : de antoineve
