Hi!
I have a board containing 32 digital input and 2 outputs, with an modbus interface. I want to use it as a interface between node red and a bunch of mono-stable buttons to control home lights (and some other stuff, nor really real time application so not relevant)
To test this approach I've prepared a PoC (on my PC) in python that uses modbus to read the status of inputs every 50ms or so (min time is 15ms max was something around 80ms) , and react to given state change, this worked well, even the shortest "clicks" where "discovered" by the app, and a signal to turn light on/off was send successfully.
I want to move this to Node RED running on my raspberry pi zero I wanted to read the status using normal nodes (just read modbus data every 50ms in a loop) but this task takes >50% of the RPi resources so I assume that this is not good solution
For now I have a question on HOW I should implement this "properly"?
-
Write my own service in C/C++ that will talk with the input board and send some data over http (or something else, mayby some IPC...) to node red only when detecting some signal?
-
Run a python script containing "do while loop" in a "python3 node" and just output the data on state change to node red?
-
The board contains an ATmega uC I can "hack" this chip quite easily, and write my own implementation that uses the 2 given outputs to signal an interrupt that will signal the RPi and ONLY THEN use node red on RPi to read the state of inputs and decide what to do with this
-
Do something else?