How to use node-red to turn off an LED

Alles rund um TX(T) und RoboPro, mit ft-Hard- und Software
Computing using original ft hard- and software
Forumsregeln
Bitte beachte die Forumsregeln!
Antworten
zhengtzer
Beiträge: 15
Registriert: 22 Aug 2023, 12:11

How to use node-red to turn off an LED

Beitrag von zhengtzer » 22 Sep 2023, 19:51

Hi


i know how to publish a switch status through mqtt and display on node-red dashboard
node-red.png
node-red.png (46.04 KiB) 2372 mal betrachtet
but now i am stuck on the other way around, how can i turn off an LED through subcribe?
subcribe.png
subcribe.png (27.47 KiB) 2372 mal betrachtet

thanks
Jonathan

rugee-f
Beiträge: 63
Registriert: 28 Jan 2022, 13:46

Re: How to use node-red to turn off an LED

Beitrag von rugee-f » 22 Sep 2023, 22:18

You can write a python prog where your incomming MQTT messages affect the TXT 4 IO (similar like you tried in RoboProCoding - I did this in plain python code...)

But the easier way to handle the IO of the TXT4 direct from Node-Red is to use the TXT4 API with HTTP requests.
With that you do not need a Python software layer to use the IO.

Bild
Dateianhänge
API_Flow.png
API_Flow.png (138.83 KiB) 2342 mal betrachtet

zhengtzer
Beiträge: 15
Registriert: 22 Aug 2023, 12:11

Re: How to use node-red to turn off an LED

Beitrag von zhengtzer » 23 Sep 2023, 16:19

Hi

"But the easier way to handle the IO of the TXT4 direct from Node-Red is to use the TXT4 API with HTTP requests.
With that you do not need a Python software layer to use the IO."

thanks for guiding me, and i tried to figure out whole day, now txt4.0 can receive the message, but the LED just cant be turn off
can you help me to look through and see which part had i do wrongly?tyty

my RPC
subcribePayload.png
subcribePayload.png (213.67 KiB) 2253 mal betrachtet
my flow
node-red.png
node-red.png (125.2 KiB) 2253 mal betrachtet
my dashboard, know how to "control" the LED on dashboard only
nodeRedDashboard.png
nodeRedDashboard.png (42.19 KiB) 2253 mal betrachtet

thanks
Jonathan

rugee-f
Beiträge: 63
Registriert: 28 Jan 2022, 13:46

Re: How to use node-red to turn off an LED

Beitrag von rugee-f » 23 Sep 2023, 22:01

I do not often use Blockly - with that I could not help you much.
I am using plain Python code - there I initialized my TXT4 IO as lamp (PWM) outputs and declared MQTT topics for the PWM setpoints.
declare_1.png
declare_1.png (93.97 KiB) 2231 mal betrachtet
With incoming MQTT message on the setpoint topic I wrote the setpoint value to the TXT output.
0 for LED OFF and 255 for LED ON.
declare_2.png
declare_2.png (84.14 KiB) 2231 mal betrachtet

Antworten