Raspberry PI 3 - GPIO status

HI,
First of all I'm absolutely beginner in Node Red and I need some help.
I'm trying for some days to get on dashboard status of 3 GPIO pins.
My scenario, one short description :slight_smile:
I made short automation fro my house heating module.
I have 2 sensors for reading temperature and one input pin for reading status of ambient sensor. Base ambient status and readings from temperature sensors I do some calculation and I'm starting or stopping heating module and pump.
My problem is:
I created one flow in Node Red to get temperature from sensors. I created in dashboard 2 gauges and it's work perfectly.
I created flows for pump and heating module using switch one function and text node to display on dashboard status ON OFF when I'm using switch.
Problem is that I did't succeed to get status ON OFF of pin when rasPI switch automatically the pin 0 / 1.
If I put in flow to read PIN status, the program from raspberry is not switching anymore the pin, I think because is used by other process, maybe Node Red I think.
If someone have any idea how can I read and display, command status of a pin and still to work from PI program I will by very grateful.
I put also a picture with my flow

Thanks in advance for your time and patience with a beginner :slight_smile:

Regards,
Marian Sebastian

Your flow doesn鈥檛 include any debug nodes

Debug nodes are your friends as it allows you to see the messages that are being passed between the nodes.

Often you will need to filter or reformat the data in a message. Check that the message your are sending to a node matched what the info panel for that node tells you the node needs. When you know what you have and what you need you can use the change node to modify the message

Do you mean you are trying to read and write to the same pin? You can't do that, a pin can only be an output or an input. Instead you can feed the signal that is driving the pin to the dashboard, via other nodes if necessary to set the text.
By the way, in order to simplify the question it is best just to concentrate on the bits that don't work, rather than complicate it with all the bits that do, though it is great that you have managed to get most of it going already :slight_smile:

Hello.
First of all I apologize for the bad translation, I asked Google Translate for help because my English is very limited.

I do not know if I am breaking any rule by reactivating this post that has been inactive for more than two years ... if so, surely someone will give me a wake-up call.

I am in the same situation as @S72TM or so I think, and I think that either it was not explained enough or it was not understood what he meant. I explain my case to see if it is the same or I am lost and above all, see if it can be solved.

I have a network with several devices, including several Raspberry Pi, these raspi can be controlled remotely (from the master) or locally (from pushbuttons). In addition, if it is controlled from the master, it can be by buttons on the dashboard or from Cron according to an established schedule. In the slave raspi I can install a script that receives and sends states and commands, in fact it works that way, but having Node-RED, why not use it? Node-RED offers friendlier programming.
The problem is that I want to indicate the state of the pins in the dashboard (later I will expand it to show with physical LEDs on the slave raspi as well), and I have no way (or rather, I don't know how) to know if a pin of output is activated or not from Node-RED. Let's see, from the programming panel you can see it, in the programmed flow I see the status at 1 or 0, but I don't know how to transfer that information to a node, a variable or a function node to process it.

I do not know if I explain myself well, in short it is about knowing the current state (1/0 - true/false - on/off - activated/deactivated) of a pin configured as an output, not to read the input of this pin (I promise I have done searches in the forum and in Google, but either I am not searching correctly or no one else has really had this question).

I think I extended a bit ... :slight_smile:


Captura 1

At the moment I created a global variable in the slave raspi in which I keep control of the states, and each time a state change is sent to a pin either from the dashboard or from a local pushbutton or from Cron, said change is updated in the global variable. This global variable is the one that is constantly forwarded to the master raspi to display the states.

This all works, but it seems like a very inelegant way to approach the problem, I suppose there must be a simpler and above all more secure way to get the states.

Any suggestion?

A much more elegant way is to use MQTT. That can be used to retain the previous value of data and also to communicate the value between different devices. If you don't know about MQTT then read this tutorial, it will tell you virtually everything you need to know. If you have any further questions then probably best to start a new thread. MQTT Essentials - All Core Concepts explained

Thanks @Colin, I did not want to open a thread so as not to derive this one because it fits my query, but yes, in case more questions arise I will open a new one.
I have not read about MQTT, I will read a little about it to see, but I have been reading about the construction of modules and I see that with a small Python script I can have exactly what I want, what's more, I already have the script because as I said Before, I did it with a Python script built on a Flask server that sent the data through GET and POST at regular intervals, it would be just a couple of small changes and I would have it to my liking.
I think that MQTT is not going to adjust to what I want because I am not interested in transporting the retained data between the flows, the case is that the master device receives the data from a slave, in turn it can order it to activate / deactivate an output, but Said output can also be changed state locally from the slave and it can also be done by dashboard or by physical push-button that triggers the flow directly, so what I want is to supervise those outputs and know what state they are in so that the master always indicates correctly.
I think I am going to try to pack a new module, in this case deriving from the rpi-gpio, in fact I think you can take advantage of a lot of its code, or perhaps create a new one because ultimately it would not be more than a small script reading the state of the output without anything else because it could be launched from an inject, a timer or a cron and not having to do threads that are consuming resources.

That is exactly what MQTT can do for you.

Vale, pido perd贸n de nuevo. Es que no me estoy explicando bien.
En el dispositivo master tengo Node-RED, y este simplemente recibe los datos y toma decisiones sobre las 贸rdenes que da a los esclavos, hasta ah铆 bien.
El meollo est谩n en uno de los esclavos, es una Raspberry que hasta ahora la ten铆a trabajando con Flask y por medio de Python obten铆a los datos y los enviaba al maestro por medio de GET y POST.
El inconveniente es que en la Raspberry esclava quit茅 Flask e instal茅 Node-RED, y es aqu铆 donde se genera el problema, ahora desde el esclavo quiero obtener los estados de las salidas (con las entradas no hay problema, hay m贸dulos para eso pero no hay m贸dulos que recojan el estado de las salidas, o yo no los conozco). De momento en el flujo del esclavo tengo una variable global que almacena el estado y cuando recibe una orden de cambio de estado la actualiza para reenviar al maestro. Lo que pretend铆a es prescindir de tener que estar controlando el estado de esa variable porque implica varios m贸dulos s贸lo para ella, y lo que intentaba es obtener el estado de la salida en vivo al enviar los datos.
Perd贸n por tanto l铆o.... :sweat_smile:

I think you forgot to translate that, but I think I basically understand. Have you worked through the tutorial? You cannot understand how MQTT can help unless you first understand about MQTT.

MQTT takes the place of the variables saving the states, so the value is available anywhere on any of your systems.

Oops ... I took the copy on the left side... :grimacing:

No, no, I have not read about MQTT, I only thought about what you told me that it stores and transports the previous states. I will read about MQTT first before commenting.

That seems interesting to me ... I'll read about it maybe it fits what I'm looking for. Of course, to get rid of global variables, I see that yes, I am left wondering about obtaining the current state of the output ... although now, as I write, I realize ... if any of the inputs I inject them with MQTT Well, I don't read the current status, but I do know at all times what is the last thing that was ordered to do, so that if it can help me.

Not only that, but if you use a Retained topic then on restart you can make it restore outputs, dashboard switches and so on. to the previous values.

Ok, that's even more interesting, now I do it the ass, involving a lot of variables ...
I already started with the tutorial ... to see if in a few days I can get something clear. Thanks for the directions.
As usually happens, if there is no more news from me, everything is fine ... :stuck_out_tongue_winking_eye:.

No, no, I threaten to return ... and soon I fear ...