Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISKRA MT381 energy meter compatibility #4

Open
MatejsLab opened this issue Jun 3, 2023 · 4 comments
Open

ISKRA MT381 energy meter compatibility #4

MatejsLab opened this issue Jun 3, 2023 · 4 comments

Comments

@MatejsLab
Copy link

Hi, this project seems interesting, I am planning to integrate the Iskra energy meter into Openhab.

How do I know if my energy meter is compatible with your software?

My meter has IR ports with a magnet ring, but the model seems different.

image

I actually already measure just current with CTs to prevent overloads of mains fuses.

I would like to send the 15-minute consumption, active tariff, and warning flag "grid transformer overload" if it exists.
Our electric company set up a new plan with 5 tariffs and 3 of them change in a day, 2 are winter and 2 are summer only, and one is the baseline. I could guess with Openhab based on time what tariff is on but it is cheating it may be false.

Now they announced a new flexible contract where you get a cheaper tariff if you turn off loads at peak demands, but it is dumb as they expect me to fiddle with unplugging devices manually in 15 minutes when I get an SMS or Mail to get a bonus. I have openhab to do this, to manage with dryers and boilers w smart plugs and dial down smart heating.

Maybe just point me out if smarting the energy meter is useful for that, or it cant be smartened to tell that grid load indicator and my 15-minute energy rate that my energy company talks all over the place that smart meters can do but not how I can use it to control my smart heating for example.

Thanks in advance
Matej

@wdoekes
Copy link
Owner

wdoekes commented Jun 6, 2023

Hi Matej,

Cool that you're considering using this.

How do I know if my energy meter is compatible with your software?

You don't =)

On the internet, I found a me162_technical_description.pdf PDF:

ME162
Single-Phase Electronic Meter
Technical Description
Version 1.1, 02.06. 2006

With among others this text:


image


The relevant bits are documented at the top:

/**
* pe32me162ir_pub // Talk to optical port of ISKRA ME-162, export to MQTT
*
* Components:
* - ISKRA ME-162 electronic meter with optical port
* - a digital IR-transceiver from https://wiki.hal9k.dk/projects/kamstrup --
* BEWARE: be sure to check the direction of the two BC547 transistors.
* The pictures on the wiki have them backwards. Check the
* https://wiki.hal9k.dk/_media/projects/kamstrup-schem-v2.pdf !
* - ESP8266 (NodeMCU, with Wifi) _or_ an Arduino (Uno?). Wifi/MQTT publish
* support is only(!) available for the ESP8266 at the moment.
* - attach PIN_IR_RX<->RX, PIN_IR_TX<->TX, 3VC<->VCC (or 5VC), GND<->GND
* - (optional: analog light sensor to attach to A0<->SIG (and 3VC and GND))
*
* Building/dependencies:
* - Arduino IDE
* - (for ESP8266) board: package_esp8266com_index.json
* - (for ESP8266) library: ArduinoMqttClient
* - (for Arduino) library (manually): CustomSoftwareSerial (by ledongthuc)
*
* Configuration:
* - Connect the pins as specified above and below (PIN_IR_RX, PIN_IR_TX);
* - connect the IR-tranceiver to the ISKA ME-162, with _our_ TX on the left
* and _our_ RX on the right;
* - Copy config.h.example to config.h and adapt it to your situation and
* preferences.
* - Copy arduino_secrets.h.example to arduino_secrets.h and fill in your
* credentials and MQTT information.
*
* ISKRA ME-162 electricity meter notes:
* > The optical port complies with the IEC 62056-21 (IEC
* > 61107) standard, a mode C protocol is employed;
* > data transmission rate is 9600 bit/sec.
* ...
* > The optical port wavelength is 660 nm and luminous
* > intensity is min. 1 mW/sr for the ON state.
*
* IEC 62056-21 mode C:
* - is a bidirectional ASCII protocol;
* - that starts in 300 baud with 1 start bit, 7 data bits, 1 (even)
* parity bit and one stop bit;
* - can be upgraded to higher baud rate (9600) after the handshake;
* - and allows manufacturer-specific extensions.
* - See: github.com/lvzon/dsmr-p1-parser/blob/master/doc/IEC-62056-21-notes.md
(IEC 62056-21 protocol).

There's an initial connect readout sample here:

/* Data between STX and ETX. It should look like:
* > C.1.0(28342193) // Meter serial number
* > 0.0.0(28342193) // Device address
* > 1.8.0(0032826.545*kWh) // Total positive active energy (A+)
* > 1.8.1(0000000.000*kWh) // Positive active energy in first tariff (T1)
* > 1.8.2(0032826.545*kWh) // Positive active energy in second tariff (T2)
* > 2.8.0(0000000.001*kWh) // Total negative active energy (A-)
* > 2.8.1(0000000.000*kWh) // Negative active energy in first tariff (T1)
* > 2.8.2(0000000.001*kWh) // Negative active energy in second tariff (T2)
* > F.F(0000000) // Meter fatal error
* > ! // end-of-data
* (With "\r\n" everywhere.) */

I also have a Python version here: https://github.com/wdoekes/pe32me162irpy_pub

It is not as well documented, but it is written in Python, so it might be easier to hack/extend/change. You can use that if you're testing on a laptop/raspberry, instead of on an ESP.


I would like to send the 15-minute consumption, active tariff, and warning flag "grid transformer overload" if it exists.

Hard to tell whether that exists. The ME162 has the following EDIS/OBIS codes for readout:

image

There is no such thing as a 15-minute consumption there. Only the "current" positive/negative cumulative values (1.8.x and 2.8.x). And it has no mention at all of what the active tariff is. Although the latest change in any of the 1.8.x or 2.8.x. values should give you a clue which one is active.


I think this might be your manual: https://www.telematicasistemi.it/it/documents/_01.category/manuali/Mx381_User_manual_eng_V1.01.pdf
It looks way more advanced than my device.

It's likely that the same protocol is supported:
image

The EDIS/OBIS codes are scattered throughout the document: 1.8.0, 90.7.0, etc..

I think from "Annex 1: MT381 object list" and downwards, you have a boatload of these OBIS codes. Among those 0-0:96.14.0.255 ("Currently Active Tariff") and the aforementioned 1-0:1.8.0.255 ("Active Energy Plus").

The 0-0 vs. 1-0 probably specifies which internal device this code is for. At login time, the "default" device is selected here:

iskra_tx(F("/?!\r\n"));

I think you'll need to write /?0! to talk to device 0 and /?1! to talk to device 1.

In the Python version, that would be here: https://github.com/wdoekes/pe32me162irpy_pub/blob/a7ccc15ab079cc323bd7b96adf6188a4e0b28891/pe32me162irpy_pub.py#L437

You'll probably need to "log out" to switch between devices:

/* #5: Terminate the connection with "\SOH B0\ETX " */
case STATE_WR_RESTART:
write_state = state;
iskra_tx(F(S_SOH "B0" S_ETX "q"));
next_state = STATE_WR_LOGIN2;
break;

With these parts you might be able to:

  • log in on dev 0
  • fetch the currently active tarrif; push value to openhab
  • log out
  • log in on dev 1
  • fetch the current readings from 1.8.x for 15 minutes (or less if you don't know when the tariff changes); push delta to openhab
  • log out
  • repeat

Good luck!
Walter

@wdoekes wdoekes changed the title Iskra energy meter compatibility ISKRA MT381 energy meter compatibility Jun 6, 2023
@JieffeEl
Copy link

JieffeEl commented Jun 6, 2023

To add some info, I'm using this program with a ME372 meter and it works fine. My meter doesn't publish much data though, especially not the instant consumption.
Here is what I have :

[ISK5\2ME372-2102]
C.1.0(xxxxxxxxx) // Meter manufacturer number
0.0.0(xxxxxxxxx) // Meter serial number
1.8.0(029809kWh) // Total imported active energy
2.8.0(000000
kWh) // Total exported active energy
128.20.0(020) // GSM signal status (15-20 = 2 bars)
128.20.1(015) // GSM Status
!

The IR probe is not sold any more by the Danes as a kit (I think I was the last to order one), but the components are very common and easy to source on Ali. The PCB schematics are still available and can be used to order the PCB on JLCPCB or PCBWAY. The enclosure can be 3D-printed (the STL is on the Danes website and there is even an improved version with space for a Wemos on Thingiverse, https://www.thingiverse.com/thing:4437840)

@MatejsLab
Copy link
Author

MatejsLab commented Jun 6, 2023 via email

@wdoekes
Copy link
Owner

wdoekes commented Sep 6, 2023

FYI: In 6ccff8b I removed the Danes from the docs and added a link to Bret's eBay where he sells presoldered ones (no plastic cover / magnets though).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants