Difference between revisions of "M-bus Linux"
From Teknologisk videncenter
m |
m (→Beaglebone black - debian > version 9) |
||
(9 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
sudo make install | sudo make install | ||
</source> | </source> | ||
− | == | + | ==Hardware configuration== |
+ | [[image:Beaglebone-black-pinout.jpg|right|300px]] | ||
+ | ===Display=== | ||
+ | *[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] | ||
+ | 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: | Wires: | ||
*P9-11 ([[BeagleBoard|BBB]]-RX) to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] TX | *P9-11 ([[BeagleBoard|BBB]]-RX) to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] TX | ||
*P9-13 (BBB-TX) to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] RX | *P9-13 (BBB-TX) to [https://www.mikroe.com/m-bus-master-click MIKROE-3880 M-BUS MASTER CLICK] RX | ||
− | *P9-1 (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 (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 |
− | * | + | * 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 25: | 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> | ||
mbus-serial-request-data-multi-reply -d /dev/ttyS4 68 | mbus-serial-request-data-multi-reply -d /dev/ttyS4 68 |
Latest revision as of 15:09, 11 August 2024
Contents
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
Display
- Newhaven display 2x20
- Onboard display controller Sitronix ST7036i
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:
- P9-11 (BBB-RX) to MIKROE-3880 M-BUS MASTER CLICK TX
- P9-13 (BBB-TX) to MIKROE-3880 M-BUS MASTER CLICK RX
- P9-1 or P9-2 (BBB-GND) to MIKROE-3880 M-BUS MASTER CLICK GND
- P9-3 or P9-4 (BBB-3V3) to MIKROE-3880 M-BUS MASTER CLICK 3V3
- Connect 36 Volt DC PSU to MIKROE-3880 M-BUS MASTER CLICK 36 Volt +/-
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>