good morning , i need help i want to control solenoid valve 12 v by a raspberry 5 v and use python prog via MQTT and the switch that i will use it to control solenoid valve is in node red dashboard how i can do that please
Are you asking how to organise the hardware to connect a 12v solenoid to a Pi? If so then I don't think this is the right place to ask that.
I don't understand what you mean 'use a python prog via MQTT' but again that does not appear to be node-red related.
If the node-red part of the question is how to publish information to MQTT when you press a dashboard button then all you have to do is to connect the button to the MQTT node, so you need to explain what is not working.
this is my python code that i use it to control solenoid valve by the switch in node red dashboard and i ask how i connect raspberry 5 v with soleinoid valve 12 v i use the
relay but don't know if its the good solution or not
As I said, a node-red forum is not the best place to ask a question about how to connect the solenoid.
However, I would ask why you are using python. Why don't you use node-red to drive the GPIO directly?
i use the python because i use the raspberry and i use the node red and mqtt to control the soleinoid valve by a switch in node red via mqtt " remote server"
Do you mean that the python code is running on a different machine to node-red?
python code i use it to connect raspberry and node red by using MQTT and the the switch in node red dashboard to control on / off the solenoid valve that i use it with raspberry
You just keep stating the same information without answer the question.
- Is node-red running on the same pi that you are running the python code? Yes or no.
- If so then why not use node-red to subscribe to the MQTT broker and drive the GPIO, why do you need to use Python?
yes node red is running on the same raspberry that i run the pythgon code , secondly i don't know an other solution to drive GPIO and using MQTT to connect raspberry and remote server node red i just know the python
it's clear..???
This should get you started
https://cookbook.nodered.org/mqtt/
thank you @Colin