ESP8266 rapport erreur Plugin _P127_Teleinfo

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
T3rorX
New user
Posts: 1
Joined: 03 Jan 2019, 05:16

ESP8266 rapport erreur Plugin _P127_Teleinfo

#1 Post by T3rorX » 03 Jan 2019, 14:28

Bonjour,

Je réfléchis à mettre en place un ESP8266 dans mon local compteur ERDF, mais impossible de compiler avec Atom.

Voici les erreurs
H:/GitHub/ESPEasy/src/_P127_Teleinfo.ino: In function 'boolean Plugin_127(byte, EventStruct*, String&)':
H:/GitHub/ESPEasy/src/_P127_Teleinfo.ino:189:49: error: incompatible types in assignment of 'int' to 'unsigned int [32]'
H:/GitHub/ESPEasy/src/_P127_Teleinfo.ino:245:14: warning: unused variable 'log' [-Wunused-variable]
sprintf_P(log, PSTR("%s%s using port %u"), "HTTP : connecting to ", host, port);
^
H:/GitHub/ESPEasy/src/_P127_Teleinfo.ino:45:15: warning: unused variable 'connectionState' [-Wunused-variable]
H:/GitHub/ESPEasy/src/_P127_Teleinfo.ino: In function 'boolean P127_sendtoHTTP(String, int, String)':
H:/GitHub/ESPEasy/src/_P127_Teleinfo.ino:585:1: warning: control reaches end of non-void function [-Wreturn-type]
*** [.pioenvs\esp32test_1M8_partition\src\ESPEasy.ino.cpp.o] Error 1


_P127_teleinfo.ino Pris sur https://github.com/letscontrolit/ESPEas ... Playground

Code: Select all

//#######################################################################################################
//#################################### Plugin 127: Teleinfo #############################################
//#################################### This plugin transmits data of energy counter to HTTP server  #####
//#################################### Compatible with jeedom plugin Teleinfo                       #####
//#######################################################################################################

#define PLUGIN_127
#define PLUGIN_ID_127         127
#define PLUGIN_NAME_127       "Teleinfo"


#define P127_BUFFER_SIZE 128
boolean Plugin_127_init = false;
int P127_CYCLE = 0;
String P127_SendData = "";
String P127_URL = "";
int P127_PORT = 80;
String P127_HOST = "";

boolean Plugin_127(byte function, struct EventStruct *event, String& string)
{
  boolean success = false;
  static byte connectionState = 0;

  switch (function)
  {

    case PLUGIN_DEVICE_ADD:
      {
        Device[++deviceCount].Number = PLUGIN_ID_127;
        Device[deviceCount].SendDataOption = false;
        Device[deviceCount].TimerOption = false;
        Device[deviceCount].Ports = 0;
        Device[deviceCount].PullUpOption = false;
        Device[deviceCount].InverseLogicOption = false;
        Device[deviceCount].FormulaOption = false;
        Device[deviceCount].Custom = true;
        Device[deviceCount].ValueCount = 0;
        break;
      }

    case PLUGIN_GET_DEVICENAME:
      {
        string = F(PLUGIN_NAME_127);
        break;
      }

    case PLUGIN_GET_DEVICEVALUENAMES:
      {

        break;
      }

    case PLUGIN_WEBFORM_LOAD:
      {




        char deviceTemplate[2][128];
        LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));

        string += F("<TR><TD>Host:<TD><input type='text' size='64' maxlength='128' name='Plugin_127_host' value='");
        string += deviceTemplate[0];
        string += F("'>");
        char tmpString[128];
        sprintf_P(tmpString, PSTR("<TR><TD>Port:<TD><input type='text' name='Plugin_127_port' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
        string += tmpString;
        string += F("<TR><TD>Start url:<TD><input type='text' size='64' maxlength='128' name='Plugin_127_url' value='");
        string += deviceTemplate[1];
        string += F("'>");
        success = true;
        break;
      }

    case PLUGIN_WEBFORM_SAVE:
      {

        String plugin1 = WebServer.arg("Plugin_127_port");
        Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();

        char deviceTemplate[2][128];
        char argc[25];

        String arg = F("Plugin_127_host");
        arg.toCharArray(argc, 25);
        String tmpString = WebServer.arg(argc);
        strncpy(deviceTemplate[0], tmpString.c_str(), sizeof(deviceTemplate[0]));

        arg = F("Plugin_127_url");
        arg.toCharArray(argc, 25);
        tmpString = WebServer.arg(argc);
        strncpy(deviceTemplate[1], tmpString.c_str(), sizeof(deviceTemplate[1]));

        Settings.TaskDeviceID[event->TaskIndex] = 1; // temp fix, needs a dummy value

        SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
        success = true;
        break;
      }


    case PLUGIN_INIT: // ok
      {
        char deviceTemplate[2][128];
        LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
        P127_HOST = String(deviceTemplate[0]);
        P127_PORT = int(Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
        P127_URL = String(deviceTemplate[1]);
        Serial.begin(1200, SERIAL_7E1); //Liaison série avec les paramètres
        Plugin_127_init = true;
        success = true;
        break;
      }


    case PLUGIN_SERIAL_IN:
      {
        uint8_t serial_buf[P127_BUFFER_SIZE];
        int RXWait = 10;
        int timeOut = RXWait;
        size_t bytes_read = 0;
        char log[40];


        while (timeOut > 0)
        {
          while (Serial.available()) {
            if (bytes_read < P127_BUFFER_SIZE) {
              serial_buf[bytes_read] = Serial.read();
              bytes_read++;
            }
            else {
              Serial.read();  // when the buffer is full, just read remaining input, but do not store...

            }
            timeOut = RXWait; // if serial received, reset timeout counter
          }
          delay(1);
          timeOut--;
        }

        if (bytes_read == P127_BUFFER_SIZE)  // if we have a full buffer, drop the last position to stuff with string end marker
        {
          while (Serial.available()) { // read possible remaining data to avoid sending rubbish...
            Serial.read();
          }
          bytes_read--;
          // and log buffer full situation
          // strcpy_P(log, PSTR("Teleinfo: serial buffer full!"));
          // addLog(LOG_LEVEL_ERROR, log);
        }
        serial_buf[bytes_read] = 0; // before logging as a char array, zero terminate the last position to be safe.
        //	char log[P127_BUFFER_SIZE + 40];
        //	sprintf_P(log, PSTR("Ser2N: S>: %s"), (char*)serial_buf);
        //	addLog(LOG_LEVEL_DEBUG, log);

        // We can also use the rules engine for local control!


        String message = (char*)serial_buf;
        int NewLinePos = message.indexOf("\r\n");
        if (NewLinePos > 0) {
          message = message.substring(0, NewLinePos);
        }
        String eventString = "";

        // message.replace("\r", "");
        if (message.length() > 5) {
          int indexValue = message.indexOf(" ");
          String nameValue = message.substring(1, indexValue);
          String value = message.substring(indexValue + 1, message.length() - 3);
          String checksum = message.substring(message.length() - 2);

          //  UserVar[event->BaseVarIndex] = value.toInt();

          if (P127_CYCLE == 0) {
            if (P127_checksum(nameValue, value, checksum)) {

              eventString = F("Teleinfo#");
              eventString += nameValue;
              eventString += F("=");
              eventString += value;
              P127_SendData += nameValue + "=" + value + "&";

            }

          }

          if (nameValue == "ADCO") {
            if (P127_CYCLE < 8) {
              P127_CYCLE++;
            } else {
              if (  P127_checksum(nameValue, value, checksum) ) {
                eventString = F("Teleinfo#SendData");
                P127_CYCLE = 0;
                P127_sendtoHTTP(P127_HOST, P127_PORT, P127_URL + P127_SendData);
                P127_SendData = "";

              }
            }
          }

          if (eventString.length() > 0) {
            rulesProcessing(eventString);
          }

        }

        success = true;
        break;

      }

  }
  return success;
}

boolean P127_checksum(String valuename, String value, String checksum) {
  String data = "";
  int i;
  char sum = 0;
  char sumchar;
  sumchar = checksum.charAt(0);
  data = valuename + " " + value;
  for (i = 0; i < data.length(); i++) {
    sum = sum + data.charAt(i);
  }
  sum = (sum & 0x3F) + 0x20;

  if (sum == sumchar) {
    return true;
  } else {
    return false;
  }
}


boolean P127_sendtoHTTP(String hostname, int port, String url) {
  char log[80];
  boolean success = false;
  char host[128];

  hostname.toCharArray(host, 128);
  sprintf_P(log, PSTR("%s%s using port %u"), "HTTP : connecting to ", host, port);
  addLog(LOG_LEVEL_DEBUG, log);

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  if (!client.connect(host, port))
  {
    connectionFailures++;
    strcpy_P(log, PSTR("HTTP : connection failed"));
    addLog(LOG_LEVEL_ERROR, log);
    return false;
  }
  statusLED(true);
  if (connectionFailures)
    connectionFailures--;

  url.toCharArray(log, 80);
  addLog(LOG_LEVEL_DEBUG_MORE, log);

  String hostName = host;

  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");

  unsigned long timer = millis() + 200;
  while (!client.available() && millis() < timer)
    delay(1);

  // Read all the lines of the reply from server and print them to Serial
  while (client.available()) {
    String line = client.readStringUntil('\n');
    line.toCharArray(log, 80);
    addLog(LOG_LEVEL_DEBUG_MORE, log);
    if (line.substring(0, 15) == "HTTP/1.1 200 OK")
    {
      strcpy_P(log, PSTR("HTTP : Succes!"));
      addLog(LOG_LEVEL_DEBUG, log);
      success = true;
    }
    delay(1);
  }
  strcpy_P(log, PSTR("HTTP : closing connection"));
  addLog(LOG_LEVEL_DEBUG, log);

  client.flush();
  client.stop();
}
Merci de votre aide.

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#2 Post by gmella » 26 Mar 2020, 18:57

Bonjour,

Je teste depuis quelques semaines mon compteur Linky avec le plugin que tu cites sur lequel j'ai fait pas mal de modifications. C'est stable en remontant même les infos toutes les 20s à mon controlleur domoticz.

Je n'ai pas encore fait de pull request et j'hesite à faire un nouveau plugin. Mais je vais essayer de contribuer un peu plus dans ce super projet qu'est EspEasy.

En attendant voila le code si cela peut servir et relancer les échanges:
https://github.com/gmella/ESPEasyPlugin ... leinfo.ino

Attention comme mentionné c'est en mode STANDARD donc a completer pour supporter les deux modes...

Thanks a lot for ESPEasy ! I enjoy and use it more and more.
Merci aussi à Charles Hallard pour sa lib et autres infos.
Guillaume

guy67400
Normal user
Posts: 11
Joined: 14 Sep 2016, 23:55
Location: Strasbourg

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#3 Post by guy67400 » 02 Apr 2020, 22:10

Hi,

Thank you for your work on Plugin _P127_Teleinfo - I'm interested in this plugin for non-Linky meter (Landis+Gyr meter)
When I try to compile 20200328 (Platformio 4.3.2a1 on VS code), I got following error (not related to P127 plugin):
How did you compile the project ? Would you please be so kind to share the tools / the binary you did use ?

Thank you

******************************************************************************

Bonjour,

Merci pour ce travail. Je suis moi même intéressé par ce plugin utilisé avec un compteur non linky.
Lorsque j'essaye de compiler la version 20200328, j'ai l'erreur :



Submodule path 'tools/sdk/lwip2/builder': checked out '354887a25f83064dc0c795e11704190845812713'
Submodule 'lwip2-src' (https://git.savannah.nongnu.org/git/lwip.git) registered for path 'tools/sdk/lwip2/builder/lwip2-src'
Cloning into 'C:/Users/guy/.platformio/packages/_tmp_installing-apq8gd0u-package/tools/sdk/lwip2/builder/lwip2-src'...
remote: Counting objects: 51280, done.
remote: Compressing objects: 100% (12186/12186), done.
remote: Total 51280 (delta 38698), reused 50936 (delta 38448)
Receiving objects: 100% (51280/51280), 10.06 MiB | 478.00 KiB/s, done.
Resolving deltas: 100% (38698/38698), done.
error: Server does not allow request for unadvertised object 159e31b689577dbf69cf0683bbaffbd71fa5ee10
Fetched in submodule path 'tools/sdk/lwip2/builder/lwip2-src', but it did not contain 159e31b689577dbf69cf0683bbaffbd71fa5ee10. Direct fetching of that commit failed.
Submodule path 'tools/sdk/ssl/bearssl': checked out '89454af34e3e61ddfc9837f3da5a0bc8ed44c3aa'
Failed to recurse into submodule path 'tools/sdk/lwip2/builder'
Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', '--branch', '2.6.3', 'https://github.com/esp8266/Arduino.git', 'C:\\Users\\guy\\.platformio\\packages\\_tmp_installing-apq8gd0u-package']
The terminal process terminated with exit code: 1

Comment avez vous pu contourner ce problème ?
Vous serait il possible de partager le fichier source ? les version de logiciels que vous avez utilisé ?

Merci

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#4 Post by gmella » 03 Apr 2020, 09:34

Hello,

I work on a linux machine using the arduino IDE (arduino-1.8.9). I find it ok for most tries I performed following classical use : load esp8266 platform support and use library manager for most projects.
I never tried Platformio and this may be a good opportunity.

But coming back to my setup to build various espeasy flavors I must be complete giving the whole summary:
  • git clone espeasy repository
  • move, copy or link ESPEasy/src to ESPEasy/ESPEasy so the arduino IDE does not complain when you open the project with ESPEasy/ESPEasy/ESPEasy.ino
  • copy/synchronize ESPEasy/lib content to my main ARDUINO/libraries
Sometimes some libraries build failed on my machine because of the case sensitive filesystem. I just rename files or fix includes and that works arround (ok I miss to notiofy back to author to fix that for others..).

I will be very happy to join a team work with other ESPEasy users. For this time it could be on the support for the HISTORIQUE mode for your Landis+Gyr meter I guess.

All that said, let me know how I can help more.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#5 Post by TD-er » 03 Apr 2020, 10:19

Help is always appreciated.
If you can contribute to help coding, you can always fork the Git repository and create a pull request.

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#6 Post by gmella » 03 Apr 2020, 10:43

Hello TD-er,

That's the plan. I already forked the repo and plan to make a pull request. I replied to guy67400 message and sure we will make a pull request as soon as it is compatible with both mode.

I didn't get in touch with the first author of the plugin I rework but leave some comment in my previous source link . Then I would appreciate comments on two questions:
- should we take a new plugin id in the playground for such rewrite ?
- should we go backward on the part that read the serial data ? instead of using an existing Library

Anyway I put my finger in the machine and will continue to push it now as much as I can. I then wait guy67400' reply

Best regards,

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#7 Post by TD-er » 03 Apr 2020, 11:36

Well the plugin ID's on the playground are not that official.
A general rule of thumb, when you render the settings incompatible, I would suggest a new value (max 255)
If plugins on the playground are good enough and/or useful for others, they will be included in the main repository.

guy67400
Normal user
Posts: 11
Joined: 14 Sep 2016, 23:55
Location: Strasbourg

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#8 Post by guy67400 » 03 Apr 2020, 22:26

Thank you for your reply gmella,

I spend this afternoon following your advices, fighting with arduino IDE compiler and finally I achieved to compile successfully the 20200327 package.

I will now include the P127 plugin, and will come back to you with my findings using the plugin on my hardware (Wemos D1 mini), to monitor my "old" electricity meter.
I will do this in the coming days

Thank you again for your help.

Best regards

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#9 Post by gmella » 04 Apr 2020, 18:32

Hello guy67400,

Nice to see that you get ready to build an espeasy package. I succeeded to test it on both TIC protocols, then performed a pull request on the main repo.
In the mean time, please find my last version on https://github.com/gmella/ESPEasyPluginPlayground , copy it next to ESPEasy.ino ( where I added #define USES_P127 )

Bonne chance !
--
Guillaume

guy67400
Normal user
Posts: 11
Joined: 14 Sep 2016, 23:55
Location: Strasbourg

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#10 Post by guy67400 » 04 Apr 2020, 22:29

Thank you for your latest version.

I succeded to compile previous version with some changes, and try your new filewith similar compilation problems :
My setup :
- I used the package 20200328,
- added P_127 in the ESPeasy/ESPeasy folder,
- #define USES_P127 in plugin_sets.h,
- added https://github.com/marco402/LibTeleinfo ... es/Wifinfo in Libraries
( with "mySyslog.h" and "Wifinfo.h" commented in LibTeleinfo.h)
- hardware is D1 mini, HWserial0 (no serial log)

Compilation errors :
- _P127_Teleinfo:92:26: error: no matching function for call to 'TInfo::init(bool)' tinfo.init(true);
- __P127_Teleinfo:97:27: error: no matching function for call to 'TInfo::init(bool)' tinfo.init(false);
(Compilation is OK if I change tinfo.init(true); to tinfo.init(); and remove the standard mode (just keep my need). I had similar error with previous version )

- _P127_Teleinfo:121:21: error: 'TAILLE_MAX_VALUE' was not declared in this scope char cvalue[TAILLE_MAX_VALUE];
(Compilation is OK if I add #define TAILLE_MAX_VALUE 98 as defined in LibTeleinfo.h . I had similar error with previous version )

I suspect I'm not using the same LibTeleinfo.h file as you do ?

Any way, with the changes I uploaded the bin in a Wemos D1 mini, and will test reception of the Teleinfo data tomorrow.

By the way, what is "I2C adress" and "Channel" in device tack setting ?

Thanks for your support
Regards

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#11 Post by gmella » 05 Apr 2020, 11:07

Hello,

Giving your mention about I2C adress and Channel, I never saw such things. I updated my ESPEasy package. I pulled the head mega branch this morning and I discovered the points. Many changes occured but I succeeded to read again a counter leaving those field with default values but selecting again HW Serial0. This make the proper GPIO selected in GPIO <-TX field. For that I do also have to disable javascript else I was not able to edit the device seting page properly.
I'm sure that these points will be fixed in the future.

On the other part, I also think that your ARDUINO/libraries/LibTeleInfo directory does not include the proper files which must be next files : without #include "mySyslog.h" and #include "Wifinfo.h"
I suspect that you copied these files in the ESPEasy subdirectories but they must be present into the main Arduino libraries. If it is the point, you should be quite near to get a working reader :)

Regards,
Guillaume

guy67400
Normal user
Posts: 11
Joined: 14 Sep 2016, 23:55
Location: Strasbourg

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#12 Post by guy67400 » 05 Apr 2020, 18:41

Hello,

Thank you for the P127 update and your directions.
I succeded to compile and download ESPeasy with P127.

Config :
- D1 mini
- HWserial0 swap (use GPIO13/D7 for serial teleinfo data input pin)
- "send to controler" disabled

Findings :
Connection to the meter, PAPP is updated sometimes once at power up, then no more reading.....it seems ESP8266 is at the edge of speed and memory capability (software crash ?).
When I browse though ESP webpages (my computer connected to ESP though IP adress of ESP), I regularly get the message "Low memory. Cannot display webpage :-("
, and many times there is timeout = no page display.

To go further in analysis of what ESP does,
Is it possible to query the "teleinfo" values using http command to ESPeasy
(for exemple, on Wifiinfo software, It is possible to send the command EspIP:Port/control?cmd=taskvalueset,x,x,%IINST1%)

Regards

Guy

seb82
Normal user
Posts: 62
Joined: 05 Sep 2018, 10:56

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#13 Post by seb82 » 05 Apr 2020, 22:49

@guy67400, the error you get while trying to compile with platformio is due to a change in a library that affects building of core 2.6.3. I believe TD-er even opened an issue about it some months. It was fix but there has not been a stable release since then. You can use the latest version with that change under [core_2_6_3] in plaftformio_core_defs.ini [core_2_6_3]

Code: Select all

platform_packages         =
	;framework-arduinoespressif8266 @ https://github.com/esp8266/Arduino.git
Just remember this is not stable.
The good thing with platformio is that is it a lot faster to compile, which is clearly an advantage when developping (Arduino IDE is supposed to do some kind of cache for the libraries as well but I was never able to make it work under Windows).

For my part, I am using the Wifinfo example with this version of the library : https://github.com/theGressier/LibTeleinfo (compiled with last esp core 2.6.3) with a D1 mini that just fits under the Linky cover.
It has been running perfectly stable for 10 days now - even when accessing the web interface which used to be painfull sometimes - with 34 KB free memory.
This version is for "mode historique", not "mode standard".
Looking at the code for examples for a new project, I must say that Charles Hallard who originally wrote the Teleinfo library did a great job even though this is a few years old now.

@gmella, thanks for your work. It is good to have a working teleinfo plugin for ESP Easy. It could be useful sometime.
Sébastien - espRFLinkMQTT gateway RFLink MQTT on esp

guy67400
Normal user
Posts: 11
Joined: 14 Sep 2016, 23:55
Location: Strasbourg

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#14 Post by guy67400 » 06 Apr 2020, 19:56

Hello seb82
Thank you for your comments.
Indeed I also use wifiinfo for some month now, but one ennoying problem with Wifinfo is that, in case of power failure, my pi3 with domoticz takes some time to setup Wifi AP, and Wifinfo who start fast does not see Wifi AP, does not connect, and there is no rules mechanism (update me if I'm wrong) you can setup to have "auto reconnection" in that case.


Hello gmella
I made some more investigation, and it seems that there is no problem accessing the webpages of Esp_teleinfo, in case the teleinfo data are not received by the wemos D1 mini.
If it can help, I would suggest to use a gating mechanism :
- when Esp_teleinfo need the teleinfo frame, it set one gpio that enable the data input to the serial0 pin
- when the frame has been received, gpio is reset, and this block the data coming to serial0 input.
- this is done at the rate selected to send data to controler - like that ESP is only buzzy receiving serial data when it need them, not all the time.
This could be easely done with one gpio and one diode, connected to serial0 pin (hardware wemos D1 mini + teleinfo adapter using SFH620A)
1st and last byte received by ESPeasy could be corrupted (as the start/stop could happen in the middle of one byte) and the 1st received frame would be corrupted, but the STX/ETX would synchronize the reception on the next full frame

Regards

Guy

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#15 Post by gmella » 06 Apr 2020, 20:52

Hello guy67400,

Not sure to understand why such gating mechanism. I just performed additional test on a D1 mini without any issue. The load is quite low 5% for 10s interval.
The only stop I got in my past tries was the use of software serial reading (I read similar bug that prevent such use).

I think that reading rate must be high enough so the esp can read an loop ever every labels. These are stored in memory and plugin just read the two selected values given the two selected names. With current implementation, I can read default labels (PAPP changes when I connect a load) or other ones ISOUSC...
Here is a sample log line I get In Tools/Log after changing the labem :

Code: Select all

1861523: P127 : Init HISTORIQUE mode 1200_7E1 RX=13 reading ISOUSC,BASE
In any cases, a checksum is performed before storing data so we can trust data without more analysis.

Since HISTORIQUE mode is at 1200bauds, I wonder if putting an higher timeout inside the PLUGIN_TEN_PER_SECOND could help for a better reading and hopefully reduce the load.

Thank you seb82 for your comments. I should give a try to platformio in the future.

From the beginning I think that using an internal serial data reading could help to get a self contained plugin. This could help to move into the standard plugin if it reach acceptance level. I also think that Hallard Lib repo missed a lot of pull request. Anyway, nice to see the community work moving!

I also use a PZEM004 plugin to monitor my PV production. I hope to get a single ESP8266 able to read multiples PZEM and my Linky.

Kind regards,
Guillaume

seb82
Normal user
Posts: 62
Joined: 05 Sep 2018, 10:56

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#16 Post by seb82 » 06 Apr 2020, 21:38

@guy67400, yes indeed I got the same issue at startup with Wifinfo. For the time being I added a delay before wifi startup:

Code: Select all

// start Wifi connect or soft AP
  delay(60000); // XXX délai avant connexion wifi pour laisser démarrer le routeur
  WifiHandleConn(true);
Not a very nice fix but it works well (and I can also cut the power supply of my D1 mini hosting Wifinfo).
I plan to look at the wifi part of the code deeper for another project so maybe I will be able to figure out why it does not reconnect. Unless I decide to use some of ESP Easy code :D
Sébastien - espRFLinkMQTT gateway RFLink MQTT on esp

guy67400
Normal user
Posts: 11
Joined: 14 Sep 2016, 23:55
Location: Strasbourg

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#17 Post by guy67400 » 07 Apr 2020, 05:29

Hello seb82
Thank you for this fix - I will implement it if I can not get ESPinfo to work as expected

Hello gmella
From your log record, I guess that your mains is mode "monophasé" => total byte on the teleinfo frame around 120 - 140 bytes

My mains is "triphasé" + "Hc/Hp" => total bytes on teleinfo frame 251 bytes ( I made some records of the frames to verify this number)

Could this difference explain the problem I have ?
Should I change some items in the source ? 'TAILLE_MAX_VALUE' ?
( I have very basic software knowledge, not able to fully understand the code in P_127 and the code in teleinfo library)

Thank you for your help

Guy

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#18 Post by gmella » 07 Apr 2020, 22:45

Hello guy67400,

I had a quick look on the LibTeleinf forks but have no idea of the issue that can occurs for a triphasé + HC/HP setup.

I performed some minor changes in my Pull Request following TD-er comments, but may think about using back the serial data reading in the plugin without use of LibTeleinfo library.

Anyway since you mention HC HP, I think that this plugin should get more control to read more data, trying also to be compatible with the domoticz P1 smart meter or current amper 3 phases...


It may be nice if you could perform more testing adding log calls . Tools/logging enables the reading over the wifi since we can't use the serial log, nice feature :) ...
Another option could be to run a simple program that just use the LibTeleinfo (now added in my repo...) and print receive data on the other serial line, this to confirm that this library can read the messages of your counter.

Any other ideas ?

guy67400
Normal user
Posts: 11
Joined: 14 Sep 2016, 23:55
Location: Strasbourg

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#19 Post by guy67400 » 08 Apr 2020, 15:10

Thank you spending time to help me.

I tried to change ten_per_second timing as you suggested before but no succes.
I will try the Tools/login as you suggest and the other program to receive and resend teleinfo frame.

In the mean time, here is a short record of a "normal" frame received on teleinfo output of my meter - if it can help...

Regards

Guy

ASCII
"STX"
ADCO 700809412167 D
OPTARIF HC.. <
ISOUSC 20 8
HCHC 016603911 !
HCHP 030345687 7
PTEC HP..
IINST1 001 I
IINST2 001 J
IINST3 000 J
IMAX1 052 7
IMAX2 055 ;
IMAX3 032 7
PMAX 12480 5
PAPP 00400 %
HHPHC A ,
MOTDETAT 000000 B
PPOT 00 #
"ETX"

Same frame in hex :
02 0A 41 44 43 4F 20 37 30 30 38 30 39 34 31 32
31 36 37 20 44 0D 0A 4F 50 54 41 52 49 46 20 48
43 2E 2E 20 3C 0D 0A 49 53 4F 55 53 43 20 32 30
20 38 0D 0A 48 43 48 43 20 30 31 36 36 30 33 39
31 31 20 21 0D 0A 48 43 48 50 20 30 33 30 33 34
35 36 38 37 20 37 0D 0A 50 54 45 43 20 48 50 2E
2E 20 20 0D 0A 49 49 4E 53 54 31 20 30 30 31 20
49 0D 0A 49 49 4E 53 54 32 20 30 30 31 20 4A 0D
0A 49 49 4E 53 54 33 20 30 30 30 20 4A 0D 0A 49
4D 41 58 31 20 30 35 32 20 37 0D 0A 49 4D 41 58
32 20 30 35 35 20 3B 0D 0A 49 4D 41 58 33 20 30
33 32 20 37 0D 0A 50 4D 41 58 20 31 32 34 38 30
20 35 0D 0A 50 41 50 50 20 30 30 34 30 30 20 25
0D 0A 48 48 50 48 43 20 41 20 2C 0D 0A 4D 4F 54
44 45 54 41 54 20 30 30 30 30 30 30 20 42 0D 0A
50 50 4F 54 20 30 30 20 23 0D 03 then next frame
02 0A

guy67400
Normal user
Posts: 11
Joined: 14 Sep 2016, 23:55
Location: Strasbourg

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#20 Post by guy67400 » 08 Apr 2020, 18:36

Hello gmella,

I loaded your last revision plugin, and now the frames are correctly received - I checked all the labels in my teleinfo frame :
- all labels with value = number , are correctly received
- labels with value = ascii characters display "0" for example "OPTARIF HC", or "PTEC HP"
The log (tools/log) show same OPTARIF 0 PTEC 0
=> it seems the teleinfo library that we use does not properly store ascii characters in the "value" field

Anyway, thank you for your support - I see the light at the end of the tunnel...

Guy

Are you going to update the plugin to make more than 2 labels/values available ?

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#21 Post by gmella » 08 Apr 2020, 19:14

Hey good news guy67400!

In the mean time I just discovered the /timingstats url. You may also check that calls are properly performed having a look using Tools->Timing stats and especially on the TEN_PER_SECOND line for the TIC plugin.
Did you still get heavy load on your esp ?

You are right about non numeric values. These issue is related to my plugin code which always perform an atoi to convert values into numeric values.
That could be nice to be able to read such string values but I need to learn more how to code plugins. I think that other feature could get higher priorities.

TD-er also merged my code in the main plugin playground repo after putting the Teleinfo code copy into + some minor changes.

Thanks to you great feedback, I'm then very motivated to continue this work and get other experiences (seb82 ? :D ) for more test and improve this plugin. If we continue to use the LibTeleinfo library fork (there are pros and cons), it could be nice to put it back to the original repository of Charles Hallard. I could start to contact on github marco402 to provide some small feedback since this make me very happy to receive info from my Linky on STANDARD mode. The current implementation cover my need!


Et donc :) , What would be your change requests to cover your use cases ?

Well done guy67400! Thx again to the ESP Easy authors!
Regards,
Guillaume

guy67400
Normal user
Posts: 11
Joined: 14 Sep 2016, 23:55
Location: Strasbourg

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#22 Post by guy67400 » 08 Apr 2020, 23:06

Hi gmella,
Your job is really impressive....as you will see in this follow up....

My need is to have the values of 6 labels sent to domoticz.
Before using Espeasy/Teleinfo, I used domoticz script to querry Wifinfo and got a json "package" with the whole teleinfo frame.

With your tremendous plugin, I created 3 task in ESPeasy, each with "Energy - Teleinfo Power Energy [TESTING]" device - total 3 teleinfo devices running in //, each with 2 labels out of,
PAPP, IINST1 IINST2,IINST3 HCHC,HCHP. I then use rules to "SendToHTTP" those values to Domoticz every 30s.

This is perfectly working. Load is about 3X the load if only 1 device ("TEN_PER_SECOND" runs 30 call/s , average duration 2ms) - makes ESP load (System info) = 13.4%

Imaginais tu que quelqu'un serait assez fou pour essayer ca ???

Your plugin perfectly feed my needs !
Encore merci

Guy

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#23 Post by gmella » 09 Apr 2020, 19:39

Hi guy67400,

Oh what a good news! I thought about such future usage as mentioned in the original code comments but did not imagine to test it before more work. This pluginPlayground is very nice to experiment these building blocks in a such ESPEasy way !

I suppose that we can get the same feature but leave only one device run the serial data reading. This would then limit the total CPU load quite equals to a single device. I tried to loop over the /json url to monitor required resources of the plugin and will try to put some numbers. I will also look on the way how to make this plugin documentation. All of what has been gathered in _Pxxx_PluginTemplate.ino guidelines.

We are in good shape. Thank you for your experiment and feedback!

Regards,
Guillaume

seby90
New user
Posts: 5
Joined: 10 Jun 2020, 13:10

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#24 Post by seby90 » 10 Jun 2020, 13:47

Bonjour gmella,

j'aimerais utiliser ton plug in 127 en apportant des modifs pour envoyer les données sur domoticz mais en utilisant un compteur P1 Smart Meter.
J'ai quelques connaissances minime en programmation et je débute sous esp easy.
Le P1 Smart meter possède 4 différent compteur , ce qui est interessant quand tu es en contrat HP/HC . Le codage utilisé est celui ci dessous.
p1 smart meter.JPG
p1 smart meter.JPG (55.77 KiB) Viewed 21026 times
J'ai un linky et pour l'instant ma TIC est en mode historique et je tente de faire des essais pour remonter uniquement le compteur HP et HC. Dans le futur, je demanderais un passage de ma TIC en mode standard, qui va me permettre de récupérer mon compteur HP, HC et le compteur d'injection (car je suis en autoconso avec une petite installation photovoltaique). On peut aussi remonter la puissance apparente, mais aucun intérêt pour nous consommateur car c'est la puissance active qui nous est facturé..
A la base, ton code n'envoit que 2 type de données, soit l'état du compteur de base et la puissance apparente.

Je me suis lancé dans une modif de ton plugin. J'ai déclarer 6 variables pour l'historique et pour le mode standard
declaration variable.JPG
declaration variable.JPG (36.49 KiB) Viewed 21026 times
J'ia modifié aussi le plug in device, notamment te permettant de capturer 6 différentes données. J'ai modifié la partie v_type qui d'origne état en "dual" et je l'ai passé en "quad" mais je pense que je me trompe sur ce sujet....
plug in device.JPG
plug in device.JPG (36.64 KiB) Viewed 21026 times
puis également ces modif
plugin_get_device.JPG
plugin_get_device.JPG (39.64 KiB) Viewed 21026 times
modif1.JPG
modif1.JPG (32.61 KiB) Viewed 21026 times
modif2.JPG
modif2.JPG (38.32 KiB) Viewed 21026 times
et la partie finale ou j'ai mis pas mal de chose en commentaire pour l'instant car j'ai eu des soucis de rafraichissement

Via le log,je vois que j'arrive à récupérer les 6 données qui m’intéresse par le plug in, mais le contrôleur n'envoit vers mon domoticz que 2 valeurs. Ca doit être super bête, et je pense qu'il suffirait de modifier un autre fichier , si tu sais m'éclairer ca serait super sympa.
Attachments
commentaires.JPG
commentaires.JPG (135.81 KiB) Viewed 21026 times
Last edited by seby90 on 10 Jun 2020, 14:14, edited 1 time in total.

seby90
New user
Posts: 5
Joined: 10 Jun 2020, 13:10

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#25 Post by seby90 » 10 Jun 2020, 13:50

Je n'arrivais pas à poster plus de vue. Voici une copie écran du log qui est assez parlant. On voit les 6 données récupérer par le plug in, et on voit que le controleur n'en envoit que 2
log esp easy.JPG
log esp easy.JPG (17.58 KiB) Viewed 21025 times
Voici une copie sous écran sous domoticz. La ligne du bas est celle transmisse par esp easy avec ma modif, et je cherche a envoyer comme la ligne du haut...
capture_domoticz.JPG
capture_domoticz.JPG (13.67 KiB) Viewed 21025 times
D'avance merci pour ton aide

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#26 Post by gmella » 10 Jun 2020, 14:54

Salut seby90,

Sympa de voir tes modifs!
A première vue, j'aurai tendance à penser qu'il te suffit de remplacer event->sensorType = SENSOR_TYPE_DUAL par event->sensorType = SENSOR_TYPE_QUAD dans le switch pour PLUGIN_READ.
J'avoue qu'en relisant ton post, je me suis demandé pourquoi j'avais mis dans la partie PLUGIN_DEVICE_ADD DEVICE_TYPE_SINGLE. Probable que l'on puisse améliorer cette cohérence. Tu peux donc certainement essayer de "simplement" supprimer ma ligne qui affecte event->sensorType.

Je ne me suis pas remis sur ce plugin, mais je me suis dit qu'il reste encore de quoi l'améliorer en me demandant s'il ne devrait pas être mieux concu pour lire N etiquettes que l'on pourrait choisir avec des listes déroulantes correspondant à celles définies dans la librairie LibTeleInfo...

Mais si ca marche chez toi avec ton code on peut aussi voir pour faire une première version intermédiaire. Ce serait une première étape pour aller dans cette direction et inclure également le cas comme guy67400 en triphasé.

Bref, pour l'instant je suis curieux de voir si ca marche mieux en enlevant une ligne de code ;)
A+

seby90
New user
Posts: 5
Joined: 10 Jun 2020, 13:10

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#27 Post by seby90 » 10 Jun 2020, 15:50

encore merçi pour ton retour rapide, c'est cool !

Oui effectivement, on peut ameliorer le code et pouvoir chosir n etiquettes et envoyer ce que l'on désire. Mais j'avoue qu'à cet instant précis, je n'aurais pas les compétences d'y arriver seul. :P

Après mes modifs sont basiques et non pas de mérite. J'essaye de m'adapter au plus simple que tu as déjà fait et je débute sur ce type de programmation ;)

A l'occurence, tu devras essayer mais sur Domoticz , le P1 Smart Meter est vraiment mieux que les autres compteurs. J'ai tester les compteurs avec seulement 2 entrées ( dont l'utilisation de la puissance apparente )et le graphique n'est pas du tout réaliste à la vrai consommation facturée. D'ailleurs je comprends pas pourquoi la puissance active n'a jamais été utilisé sur la TIC...

Sous domoticz, le fait d'utiliser le P1 Smart Meter, sur la dernière période de 24h, pour chaque compteur il regarde le nombre de Wh qui passe durant les 5 dernières minutes et te recalcule une puissance active (donc puissance facturée) durant ce créneaux. Je trouve cela beaucoup plus précis. Puis ensuite comme les autres compteurs, te relève une conso en Kwh journalière etc... Et ca permet d'avoir 4 compteur imbriqué dans la même ligne de commande

J'ai donc fait cette modif (mise en commentaire de la ligne event->sensorType
modif3.JPG
modif3.JPG (25.07 KiB) Viewed 21013 times
Il y a du mieux, mais je n'envoie que 4 données au lieu des 6
log_easy2.JPG
log_easy2.JPG (21.26 KiB) Viewed 21013 times
Si tu as une autre idée, je suis preneur :D

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#28 Post by gmella » 10 Jun 2020, 17:01

Oups, j'ai lu un peu vite.
Pour l'instant la remontée par domoticz (en HTTP) semble limitée à 4 valeurs max. Il faudrait donc construire une chaine dans le plugin pour ce mode particulier. On commence à avoir bcp de combinaisons (HISTO/STD x HC/HP x MONO/TRI) . Actuellement tu peux donc faire un peu comme guy67400 plus haut dans ce fil en utilisant SendToHTTP.

Mais c'est vrai que tout mettre dans le plugins permettrai de tirer le benefice d'un affichage sympa dans domoticz avec une mise en place très simple sur espeasy en s'appyant sur les controleurs.

Pour la suite, je veux bien continuer à améliorer le plugin avec toi. Je suis bien occupé les 2 prochaines semaines, mais n'hésites pas à relancer ensuite...

Merci pour les tests!

seby90
New user
Posts: 5
Joined: 10 Jun 2020, 13:10

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#29 Post by seby90 » 11 Jun 2020, 12:02

En fouillant dans le code, je me suis vite aperçut qu'on était limité à 4 valeurs max.
Ne connaissant pas le code à écrire pour envoyer de simple demande HTTP, du coup, j'ai créer un SENSOR_TYPE_P1METER avec 6 valeurs.
J'ai également fait des modifs simple afin d'envoyer 0 dans les cellules qui ne nous intéresse pas car donc mon cas, pour l'instant, j'utilise que le compteur HP, HC, et la puissance PAPP .
J'ai fait la demande pour basculer en mode standard , on verra demain, si je remonte bien le compteur d'injection
Je suis partant pour participer à de futures modifs propre car pour l'instant, j'ai fait à "l'arrache" :lol:

As I searched through the code, I quickly realized that we were limited to a maximum of 4 values.
Not knowing the code to write to send a simple HTTP request, so I created a SENSOR_TYPE_P1METER with 6 values.
I also made some simple modifications to send 0 in the cells that doesn't interest us because in my case, for the moment, I only use the HP, HC, and PAPP power.
I made the request to switch to standard mode, we'll see tomorrow, if I put the injection meter back up.
I'm ready to participate in future clean modifications because for the moment, I've been working hard on :lol:
Last edited by seby90 on 11 Jun 2020, 15:57, edited 1 time in total.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#30 Post by grovkillen » 11 Jun 2020, 12:31

Please post in English for the rest of the world to read...
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

seby90
New user
Posts: 5
Joined: 10 Jun 2020, 13:10

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#31 Post by seby90 » 12 Jun 2020, 11:51

Sorry about my English, I'll do what I can.

Standard mode on my linky has been activated. I have "EASF02" which is my full hour meter, "EASF01" which is my off-peak meter, "EAFS08" which is the 08 meter which is not used by the linky (meter has 0 which suits me) "SINSTS" which is the instantaneous apparent power. It is its well read and recognized, but on the other hand, I do not manage to obtain the value EAIT which is the injected power meter (which interests me the most), and SINSTI which is the instantaneous apparent apparent power.

After I realize that I don't lose moment EASF01 or 02, there must be a problem with the PLUGIN on 6 values? Is it a problem of reading order ?? Is there an easy way to make a real log of the input serial port on pin d7 of the wemos ?

--

désolé pour mon anglais, je vais faire ce que je peux.

Le mode standard sur mon linky a été activé. J'ai "EASF02" qui est mon compteur heures pleines , "EASF01" qui est mon compteur heures creuses, "EAFS08" qui est le compteur 08 qui est non utilisé par le linky (compteur a 0 ce qui m'arrange) "SINSTS" qui est la puissance apparente instantanée. Elle est son bien lu et reconnu, mais en revanche, je n'arrive pas à obtenir la valeur EAIT qui est le compteur puissance injecté (qui m’intéresse le plus), et SINSTI qui est la puissance apparente instantanée apparente.

Après je m'aperçoit que je perds pas moment EASF01 ou 02, il doit y avoir un soucis avec le PLUGIN sur 6 valeures ?? Est ce un problème d'ordre de lecture ?? Y a t il un moyen facilement de faire un vrai log du port série en entrée sur la pin d7 du wemos ?

log_espeasy3.JPG
log_espeasy3.JPG (15.47 KiB) Viewed 20930 times

gmella
Normal user
Posts: 13
Joined: 26 Mar 2020, 18:37

Re: ESP8266 rapport erreur Plugin _P127_Teleinfo

#32 Post by gmella » 12 Jun 2020, 16:00

Hi,
I think that most of the issues are not related to EspEasy but to the protocol of the linky in your special case. I also have a solar power in the simple auto-consommation mode and notice that the values during injection are left to 0 :( Then I tried to build a PV-router plugin on EspEasy but this was not reliable enough using the hardaware interruptions. And A/D converter is not so good by default to get a reliable power meter in addition to the reading of the Linky. Workarround was to use PZEM004 plugin to monitor my PV production. But I also now have a running PV-router using an arduino.


Coming back to the Teleinfo plugin, we can take the opportunity of seby90 new come to enhance the support of various configurations as far as possible.

Then here is a first question to the world who read it ;) . Since we have a plugin that would require to report more than 4 values (6 in both use cases of seby90 and guy67400) using a controler, what is the best option to support that in a plugin .
1/ extend SENSOR_TYPE list with SENSOR_TYPE_SEXTUPLE and modify every controllers ?
2/ prefer a fallback to SENSOR_TYPE_STRING and then handle param part building inside the plugin ?
3/ use another smarter technic ?


We plan to continue experiment plugin updgrade and will PR the result in the plugin playground so this plugin can cover wider use cases without use of multiples tasks + SendToHTTP .

Cheers,

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests