# BACnet MSTP in Node-RED

**URL:** <https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659>\
**Category:** General\
**Created:** [2 May 2024 18:12 UTC](https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659 "2024-05-02T18:12:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [2 May 2024 18:12 UTC](https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659/1 "2024-05-02T18:12:51Z")

</div>

Hello,

I am attempting to read a BACnet MSTP device in Node-RED running on a Raspberry Pi. I'm connecting to the device via an RS-485 to USB adapter. I have successfully communicated to the device using YABE (Yet Another BACnet Explorer) and am able to read the analog Values of interest just fine.

To the best of my knowledge, none of the Node-RED node packages appear to support reading from an MSTP device, they all appear to be expecting BACnet IP.

I've read through several of the threads on the forum pertaining to BACnet and few have to do with MSTP specifically. Does anyone have any ideas on how I could communicate to this device from Node-RED?

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [2 May 2024 21:41 UTC](https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659/2 "2024-05-02T21:41:29Z")

</div>

To give a little more context one of the most promising routes I've tried is using this [GitHub - riptideio/misty: MS/TP Support for bacpypes](https://github.com/riptideio/misty)  
I am able to run it successfully from the terminal, but it requires manual input to read an object once a connection to the device is made so it has been difficult to replicate in Node-RED. I have tried `exec`, `pythonshell` and `daemon` to run the program but so far I have encountered errors with each.

Exec this is the error I get:

```auto
DEBUG:bacpypes.consolelogging.ConfigArgumentParser: __init__
DEBUG:bacpypes.consolelogging.ArgumentParser: __init__
DEBUG:bacpypes.consolelogging.ConfigArgumentParser:update_os_env
DEBUG:bacpypes.consolelogging.ArgumentParser:update_os_env
DEBUG:bacpypes.consolelogging.ArgumentParser: - settings: {'debug': set(), 'color': False, 'debug_file': '', 'max_bytes': 1048576, 'backup_count': 5, 'route_aware': False}
DEBUG:bacpypes.consolelogging.ArgumentParser: - os environment
DEBUG:bacpypes.consolelogging.ArgumentParser:parse_args
DEBUG:bacpypes.consolelogging.ConfigArgumentParser:expand_args Namespace(buggers=False, debug=None, color=None, route_aware=None, ini='/home/jci/misty/misty/samples/bac_client.ini')
DEBUG:bacpypes.consolelogging: - config: <configparser.ConfigParser object at 0x7fb136bd00>
DEBUG:bacpypes.consolelogging: - ini_obj: {'objectname': 'BACClient', 'address': '25', 'interface': '/dev/ttyUSB0', 'max_masters': '127', 'baudrate': '38400', 'maxinfo': '1', 'objectide...

```

Pythonshell error

```auto
exit code: 2, DEBUG:bacpypes.consolelogging.ConfigArgumentParser: __init__
DEBUG:bacpypes.consolelogging.ArgumentParser: __init__
DEBUG:bacpypes.consolelogging.ConfigArgumentParser:update_os_env
DEBUG:bacpypes.consolelogging.ArgumentParser:update_os_env
DEBUG:bacpypes.consolelogging.ArgumentParser: - settings: {'debug': set(), 'color': False, 'debug_file': '', 'max_bytes': 1048576, 'backup_count': 5, 'route_aware': False}
DEBUG:bacpypes.consolelogging.ArgumentParser: - os environment
DEBUG:bacpypes.consolelogging.ArgumentParser:parse_args
usage: ReadProperty.py [-h] [--buggers] [--debug [DEBUG ...]] [--color]
                       [--route-aware] [--ini INI]
ReadProperty.py: error: unrecognized arguments: read 4 analogValue:29522 presentValue

```

Daemon immediately says "stopped" upon deployment but doesn't return any error that I'm able to see.

I'm not Python literate enough to know how to, but I'm assuming I could just remove the part of the script that asks for input and just hard code the input to read? From the terminal I have tried feeding input directly such as:  
`python /home/jci/misty/misty/samples/bac_client.py --ini /home/jci/misty/misty/samples/bac_client.ini <<< "read 4 analogValue:29522 presentValue"`  
But this returns:

```auto
Initialized the socket
mac_address = 25 
max master = 127 
baud rate = 38400 
max info frames = 1 
RS485: Initializing /dev/ttyUSB0=success!
MS/TP MAC: 19
MS/TP Max_Master: 7F
MS/TP Max_Info_Frames: 1
mstp_path=/var/tmp/ma_37giaq6z/mstpttyUSB0 
no task manager
Cleaned up MSTP temp directory

```

Here is what a successful interaction looks like in the terminal:

```auto
Initialized the socket
mac_address = 25 
max master = 127 
baud rate = 38400 
max info frames = 1 
RS485: Initializing /dev/ttyUSB0=success!
MS/TP MAC: 19
MS/TP Max_Master: 7F
MS/TP Max_Info_Frames: 1
mstp_path=/var/tmp/ma_zwyq53pn/mstpttyUSB0 
> read 4 analogValue:29522 presentValue
75.14591979980469
> exit
Exiting...
Cleaned up MSTP temp directory

```

If there is another library or method that would be better I'm very interested to try it. Or if someone can help me troubleshoot one of the methods I've tried, any help is welcome.

---

<div class="post-metadata">

**Author:** ![iiLaw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iilaw/32/14782_2.png) [@iiLaw](https://discourse.nodered.org/u/iiLaw)\
**Post date:** [3 May 2024 13:04 UTC](https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659/3 "2024-05-03T13:04:24Z")

</div>

BACnet not well supported.  
If you can place a BACnet router to bridge MS/TP to IP then I would recommend

> **[node-bacnet-contrib-extended](https://flows.nodered.org/node/node-bacnet-contrib-extended)**
>
> Install this package as a pallette by using node red dashboard

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [3 May 2024 14:33 UTC](https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659/4 "2024-05-03T14:33:46Z")

</div>

I have tried to avoid this as I havent found what appears to be a reliable router that isn't expensive. To some degree, that is what I was wanting the Raspberry Pi to do.

Like I said, I have been able to get the Misty wrapper for BACpypes to work, but the struggle has been getting it to work in Node-RED. Or at least automating the reads and then retrieving the information in Node-RED.

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [18 June 2024 22:52 UTC](https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659/5 "2024-06-18T22:52:27Z")

</div>

Hello,

Sorry for the hiatus but I have returned to this project.

I was able to use a MS/TP to IP router and I can use the `discover devices` node to see my devices. However, I have been unsuccessful in retrieving any data. I followed the instructions [here](https://www.hellgeeks.com/how-to-use-node-red-plugin-node-bacnet-contrib-extended-to-read-bacnet-devices/) to the best of my knowledge but I haven't been able to see any useful data.

I have YABE (Yet Another BACnet Explorer) installed and using it I can see all the data points I need over a BACnet IP connection.

Could someone help point me in the right direction?

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [19 June 2024 01:44 UTC](https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659/6 "2024-06-19T01:44:06Z")

</div>

I should have been a little more specific. When I use a `read-single-device` node and use the device ID and IP address of the router, I receive information about the router, but nothing about the devices connected or their bacnet properties. I have four devices attached to the router that are collected data (temperatures, pressures, etc). These devices show up in YABE but not on the output of discover devices.

I have tried changing the device ID's to what they show up as is YABE with the same IP address, but that didn't work either.

---

<div class="post-metadata">

**Author:** ![jgreenmt](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@jgreenmt](https://discourse.nodered.org/u/jgreenmt)\
**Post date:** [19 June 2024 18:02 UTC](https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659/7 "2024-06-19T18:02:04Z")

</div>

As this issue has strayed away from BACnet MS/TP it seems appropriate that I should start a new thread. I'm going to mark this one solved.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 July 2024 18:02 UTC](https://discourse.nodered.org/t/bacnet-mstp-in-node-red/87659/8 "2024-07-03T18:02:10Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
