/SmlParserLight

MicroPython compatible parser for the SML (Smart Message Language) protocol

Primary LanguagePython

SmlParserLight

MicroPython compatible parser for the SML (Smart Message Language) protocol

The Challenge

Starting point was to integrate the reading of a smart meter into the home automation iot network.

The infrastructure mosquitto MQTT server and node-red for visualization is already setup. Not wanting to spend a full Raspberry Pi to "just" read the SML messages and send them via MQTT lead to implementing the required on a MicroPython compatible hardware (e.g. ESP32, Raspberry Pi Pico W, ...)

There are quite a few projects out there providing support for SML, but unfortunately they cannot be run on the reduced functionality of MicroPython.

The Inspiration

This python script is in fact a light version of smllib. Removing a lot of functionality (and convenience) to be able to run it on micropython.

Use the smllib to analyse the raw messages from your eMeter to extract the available OBIS codes.

The Script

The scrip fulfills two tasks.

  1. Accumulate bytes read from UART to extract full frames from the stream. The validity the is checked based on the CRC signature.
  2. Once a frame is returned by get_frame() the entries can be extracted by using the sml_get_entry() function.

The entry contains all 7 components, (None if they are not set)

The Usage

The example_usage.py shows how to use the parser. For the full setup the data shall be fed from the UART attached to the SML IR interface.