Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

After adding either, the topic must be set.

...


MQTT

...

"/status" Topic Overview (1 topic)

TopicDatatypeTypical ValuesPublisherDescription

/status

bool1

...

WAGO MQTT Setup

Setting up a WAGO PFC200 PLC requires some configuration.

  1. Open the PLC's web server by entering its IP in a web browser and log in.
  2. Press "Configuration" in the menu bar.
  3. In the left menu, press "Cloud Connectivity".
  4. Press "Connection 1".
  5. Check Enabled.
  6. Set "Cloud Platform" to "MQTT AnyCloud".
  7. Set "Hostname" to the CDPStudio MQTTBroker's IP Address
  8. Set "Port Number" to the chosen port (1883).
  9. Set "Client ID" to a recognizable name such as "Wago".
  10. Set "Data Protocol" to "Native MQTT".
  11. Press "Submit".
  12. Press "Reboot" in the top right corner

The Wago is now configured to send MQTT data to the broker correctly.

CODESYS Creating a Publisher

To use MQTT with CODESYS, the WagoAppCloud library must be imported to the project. This can be done by:

  1. Press "Library Manager" in the current project.
  2. Press "Add Library".
  3. Expand "Application".
  4. Select "WagoAppCloud"
  5. Press OK.

A function block can then be created to simplify the use of the library:
Image Removed

Code Source: https://www.youtube.com/watch?v=UnhG15JFjao&t=822s&ab_channel=JugaadTech

This block can simply be added in a program like this:
Image Removed

Whenever the trigger gets a rising edge, it will publish the message to the broker.

CODESYS Creating a Subscriber

MQTT "/status" Topic Overview (1 topic)

/statusboolPLC

Should be published at the start of every update so CDP can detect loss of connection. Value should always be 1.

MQTT "/settings" Topic Overview (32 topics)

...

TopicDatatypeTypical RangePublisherDescription
/sensor/water/ecfloat0-30PLCWater EC measurement.
/sensor/water/phfloat5-7PLCWater PH measurement.
/sensor/water/tempfloat10-40PLCWater temperature measurement.
/sensor/air/tempfloat?PLCAir temperature measurement.
/sensor/air/humidityfloat?PLCAir humidity measurement.
/sensor/air/co2float?PLCAir CO2 measurement.

PETERFORWIKI"/system" Topic Overview (8 topics)

TopicDatatypeTypical RangePublisherDescription
'/state/valve/tank1/ebb'bool0, 1, 2PLCLight state, 0 Tank 1 drain/ebb valve state. 0 = auto, 1 = off, 1 2 = on.
'/state/valve/tank2/ebb'bool0, 1, 2PLCLight Tank2 drain/ebb valve state. 0 = auto, 1 = off, 1 2 = on
'/state/valve/tank1/flow'bool0, 1, 2floatPLCTime until light 1 toggles on or off, given in hours.Tank1 fill/flow valve state. 0 = auto, 1 = off, 2 = on
'/state/valve/tank2/flow'bool0, 1, 2floatPLCTime until light 2 toggles on or off, given in hours.Tank2 fill/flow valve state. 0 = auto, 1 = off, 2 = on
'/state/valve/threeway'bool0, 1, 2PLCThree-way valve state. 0 = auto, 1 = to reservoir (stirring), 2 = to tank1/2
'/state/pump'bool0, 1, 2PLCPump state. 0 = auto, 1 = off, 2 = on

MQTT "/system" Topic Overview (8 topics)

TopicDatatypeTypical RangePublisherDescription
/system/light1/statebool0, 1PLCLight state, 0 = off, 1 = on.
/system/light2/statebool0, 1PLCLight state. 0 = off, 1 = on
/system/light1/timeRemainingfloat0-24PLCTime until light 1 toggles on or off, given in hours.
/system/light2/timeRemainingfloat0-24PLCTime until light 2 toggles on or off, given in hours.
/system/tank1/statebool0, 1PLC

Tank 1 current state. 0 = ebb, 1 = flow

/system/tank2/statebool0, 1PLC

Tank 2 current state. 0 = ebb, 1 = flow

/system/tank1/timeRemainingboolfloat0, 1-24PLC

Time remaining of tank 1 state. Given in hours.

/system/tank2/timeRemainingboolfloat0, 1-24PLC

Time remaining of tank 2 state. Given in hours.