├── python_examples ├── .gitignore ├── requirements_gurux.txt ├── requirements.txt ├── Readme.md ├── decrypt_with_gurux.py └── decrypt_with_cryptography.py ├── esp_home ├── iskra_am550 │ ├── __init__.py │ ├── iskra_am550.h │ ├── sensor.py │ └── iskra_am550.cpp ├── Readme.md └── siemens_im350 │ ├── siemens_im350.h │ ├── sensor.py │ └── siemens_im350.cpp ├── docs ├── images │ ├── circuit.jpg │ ├── circuit.png │ ├── message.png │ ├── pinout_2.jpg │ ├── pinout_2.png │ ├── grafana_example.png │ ├── python_example_output.png │ ├── example_output_esphome.png │ ├── customer_interface_pinout.jpg │ ├── customer_interface_pinout.png │ └── data_output_customer_interface.png ├── provider_informations │ ├── im350.pdf │ ├── iskra.pdf │ ├── IMx50_1.pdf │ └── IMx50_2.pdf └── standalone_version │ ├── pio_settings.png │ ├── vs_buttons.png │ └── example_output.png ├── standalone_version ├── .gitignore ├── src │ ├── secrets.h.example │ ├── settings.h │ └── main.cpp ├── test │ └── README ├── Readme.md ├── lib │ └── README ├── platformio.ini └── include │ └── README ├── .gitignore ├── README.md └── LICENSE /python_examples/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | venv -------------------------------------------------------------------------------- /python_examples/requirements_gurux.txt: -------------------------------------------------------------------------------- 1 | gurux-dlms==1.0.95 2 | -------------------------------------------------------------------------------- /esp_home/iskra_am550/__init__.py: -------------------------------------------------------------------------------- 1 | CODEOWNERS = ['@Andre-Schuiki'] 2 | -------------------------------------------------------------------------------- /docs/images/circuit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/circuit.jpg -------------------------------------------------------------------------------- /docs/images/circuit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/circuit.png -------------------------------------------------------------------------------- /docs/images/message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/message.png -------------------------------------------------------------------------------- /docs/images/pinout_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/pinout_2.jpg -------------------------------------------------------------------------------- /docs/images/pinout_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/pinout_2.png -------------------------------------------------------------------------------- /python_examples/requirements.txt: -------------------------------------------------------------------------------- 1 | cffi==1.14.4 2 | cryptography==3.3.1 3 | pycparser==2.20 4 | six==1.15.0 5 | -------------------------------------------------------------------------------- /docs/images/grafana_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/grafana_example.png -------------------------------------------------------------------------------- /docs/images/python_example_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/python_example_output.png -------------------------------------------------------------------------------- /docs/provider_informations/im350.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/provider_informations/im350.pdf -------------------------------------------------------------------------------- /docs/provider_informations/iskra.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/provider_informations/iskra.pdf -------------------------------------------------------------------------------- /docs/images/example_output_esphome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/example_output_esphome.png -------------------------------------------------------------------------------- /docs/provider_informations/IMx50_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/provider_informations/IMx50_1.pdf -------------------------------------------------------------------------------- /docs/provider_informations/IMx50_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/provider_informations/IMx50_2.pdf -------------------------------------------------------------------------------- /docs/standalone_version/pio_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/standalone_version/pio_settings.png -------------------------------------------------------------------------------- /docs/standalone_version/vs_buttons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/standalone_version/vs_buttons.png -------------------------------------------------------------------------------- /docs/images/customer_interface_pinout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/customer_interface_pinout.jpg -------------------------------------------------------------------------------- /docs/images/customer_interface_pinout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/customer_interface_pinout.png -------------------------------------------------------------------------------- /docs/standalone_version/example_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/standalone_version/example_output.png -------------------------------------------------------------------------------- /docs/images/data_output_customer_interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Andre-Schuiki/esphome_im350/HEAD/docs/images/data_output_customer_interface.png -------------------------------------------------------------------------------- /standalone_version/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | .history 7 | /src/secrets.h 8 | *.log 9 | -------------------------------------------------------------------------------- /standalone_version/src/secrets.h.example: -------------------------------------------------------------------------------- 1 | char wifi_ssid[] = "SSID"; 2 | char wifi_password[] = "PASSWORD"; 3 | byte sm_decryption_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; // you need to request the key from your provider, should be 16Byte -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | .history -------------------------------------------------------------------------------- /standalone_version/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | -------------------------------------------------------------------------------- /python_examples/Readme.md: -------------------------------------------------------------------------------- 1 | # Python Example Files 2 | Two example files in python to translate the message from the meter. 3 | 4 | One File uses the [gurux](https://github.com/gurux/gurux.dlms.python) library and the other the [cryptography](https://github.com/pyca/cryptography) library. 5 | 6 | ## Usage 7 | 1. `pip install -r requirements.txt` oder `pip install -r requirements_gurux.txt` 8 | 2. Enter enter the message from you smart meter and your decryption key. (you get the key from your provider) 9 | 10 | 11 | 12 | ## Example Output 13 | ![](../docs/images/python_example_output.png) -------------------------------------------------------------------------------- /standalone_version/Readme.md: -------------------------------------------------------------------------------- 1 | # Info 2 | This was the first version of the code, use this code to as start point if you want to create your own solution. 3 | 4 | # Usage/Compiling 5 | For compiling you need **Visual Studio Code + Platform IO Plugin** for installation instructions see: [https://docs.platformio.org/en/latest/integration/ide/vscode.html#ide-vscode](https://docs.platformio.org/en/latest/integration/ide/vscode.html#ide-vscode) 6 | 1. Download this folder 7 | 2. Open the folder in Platform IO 8 | 3. Create a secrets.h file (see secrets.h.example file) 9 | 4. Build 10 | 5. Upload to ESP via serial port 11 | 12 | # Using OTA 13 | Note: First Upload must be over the Serial Port! 14 | 1. Edit platformio.ini and enter the ip address of your ESP. 15 | ![](../docs/standalone_version/pio_settings.png) 16 | 2. Use Upload/Monitor Option as usual. 17 | ![](../docs/standalone_version/vs_buttons.png) 18 | 19 | # Example Output 20 | ![](../docs/standalone_version/example_output.png) -------------------------------------------------------------------------------- /standalone_version/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /standalone_version/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [platformio] 12 | default_envs = wemos_d1_mini32_ota 13 | ; default_envs = wemos_d1_mini32 14 | 15 | [env:wemos_d1_mini32] 16 | platform = espressif32 17 | board = wemos_d1_mini32 18 | framework = arduino 19 | monitor_speed = 115200 20 | monitor_flags = 21 | --parity 22 | N 23 | --encoding 24 | utf-8 25 | upload_port = COM5 26 | debug_tool = esp-prog 27 | debug_init_break = tbreak setup 28 | lib_deps = 29 | rweather/Crypto@^0.2.0 30 | jandrassy/TelnetStream@^1.2.1 31 | build_flags = -fexceptions 32 | 33 | [env:wemos_d1_mini32_ota] 34 | platform = espressif32 35 | board = wemos_d1_mini32 36 | framework = arduino 37 | monitor_port = socket://:23 38 | monitor_speed = 115200 39 | monitor_flags = 40 | --parity 41 | N 42 | --encoding 43 | utf-8 44 | monitor_filters = log2file, default 45 | upload_protocol = espota 46 | upload_port = 47 | upload_flags = -P 11111 48 | debug_tool = esp-prog 49 | debug_init_break = tbreak setup 50 | build_flags = -fexceptions 51 | lib_deps = 52 | rweather/Crypto@^0.2.0 53 | jandrassy/TelnetStream@^1.2.1 -------------------------------------------------------------------------------- /standalone_version/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /standalone_version/src/settings.h: -------------------------------------------------------------------------------- 1 | // Using UART2 for reading the data from the smart meter, if you use the UART0 you can not upload new code to the board cause its blocked while reading from the meter! 2 | int uart2_rx_gpio = 16; 3 | int uart2_tx_gpio = 17; 4 | int data_request_gpio = 26; 5 | int led_builtin = 2; 6 | // NTP Settings 7 | char ntp_server[] = "pool.ntp.org"; 8 | const long gmtOffset_sec = 3600; 9 | const int daylightOffset_sec = 3600; 10 | 11 | const byte start_byte = 0x7E; 12 | const byte stop_byte = 0x7E; 13 | 14 | const int max_wait_time_for_reading_data = 1100; 15 | int delay_before_reading_data = 1000; 16 | 17 | const int message_length = 123; 18 | byte message[message_length]; 19 | byte buffer[90]; 20 | 21 | bool use_test_data = false; 22 | byte testData[123] = {0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x7e}; -------------------------------------------------------------------------------- /python_examples/decrypt_with_gurux.py: -------------------------------------------------------------------------------- 1 | import binascii 2 | from gurux_dlms import * 3 | from xml.dom.minidom import parseString, Node 4 | import re 5 | 6 | """ 7 | Example Script to convert and decrypt message from im350 smart meter with gurux python library. 8 | Usage: Just enter enter the message from you smart meter and your decryption key. 9 | """ 10 | 11 | # Hex String, 246 Chars // 123 Bytes, Starting/Stopping with 7E 12 | message_hex_string = '' 13 | # Hex String 32 Chars // 16 Bytes, you get the key from you provider! 14 | decryption_key_hex_string = '' 15 | 16 | decryption_key = binascii.unhexlify(decryption_key_hex_string) 17 | message_bytes = binascii.unhexlify(message_hex_string) 18 | 19 | translator = GXDLMSTranslator() 20 | translator.comments = True 21 | translator.blockCipherKey = decryption_key 22 | 23 | message_ = translator.messageToXml(message_bytes) 24 | message = re.sub(r'(