Giter Club home page Giter Club logo

p1-meter-esp8266's People

Contributors

basvdijk avatar jantenhove avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

p1-meter-esp8266's Issues

CRC16 fails

My Arduino project receives the messages just fine, however the telegram fails the CRC check. Any thoughts on why it would fail?

New srm5.0 meter sends out telegrams without delay.

Hi,

I have been trying this project with and esp01 and my slimemeter iskra smr 5.0 am550-ED1
Where every one says the p1 spits out a telegram every 10 seconds my seems to spit it out non stop.
This seems to make my esp01 crash in about 10 minutes (overheating?) and I have trouble reading the results.
I tried adding an opto coupler and driving it by pulling gpio0 low to set RTS high via 3.3v -> 220K -> pc817 -> gpio0
This sort or works. When RTS is high P1 starts spitting out stuff but it looks incomplete?
But I don't know when to set high and low?
Is a telegram online one line? Or if a telegram one set of lines?
Should I put RTS Low directly after seting it high or wait for the readtelegram loop to finish?
But I had situation it just kept running for a minute and then go low. and sometimes I missed the fasctI set it high.

Here is my version of readTelegram:

`void readTelegram() {
  // DTR is gpio0 and should be pulled low to set RTS high. 
  unsigned long now=millis();  
  if ((unsigned long)(now - lasttelegram) >= 5000) {lasttelegram=now;} else {return;} // only run once every 5 seconds.     
  TIMES1++;  // count the times set RTS was set high.
  digitalWrite(DTR,LOW); // Trigger a telegram (RTS)
  delay(20); // Do we even need a delay?
  if (mySerial.available()) {
    memset(telegram, 0, sizeof(telegram));
    while (mySerial.available()) {
      // digitalWrite(DTR,HIGH); //Should I set RTS Off again> 
      int len = mySerial.readBytesUntil('\n', telegram, MAXLINELENGTH);
      telegram[len] = '\n';
      telegram[len+1] = 0;
      yield();
      if(decodeTelegram(len+1))
      {
         UpdateElectricity();
         //UpdateGas(); // I have no gas. 
      }
    }     
  }
  TIMES2++; // Count the number of times RTS was set LOW. 
  digitalWrite(DTR,HIGH);
}`

At the start of decodeTelegram I log the received data via a post request to my local webserver. I cannot get Serial and Software Serial to work together so I have no other way to log. Maybe this takes to much time and makes the readTelegram to miss data?

bool decodeTelegram(int len) {
  koffiepost(telegram);
  etc...


void koffiepost(char* message)
  {
  String postData="LOW "+String(TIMES1)+"HIGH "+String(TIMES2)+"log="+String(message);
  String address = "http://192.168.0.1/dmation/esplog.html"; 
  HTTPClient http; 
  http.begin(address); 
  http.addHeader("Content-Type", "application/x-www-form-urlencoded"); 
  auto httpCode = http.POST(postData); 
  String payload = http.getString(); 
  http.end();    
  }
  

Some of the output I got. (it seems to only do 3 ort 4 lines and than restarts)

1-3:0.2.8(50)
0-0:1.0.0(200814002323S)
0-/ISK5\2M550E-1013

1-3:0.2.8(50)
0-0:1.0.0(200814002328S)
0-0:96.1.1(4530303533æ
/ISK5\2M550E-1013

1-3:0.2.8(50)
0-0:1.0.0(200814002333S)
0-/ISK5\2M550E-1013

1-3:0.2.8(50)
0-0:1.0.0(200814002338S)
0-0:96.1.1(4530303533þ

Any suggestion in what I could try to get my iskra smr 5.0 am550-ED1 to work with the esp01 and domoticz?

No serial output, yet meter sends data

Hi @jantenhove,

I have tried this project and it seems great, because no extra components such as resistors seem needed.

Unfortunately, my ESP (Wemos D1 Mini) does not receive any data from the smart meter. I suspect the bug is somewhere in SoftwareSerial, because when I connect the RxD pin to the TX pin, the Arduino serial console shows garbage every 10s, so the meter seems to send data.

My wiring is the same as your example. I've created simpler code to troubleshoot further:

#include <SoftwareSerial.h>

#define MAXLINELENGTH 64
#define PIN_RX D5

#define BAUDRATE 115200

SoftwareSerial softSerial(PIN_RX, -1, true, MAXLINELENGTH);

void setup() {
  
  Serial.begin(BAUDRATE);
  softSerial.begin(BAUDRATE);
  
  Serial.println("Running at baudrate " + (String)BAUDRATE + " and RX pin " + (String)PIN_RX + "...");
}

void loop() {
  if (softSerial.available()) {
    Serial.write("Available");
    Serial.write(softSerial.read());
  }
}

Apart from the Running at baudrate 115200 and RX pin 14... message, nothing happens. When I manually disconnect GND, Available can be read so the SoftSerial interrupts seem to be handled correctly.

I'm at a loss here! Is there anything I'm doing wrong?

Bug around MessageCRC

Hi Jan,
I think there is a bug in your sketch.
This:

    char messageCRC[4];
    strncpy(messageCRC, telegram + endChar + 1, 4);
...
    validCRCFound = (strtol(messageCRC, NULL, 16) == currentCRC);

Should be:

    char messageCRC[5];
    strncpy(messageCRC, telegram + endChar + 1, 4);
    messageCRC[4] = 0;
...
    validCRCFound = (strtol(messageCRC, NULL, 16) == currentCRC);

This will probably reduce a lot of "Invalid CRC" messages ;-)

connect to meter

Hi,

I just found this arduino/esp-sketch and it is kind of what I'm looking for. Thanks!
But I could not find out how to connect the esp8266 to my smart meter. Can you give me some information or picture about that?

Thanks in advance!

Garbage output on Serial

Trying to replace a RaspberryPi with ser2net with a NodeMCU module with this sketch to report P1 meter readings.

Connected the P1 Meter as described in the Readme. Compiled and flashed the sketch succesfully. NodeMCU module is connecting to the configured WiFi. On the Serial output I just see blocks of "garbage" data though. They appear every 10s, which indicates it is displaying the telegrams.

No other output on Serial. Any ideas?

Is this still active?

Hello,

I am new here and I experience some problems using it.
I always encounter invalid CRC (which I can simly ignore).
A telegram does not arrive every 10 seconds but continuously.
What am I doing wrong?

Many thanks in advance
Ralf

ESP8266 NodeMCU Softserial error

Arduino IDE version: 1.8.10
Softserial version: 6.7.1

//14 = D5 on NodeMCU
SoftwareSerial mySerial(14, -1, true, 128); // (RX, TX. inverted, buffer)

exit status 1
no matching function for call to 'SoftwareSerial::SoftwareSerial(int, int, bool, int)'
also:
Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\SoftwareSerial\src/SoftwareSerial.h:94:5: note: candidate expects 3 arguments, 4 provided

Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\SoftwareSerial\src/SoftwareSerial.h:90:5: note: candidate expects 0 arguments, 4 provided

Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\SoftwareSerial\src/SoftwareSerial.h:94:5: note: SoftwareSerial::SoftwareSerial(int8_t, int8_t, bool)

 SoftwareSerial(int8_t rxPin, int8_t txPin = -1, bool invert = false);

Graag in contact komen

Beste Jan ten Hove,

Ik zou graag met u in contact komen, maar zag zo geen andere manier om u te bereiken, vandaar via deze weg. Voor een project waar ik aan werk ben ik opzoek naar efficiënte software om diverse P1-poorten/slimme-meters uit te lezen en kwamen via via bij uw Github profiel terecht.

Zou u contact met mij willen opnemen zodat ik dit verder kan toelichten? Dit kan via [email protected] ?
Ik hoor graag van u!

Met vriendelijke groet,
Roel Oortgiesen

Issues with CRC

Have connected my 5.0 smart meter to an esp8266 and drop the output in a Google sheet in the cloud. I use your smart meter code to retrieve the data, Initially I used an older version of your code with disabled CRC. As now and then I have misreadings (?) I want your latest code ( without changes except the telegram[MAXLINELENGTH] ) but it's seams that the CRC is not working correct. ( no match at all) I did some tests with simple strings like 123 and this is working. I'm the first one with this issue?

Solution for variables witout star (like current tariff)

A function which you can use to read variables without a *.

long getValueWithoutStar(char* buffer, int maxlen) {
  int s = FindCharInArrayRev(buffer, '(', maxlen - 2);
  if (s < 8) return 0;
  int e = FindCharInArrayRev(buffer, ')', maxlen - 2);
  if (e < 0 || e <= s) return 0;
  int l = e - s - 1;
  char res[16];
  memset(res, 0, sizeof(res));

  if (strncpy(res, buffer + s + 1, l)) {
    if (isNumber(res, l)) {
      return atof(res);
    }
  }
  return 0;
}

No data from Iskra SMR 5.0 AM550-ED1 with Wemos D1

At first: thanks for the clear instructions and sketch!
I didn't get output from my meter at first, but read something about adding resistors here (Dutch).
image
Since SoftwareSerial takes care of the inverted signal I just placed a 10k resistor between 5V+ and the data-line, which made it work!
So not really an issue anymore, but maybe someone has the same problem :) I'll close it right away.

Multiple errors in sketch compile

Hi,

Thanx for this great code many thanx.. whem i'm trying to compile it i get this errors:

P1Meter.ino: In function 'bool SendToDomo(int, int, char*)':
P1Meter:107: error: 'HTTP_CODE_OK' was not declared in this scope
P1Meter:114: error: 'class HTTPClient' has no member named 'errorToString'

don't know how to solve this.

thanx in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.