Difference between revisions of "M-bus Linux"

From Teknologisk videncenter
Jump to: navigation, search
m (Display)
m (Display)
 
(7 intermediate revisions by the same user not shown)
Line 11: Line 11:
 
</source>
 
</source>
 
==Hardware configuration==
 
==Hardware configuration==
 +
[[image:Beaglebone-black-pinout.jpg|right|300px]]
 
===Display===
 
===Display===
 
*[https://newhavendisplay.com/content/specs/NHD-C0220BiZ-FSW-FBW-3V3M.pdf Newhaven display 2x20]
 
*[https://newhavendisplay.com/content/specs/NHD-C0220BiZ-FSW-FBW-3V3M.pdf Newhaven display 2x20]
**Onboard display controller [https://datasheetspdf.com/pdf-file/1470464/Sitronix/ST7036i/1 Sitronix ST7036i]
+
**Onboard display controller [http://www.newhavendisplay.com/app_notes/ST7036.pdf Sitronix ST7036i]
  
 
Configure display for I2C bus 2
 
Configure display for I2C bus 2
Line 21: Line 22:
 
*P9-19 - I2C2_SCL connect to display SCL
 
*P9-19 - I2C2_SCL connect to display SCL
 
*P9-20 - I2C2_SDA connect to display SDA
 
*P9-20 - I2C2_SDA connect to display SDA
 +
*Capacitor 1 uF between display C1+ and C1-
 +
*Capacitor 1 uF between display VOUT and VSS
 +
* i2C pullup resistor 10 K ohm between display SCL and display VDD
 +
* i2C pullup resistor 10 K ohm between display SDA and display VDD
 +
 
====Backlight====
 
====Backlight====
 
*Anode - A to 5 volt through 2 resistors of 150 ohm in parellel
 
*Anode - A to 5 volt through 2 resistors of 150 ohm in parellel
Line 31: Line 37:
 
*P9-1 or P9-2 (BBB-GND) to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] GND
 
*P9-1 or P9-2 (BBB-GND) to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] GND
 
*P9-3 or P9-4 (BBB-3V3) to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] 3V3
 
*P9-3 or P9-4 (BBB-3V3) to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] 3V3
*P9-5 (BBB-5V) to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] 5V
+
* Connect 36 Volt DC PSU to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] 36 Volt +/-
 
+
====Beaglebone black - debian <= version 9====
 
Configure BBB GPIO for UART - /dev/ttyS4
 
Configure BBB GPIO for UART - /dev/ttyS4
 
<source lang=bash>
 
<source lang=bash>
Line 39: Line 45:
 
</source>
 
</source>
  
 +
====Beaglebone black - debian > version 9====
 +
Insert UART 4 devicetree overlay in /boot/uEnv.txt - fx. use addr0
 +
<source lang=bash>
 +
uboot_overlay_addr0=/boot/dtbs/5.10.168-ti-r79/overlays/BB-UART4-00A0.dtbo
 +
</source>
 +
 +
====Libmbus software====
 
*OLD: Install [http://www.rscada.se/libmbus/ libmbus] - notice: ln -s  /usr/local/lib/libmbus.so.0 /usr/lib/
 
*OLD: Install [http://www.rscada.se/libmbus/ libmbus] - notice: ln -s  /usr/local/lib/libmbus.so.0 /usr/lib/
 
<source lang=bash>
 
<source lang=bash>

Latest revision as of 06:42, 5 September 2024

Beagleboard Black

Installing libmbus

Upgrade and install dev tools Beaglebone Black/Updating

git clone https://github.com/rscada/libmbus.git
sudo apt install libltdl-dev
./build.sh
./configure
make 
sudo make install

Hardware configuration

Beaglebone-black-pinout.jpg

Display

Configure display for I2C bus 2

  • P9-1 or P9-2 to display VSS (Ground)
  • P9-3 or P9-4 to display VDD (3,3 volt)
  • P9-16 - GPIO51/EHRPWM1B connect to display RST
  • P9-19 - I2C2_SCL connect to display SCL
  • P9-20 - I2C2_SDA connect to display SDA
  • Capacitor 1 uF between display C1+ and C1-
  • Capacitor 1 uF between display VOUT and VSS
  • i2C pullup resistor 10 K ohm between display SCL and display VDD
  • i2C pullup resistor 10 K ohm between display SDA and display VDD

Backlight

  • Anode - A to 5 volt through 2 resistors of 150 ohm in parellel
  • Katode - K to GND

mbus

Wires:

Beaglebone black - debian <= version 9

Configure BBB GPIO for UART - /dev/ttyS4

sudo  config-pin  P9_11 uart
sudo  config-pin  P9_13 uart

Beaglebone black - debian > version 9

Insert UART 4 devicetree overlay in /boot/uEnv.txt - fx. use addr0

uboot_overlay_addr0=/boot/dtbs/5.10.168-ti-r79/overlays/BB-UART4-00A0.dtbo

Libmbus software

  • OLD: Install libmbus - notice: ln -s /usr/local/lib/libmbus.so.0 /usr/lib/
mbus-serial-request-data-multi-reply -d /dev/ttyS4 68
main: debug: sending init frame
[2023-01-05 09:24:46] SEND (005): 10 40 FF 3F 16
[2023-01-05 09:24:47] SEND (005): 10 7B 44 BF 16
[2023-01-05 09:24:47] RECV (205): 68 C7 C7 68 08 44 72 68 43 35 80 2D 2C 35 0C 07 10 00 00 04 06 00 00 00 00 04 FF 07 00 00 00 00 04 FF 08 00 00 00 00 04 14 00 00 00 00 84 40 14 00 00 00 00 84 80 40 14 00 00 00 00 04 22 DF 07 00 00 34 22 00 00 00 00 02 59 A2 08 02 5D 5E 08 02 61 44 00 04 2D 00 00 00 00 14 2D 00 00 00 00 04 3B 00 00 00 00 14 3B 00 00 00 00 04 FF 22 00 01 00 00 04 6D 19 2B E5 21 44 06 00 00 00 00 44 FF 07 00 00 00 00 44 FF 08 00 00 00 00 44 14 00 00 00 00 C4 40 14 00 00 00 00 C4 80 40 14 00 00 00 00 54 2D 00 00 00 00 54 3B 00 00 00 00 42 6C E1 21 02 FF 1A 01 1B 0C 78 68 43 35 80 04 FF 16 E6 84 1E 00 04 FF 17 C1 D5 B4 00 B1 16
mbus_frame_print: Dumping M-Bus frame [type 4, 205 bytes]: 68 C7 C7 68 08 44 72 68 43 35 80 2D 2C 35 0C 07 10 00 00 04 06 00 00 00 00 04 FF 07 00 00 00 00 04 FF 08 00 00 00 00 04 14 00 00 00 00 84 40 14 00 00 00 00 84 80 40 14 00 00 00 00 04 22 DF 07 00 00 34 22 00 00 00 00 02 59 A2 08 02 5D 5E 08 02 61 44 00 04 2D 00 00 00 00 14 2D 00 00 00 00 04 3B 00 00 00 00 14 3B 00 00 00 00 04 FF 22 00 01 00 00 04 6D 19 2B E5 21 44 06 00 00 00 00 44 FF 07 00 00 00 00 44 FF 08 00 00 00 00 44 14 00 00 00 00 C4 40 14 00 00 00 00 C4 80 40 14 00 00 00 00 54 2D 00 00 00 00 54 3B 00 00 00 00 42 6C E1 21 02 FF 1A 01 1B 0C 78 68 43 35 80 04 FF 16 E6 84 1E 00 04 FF 17 C1 D5 B4 00 B1 16
<MBusData>

    <SlaveInformation>
        <Id>80354368</Id>
        <Manufacturer>KAM</Manufacturer>
        <Version>53</Version>
        <ProductName></ProductName>
        <Medium>Heat: Inlet</Medium>
        <AccessNumber>7</AccessNumber>
        <Status>10</Status>
        <Signature>0000</Signature>
    </SlaveInformation>

    <DataRecord id="0">
        <Function>Instantaneous value</Function>
        <Unit>Energy (kWh)</Unit>
        <Value>0</Value>
        <Timestamp>2023-01-05T09:24:47</Timestamp>
    </DataRecord>

    <DataRecord id="1">
        <Function>Instantaneous value</Function>
        <Unit>Manufacturer specific</Unit>
        <Value>0</Value>
        <Timestamp>2023-01-05T09:24:47</Timestamp>
    </DataRecord>

..................................................... DATA REMOVED ..................................
    <DataRecord id="29">
        <Function>Instantaneous value</Function>
        <Unit>Manufacturer specific</Unit>
        <Value>11851201</Value>
        <Timestamp>2023-01-05T09:24:47</Timestamp>
    </DataRecord>

</MBusData>