@lxz which version of the arduino IDE did you use?
It is recommended to stay with 1.6.5 at the moment.
-
reading smart meter P1-port with esp8266
pimatic rocks!!!
-
I’m using this one: https://github.com/adamvr/arduino-base64, I’ll include it this weekend. ESPimatic uses the same.
Just remembered: you will need to change base64.cpp line 2: remove avr/ so line 2 becomes#include <avr/pgmspace.h>
I think I am using 1.6.6 of the IDE. -
I was missing the time library so I downloaded https://github.com/PaulStoffregen/Time, it works now
Follow my domotica project on http://maredana.nl
-
Good to hear that, I think the time library can also be installed via the arduino library manager.
Just pushed another update to make sure the floating point -> string conversion gets 3 decimal digits. -
Just tested my latest additions: the strings are now sent with 3 decimals and I added the Base64.h and .cpp files.
I am using the VariablesDevice which works fine now, the numbers are transferred correctly.
Just a little note: I tried to put all measurement values under one VariablesDevice, but when viewing the values pimatic/the database becomes horribly slow. So I split them again (as they already were before) and things work fine{ "id": "verbruik", "name": "Huidig elektriciteitsverbruik", "class": "VariablesDevice", "variables": [ { "name": "verbruik", "expression": "$mEAV", "type": "number", "unit": "kW", "discrete": true, "acronym": "Actual Electricity Consumption" } ] }, { "id": "tellerlaag", "name": "Meterstand laag tarief", "class": "VariablesDevice", "variables": [ { "name": "meterstand", "expression": "$mEVLT", "type": "number", "unit": "kWh", "discrete": true, "acronym": "Electricity Consumption Low Tariff" } ] },
-
It does compile properly now, thanks.
However, my cable is bricked somehow.Do you guys use an RJ11 connector with 4 or 6 pins?
-
RJ11 connector has 6 slots per definition, though mostly the inner 4 are connected. I use 3 of them, to keep things clear.
-
I finally had the time to give this all a try, but I’m not sure what it is I’m doing wrong.
The esp8266 is booting and connecting to my wifi, but after that it’s only garbage/Chinese on the serial output.
Any idea what it could be? I already changed the RJ11 cable twice
-
Maybe the baudrate is wrong. 115200 seems to be good but when its wrong you get garbage output.
Please check 9600 baud. -
That might be the baud rate indeed, or an inversion of the signal might be needed. Which meter are you using?
-
My meter is a Kaifa MA105C. Which do you have?
Baud rate is not the issue I guess, because I’ve tried multiple settings and only with 115200 at least some text is readable.
-
I’m using a Landis+Gyr E350.
According to this list: https://gathering.tweakers.net/forum/list_messages/1629675 the entry for the Kaifa MA105C shows:
Merk: Model: Type: Uitvoering P1 poort: DSMR versie: Seriële instellingen: Geïnverteerd signaal? P1 telegram header: Kaifa MA105C 1-fase kleinverbruik RJ-11, 6-pins 4.2.2 115200 8N1? Ja? /KFM5
So the 115200 baud is correct, but the signal probably needs to be inverted. Have you tried that already?
It can easily be done with a transistor/FET (BS170 for example) and a resistor, or you can try to use the SoftSerial approach witch can provide the inversion by software; in the example I provided the inversion is already set to true (line 70):
SoftwareSerial mySerial(SERIAL_RX, -1, true, MAXLINELENGTH); // (RX, TX. inverted, buffer)
-
Yes, I tried the softwareserial approach, since I have no BS170 yet. Maybe I’m using the wrong version of the library.
Anyway, I will try to get a BS170 from the local hardware store. -
Remember that you will need to put the input to another pin (i.e. D5 instead of Serial RX) when using the SoftSerial. I haven’t tested with it though, had some library problems with it and the hardware serial works fine for me.
edit: Just found a minor issue while chatting with lxz… this is the software serial library needed: https://github.com/plerup/espsoftwareserial
-
I also have the KAIFA MA105C will make some time to test it
Follow my domotica project on http://maredana.nl
-
I tried it but I get an invallid crc error, when changing the inverted to false I get garbage.
`
After adding this to void setup(void)mySerial.begin(115200);
and inverted to true I get
/KFM5KAIFA-METER 1-3:0.2.8(42) 0-0:1.0.0(160303175112W) 0-0:96.1.1(4530303235303030303230303932343134) 1-0:1.8.1(002371.377*kWh) 1-0:1.8.2(002489.293*kWh) 1-0:2.8.1(000000.000*kWh) 1-0:2.8.2(000000.000*kWh) 0-0:96.14.0(0002) 1-0:1.7.0(03.135*kW) 1-0:2.7.0(00.000*kW) 0-0:96.7.21(00009) 0-0:96.7.9(00007) 1-0:99.97.0(2)(0-0:96.7.19)(150916091547S)(0000000184*s)(0001010 00001W)(2147483647*s) 1-0:32.32.0(00000) 1-0:32.36.0(00000) 0-0:96.13.1() 0-0:96.13.0() 1-0:31.7.0(013*A) 1-0:21.7.0(03.120*kW) 1-0:22.7.0(00.000*kW) !0DD1 ===INVALID CRC FOUND!===
Going to test some more later
It’s not sending the data I asume it’s because the invallid crc?Follow my domotica project on http://maredana.nl
-
Yes indeed, it calculates the CRC and compares it with the CRC it received (0DD1 in your case). If it does not match it considers the telegram invalid and discards it (it also does not update your values).
Don’t know why the CRC is false though, the telegram looks quite ok at first sight.Just found a handy tool; a CRC calculator: http://www.scadacore.com/field-applications/programming-calculators/online-checksum-calculator
I copy-pasted the message above into is (don’t forget to remove the return on the line with 1-0:99.97.0(2)…)
The CRC seems to be correct (CRC-16-IBM, Little Endian): 0DD1Removing the return got me suspicious, the line is quite long. Looking at the code at line 66/67:
#define MAXLINELENGTH 64 // longest normal line is 47 char (+3 for \r\n\0) char telegram[MAXLINELENGTH];
The mentioned line in the telegram is way longer, so the tail of the line will be dropped I guess. Try increasing the MAXLINELENGTH to for example 128, I am quite sure it will solve this problem
I already updated my code on GitHub
-
Thanks!
With your new version and addingmySerial.begin(115200);
it works perfectly!
-
Rene: today we got a Kaifa and I immediately tried to connect my ESP with your ESP8266-P1-transmitter code.
Is use softserial library as you suggested and MAXLINELENGTH 128.
I get only garbage output and error:
===INVALID CRC FOUND!===
Ð(ü(Hý9HX)ü8ˆü8˜ü8Šü8ˆü8ð((9Ô8è0pý!(øþ8Ð8Ð8Ô8Ð8Ð9Ð8ÿü8ÿü0è0è1è0909098989890ø8x)ü0Z øñAny idea how to debug or solve this?
Already thanks,
Cees -
Did you uncomment all lines to use softserial, i.e. also
mySerial.begin(115200);
at line 483 and verify the baud rate is correct for your meter?
Can you please also check the type of your meter, probably a MA105C? In that case the 115200 should be OK.