News:

  • May 18, 2024, 04:32:13 AM

Login with username, password and session length

Author Topic: Node Red / REST API and Modbus TCP  (Read 1721 times)

Kristjan

  • Full Member
  • ***
  • Posts: 49
    • Idnadartaekni ehf
Node Red / REST API and Modbus TCP
« on: June 30, 2023, 05:04:27 AM »
I have been working on a SCADA integration of Airmaster AHUs through REST API. I am running Iconics Genesis SCADA systems and the latest generation (Genesis 64) has native support for REST API, in this case I am able to integrate Airmaster data directly into SCADA.

Many of our existing sites have an older generation SCADA (Genesis 32) which doesn't have any REST API support. I was initially planning on using a BRX as a gateway between the API and SCADA but it turns out that BRX doesn't handle the long strings neccessary to work with token authentication. I then resorted to using Node Red as a gateway. Node Red is reading the API and exposing the data on a Modbus Server internal to Node Red. The SCADA then reads from the Modbus server. This instance of Node Red is running on Raspberry Pi but it should be possible to run NR on any platform, including a Windows server. A proof of concept is working but I would be interested in seeing Node Red solutions from others. Could we create a Node Red repository on Github and share some solutions there?

https://github.com/AutomationDirect

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5996
  • Yes Pinky, Do-more will control the world!
Re: Node Red / REST API and Modbus TCP
« Reply #1 on: June 30, 2023, 11:18:06 AM »
How long a string do you need?
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Kristjan

  • Full Member
  • ***
  • Posts: 49
    • Idnadartaekni ehf
Re: Node Red / REST API and Modbus TCP
« Reply #2 on: July 03, 2023, 10:44:47 AM »
I had a separate topic on this issue. See https://forum.hosteng.com/index.php?topic=3817.0

The bearer token string is JWL formatted and is 1355 characters long. I was able to recieve the API response with the token into a BRX byte buffer. Parsing out the token worked fine and then I have to make a new API request for data, adding the token as header. So I split the token into long strings (SLx) in order to pass it on to the new API request for data. The header field in the HTTPCMD instruction only supports strings up to 1024 characters so I hit the wall there. Then I resorted to using Node Red as the gateway.

As I also mentioned in the other topic, the PLC in this case is not using the data for any controls, the PLC is merely a gateway and is not really needed in the system. But I prefer using controllers we use every day and know in and out, i.e. BRX. But there are other cases where we want to use REST API data for control and in those cases it is a clear advantage to read API directly into PLC memory without any gateways.