Giter Club home page Giter Club logo

micropymeterbus's Introduction

Meter-Bus for MicroPython

MicroPython implementation of the Meter-Bus (M-Bus EN13757-3) protocol.

about M-BUS

Due to rising prices for oil, gas and heat as well as climate change, it is becoming more and more important to monitor energy consumption in order to keep an eye on energy costs, but also to be able to check the effectiveness of savings. Many meters for oil and gas, but also for water, are equipped with a special 2 wire bus system, the M-BUS or meter bus, for monitoring consumption values.

Hardware

I've tested this code with our Arduino MKR M-BUS shield and the Arduino Portenta H7 (via OpenMV IDE) and the Raspberry Pico (via Thonny IDE).

My image)

External libraries

MicroPython will not support the decimal function of standard Python. To solve this problem the library micropython-decimal-number is required.

Examples

Please enable/ disable the lines for UART configuration in the examples for your board first!

mbus-serial-scan.py

This program will scan the M-Bus for devices via the primary (logical) address. Currently it is limited to address 6 as maximum, but you can change the value MAX_PRIMARY_SLAVES in defines.py for upto 250 primary addresses.

mbus-serial-scan-secondary.py

This program will scan the M-Bus for devices via the secondary address.

mbus-serial-request-data.py

Will request the data from a slave device via primary address first and secondary address. The data is returned in JSON format.

Credits

Based on the pyMeterBus project by Mikael Ganehag Brorsson

https://github.com/ganehag/pyMeterBus

micropymeterbus's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

vtt-info stanpall

micropymeterbus's Issues

It is not micro

On ESP32 without external PSRAM it even does not imports. It will ate whole free memory

Traceback (most recent call last):
  File "main.py", line 2, in <module>
  File "/lib/meterbus/__init__.py", line 21, in <module>
  File "/lib/meterbus/telegram_control.py", line 1, in <module>
  File "/lib/meterbus/telegram_body.py", line 3, in <module>
  File "/lib/meterbus/telegram_variable_data_record.py", line 1, in <module>
MemoryError: memory allocation failed, allocating 136 bytes

Simple example just

from machine import UART, Pin
import meterbus.serial
import time
import meterbus

ser = UART(1, 2400, bits=8, parity=0, stop=1,  tx=4, rx=36)

would be nice to optimize it for low memory environments too to make it micro

also tried even simple import

>>> gc.mem_free()
101488
>>> gc.collect()
>>> gc.mem_free()
103280
>>> import meterbus
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lib/meterbus/__init__.py", line 21, in <module>
  File "/lib/meterbus/telegram_control.py", line 1, in <module>
  File "/lib/meterbus/telegram_body.py", line 3, in <module>
  File "/lib/meterbus/telegram_variable_data_record.py", line 1, in <module>
MemoryError: memory allocation failed, allocating 640 bytes

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.