I'm using an IOT from where I collect a digital signal coming from a photocell and transform it into a data insertion in a database, but I want to send it through mqtt from the IOT to a PC. It makes the connection ok but I'm not able to make the mqtt works. All this works in the same red.
You can use an mqtt broker in your local network or even on the internet.
On your local network is generally easiest.
The reason I asked what broker you have was to find out if you need any extra setup steps to make it accessible from all the devices on your network.
A commonly used broker is Mosquito. There is also Aedes broker which runs inside Node-red but is less powerful.
Make sure that you have done all the necessary steps in the section " Enable Remote Access/ Authentication".
It is not specific to installing on a Pi, though I admit I have never installed on any other platform.
Maybe this will help you understand. With MQTT there are publishers, a broker and subscribers. These three parts could be on one or more devices. Let's say you setup a broker on a Pi Zero W and it has an IP address of 192.168.1.10.
it's just sitting there waiting for a publisher or subscriber to connect to it.
Now you have this IOT device with an IP of 192.168.1.50. The IOT device wants to publish data so it is a 'PUBLISHER'. It needs to send it's messages to a 'BROKER' using a 'topic' so it points at the existing BROKER at 192.168.1.10 so now you have:
The IOT device doesn't care where the subscriber(s) are, that is the BROKERs worry, it just publishes data with a particular 'topic'
Now you have another device (your PC let's say it is IP 192.168.1.200) running NR and it wants to receive the data from the IOT device. The MQTT-IN node needs to point at the BROKER and 'subscribe' to the TOPIC that the IOT device is using. So you have
Now when ever the Broker receives a msg, it looks at the topic and sends it to any device that has subscriber to that topic. Is =o if you have another device at 192.168.1.124, and it subscribed to the same topic, when ever the IOT published a msg, the broker would send that msg to the PC and the other device.