RoanBrand / MQTT-Siemens-S7-300

MQTT library block written in Siemens SCL for S7-300 PLC with CP343-1
89 stars 46 forks source link

Can't connect with mosquitto (CPU313C and CP343-1 Lean) #8

Open GerritMeu opened 1 year ago

GerritMeu commented 1 year ago

Hi, I'm using the hardware that has been used in the test of the maker.

Unfortunately, it does not connect. What can I do possibly wrong?

The IP-Address of the internal adapter has to be configured within the hardware configuration tool (HW Config), click on the PN-IO object IP address is 192.168.0.1 of the CP module with subnet 255.255.255.0 The connection must be configured in Simatic Manager "Connections" Has been made, see attachment you must set the MQTT Functionblock parameter connectionID to the connection ID configured in Simatic Manager "Connections" What is the connection ID? I used now the backplane connection, see attachment _you must set the MQTT Functionblock parameter cpLADDR to the address of the CP module. Example for a MQTT FB call in OB1 configured for external Ethernet (CP)usage: MQTT.DB71(net_config := DB_NETCONFIG, connectionID := 1, cpLADDR := W#16#100); I compiled the example and changed connectionID to 3 (because it is the backplane connection MPI address, is that correct?). I kept cpLADDR the same, because start address is 256 and that 16#100

Did I do something wrong?

Connections StartAddress MPIaddressAsConnectionID

RoanBrand commented 1 year ago

Hi, I unfortunately do not have much of an answer for you, sorry. I started this ages ago before there was much regarding MQTT when it came to PLCs. And I myself haven't worked with them in a while.

I saw a while ago there has been later development on MQTT client libraries for Siemens. Maybe I can refer you to this after a quick search: https://cache.industry.siemens.com/dl/files/872/109748872/att_1006438/v4/109748872_MQTT_Client_DOKU_V2-1_en.pdf

That said, just after I started this @CarstenMaul did a lot of refactoring and changes. Maybe he can help with this specific question/problem.

Jansen1443 commented 1 year ago

Hi GerritMeu,

Was curious if it had still worked out. We have several s7-300 and s7-400 and would like to connect them to MQTT as well. I just can't manage to get RoanBrand's example into step7 v5.6. Can you help me with this?

Greetings and thanks in advance.

GerritMeu commented 1 year ago

Hi GerritMeu,

Was curious if it had still worked out. We have several s7-300 and s7-400 and would like to connect them to MQTT as well. I just can't manage to get RoanBrand's example into step7 v5.6. Can you help me with this?

Greetings and thanks in advance.

Hi Jansen1443,

It worked, but because I had a lack of trust that it complies with the MQTT v3.1.1 specification, I use Node-RED now. Also for the Sparkplug B implementation. I had help @ the Siemens forum to get it going: https://support.industry.siemens.com/forum/ww/en/posts/mqtt-protocol-with-cpu314c-2dp-and-cpu315-2dp/289286/?page=0&pageSize=10

I added my project wherein it worked, you can see the result also in the forum that I shared. In the project, I also added a VAT table wherein you can connect, disconnect etc.

Good luck!

Uns_mqtt_sparkplugb_17OCT22.zip