Versions Compared

Key

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

CDPStudio MQTT

CDPStudio MQTT Broker Setup

To set up CDPStudio as an MQTT Broker, the MQTTBroker module must be added to the program.

Image Added

Then, after opening the module and navigating to the table editor, the "ListenAddress" and "ListenPort" properties must be set. The IP should be set to the IPv4 address of the Ethernet Adapter that is used to connect to the PLC, while the port should be set to 1884. The IPv4 address can be found by opening the windows command window and typing the command "ipconfig".

Image Added

Here, the IPv4 address is 158.37.139.100 which is what will be used.

Now the MQTTBroker setup is finished.


CDPStudio MQTT Client Setup

To publish and subscribe, we also need a client. The MQTTClient module must be added to the program. Then, in the table editor, the properties "BrokerHost" and "BrokerPort" must be set to the MQTTBroker's properties.

Adding a Publisher/Subscriber

To add a publisher or subscriber, the modules "PublishTopic<datatype>" and "SubscriberTopic<datatype>" must be added to the MQTTClient. These modules are only found when the MQTTClient is selected, and can be found under the submenus "PublishTopic" and "SubscribeTopic":

Image Added

After adding either, the topic must be set.


MQTT "/status" Topic Overview (1 topic)

TopicDatatypeTypical Values

Updates from the PLS should happen periodically. Maximum 30s between two updates. 

TopicDatatype
PublisherDescription

/status

bool
PLS
1PLC

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 ValuesPublisherDescription
/settings/system/flowtimefloat600-1320CDPStudioHow long the keep the system in flow state in hours.
/settings/system/ebbtimefloat60-240CDPStudioHow long the keep the system in ebb state inhours.
/settings/system/flowtimefloat600-1320CDPStudioHow long the keep the system in flow state in hours.
/settings/system/ebbtimefloat60-240CDPStudioHow long the keep the system in ebb state inhours.
/settings/ebbflow/autobool1 or 0CDPStudio

Whether ebb and flow is controlled automatically (1) or manually (0)

/settings/ph/targetfloat5.8-6.0CDPStudioTarget PH value
/settings/ph/maxfloat6.0-6.2CDPStudioMaximum allowed PH value before system regulates
/settings/ph/minfloat5.6-5.8CDPStudioMinimum allowed PH value before system regulates
/settings/ph/auto
water_ecfloat
bool0 or 1CDPStudioWhether PH is controlled automatically (1) or manually (0)
/settings/ec/targetfloat11-12CDPStudioTarget EC value
/settings/ec/maxfloat12-12.5CDPStudioMaximum allowed EC value before system regulates
/settings/ec/minfloat11.5-12CDPStudioMinimum allowed EC value before system regulates
/settings/ec/autobool0 or 1CDPStudioWhether EC is controlled automatically (1) or manually (0)
/settings/air/temp/targetfloat20.5-21.5CDPStudioTarget air temperature
/settings/air/temp/maxfloat21.5-22CDPStudioMaximum allowed air temperature system regulates
/settings/air/temp/minfloat20-20.5CDPStudioMinimum allowed air temperature before system regulates
/settings/air/temp/autobool0 or 1CDPStudioWhether air temperature is controlled automatically (1) or manually (0)
/settings/air/humidity/targetfloat65-75CDPStudioTarget humidity%
/settings/air/humidity/maxfloat75-80CDPStudioMaximum allowed humidity% before system regulates
/settings/air/humidity/minfloat60-65CDPStudioMinimum allowed humidity% before system regulates
/settings/air/humidity/autobool0 or 1CDPStudioWhether EC is controlled automatically (1) or manually (0)
/settings/air/co2/targetfloat1000-2000CDPStudioTarget CO2 ppm
/settings/air/co2/maxfloat2500-3000CDPStudioMaximum allowed CO2 ppm before system regulates
/settings/air/co2/minfloat500-1000CDPStudioMinimum allowed CO2 ppm before system regulates
/settings/air/co2/autobool0-1CDPStudioWhether air co2 ppm is controlled automatically (1) or manually (0)
/settings/light/light1/timeonstring960-1320CDPStudioHow long to keep light 1 on. Convert to time in CODESYS with STRING_TO_TIME()
/settings/light/light1/timeoffstring120-480CDPStudio

How long to keep light 1 off. Convert to time in CODESYS with STRING_TO_TIME()

/settings/light/light1/timeon

string


960-1320CDPStudioHow long to keep light 2 on. Convert to time in CODESYS with STRING_TO_TIME()
/settings/light/light1/timeoffstring120-480CDPStudio

How long to keep light 2 off. Convert to time in CODESYS with STRING_TO_TIME()

/settings/light/autobool0 or 1CDPStudio

Whether lights are controlled automatically (1) or manually (0)

/settings/valve/exercise/statebool0 or 1CDPStudio

Whether valves should be exercised to avoid debris buildup and relubricate (1) or not (0)

/settings/valve/exercise/timefloat0 or 1CDPStudio

Time interval of how often to exercise the valves given in hours


MQTT "/override" Topic Overview (13 topics)

TopicDatatypeTypical RangePublisherDescription
/override/valve/tank1/ebbint0, 1, 2CDPStudioOverrides the tank 1 drain/ebb valve. 0 = Off, 1 = On, 2 = Auto.
/override/valve/tank1/flowint0, 1, 2CDPStudioOverrides the tank 1 fill/flow valve. 0 = Off, 1 = On, 2 = Auto.
/override/valve/tank2/ebbint0, 1, 2CDPStudioOverrides the tank 2 drain/ebb valve. 0 = Off, 1 = On, 2 = Auto.
/override/valve/tank2/flowint0, 1, 2CDPStudioOverrides the tank 1 fill/flow valve. 0 = Off, 1 = On, 2 = Auto.
/override/valve/threewayint0, 1, 2CDPStudioOverrides the three-way valve. 0 = Off, 1 = On, 2 = Auto.
/override/light1int0, 1, 2CDPStudioOverrides the light 1. 0 = Off, 1 = On, 2 = Auto.
/override/light1int0, 1, 2CDPStudioOverrides the light 2. 0 = Off, 1 = On, 2 = Auto.
/override/tank1/startebbbool0, 1CDPStudioSends a pulse to initiate the ebb process for tank 1
/override/tank1/startflowbool0, 1CDPStudioSends a pulse to initiate the flow process for tank 1
/override/tank2/startebbbool0, 1CDPStudioSends a pulse to initiate the ebb process for tank 2
/override/tank2/startflowbool0, 1CDPStudioSends a pulse to initiate the flow process for tank 2
/override/startprocessbool0, 1CDPStudioSets the process state. Should not be a pulse.

/override/pump

int0, 1, 2 CDPStudioOverrides the pump. 0 = Off, 1 = On, 2 = Auto.

MQTT "/sensor" Topic Overview (6 topics)

TopicDatatypeTypical RangePublisherDescription
/sensor/water/ecfloat0-30PLC
PLS
Water EC measurement.
/sensor/water
_
/phfloat
PLS
5-7PLCWater PH measurement.
/sensor/water
_
/tempfloat
PLS
10-40PLCWater temperature measurement.
/sensor/air
_
/tempfloat
PLS
?PLCAir temperature measurement.
/sensor/air
_
/humidityfloat?
PLS
PLCAir humidity measurement.
/sensor/air
_
/co2float?
PLS
PLCAir CO2 measurement.

PETERFORWIKI"/system" Topic Overview (8 topics)

TopicDatatypeTypical RangePublisherDescription
'/state/valve/tank1/ebb'bool0, 1, 2PLCTank 1 drain/ebb valve state. 0 = auto, 1 = off, 2 = on
'/state/valve/tank2/ebb'bool0, 1, 2PLCTank2 drain/ebb valve state. 0 = auto, 1 = off, 2 = on
'/state/valve/tank1/flow'bool0, 1, 2PLCTank1 fill/flow valve state. 0 = auto, 1 = off, 2 = on
'/state/valve/tank2/flow'bool0, 1, 2PLCTank2 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/
light_
statebool
PLS
0, 1PLCLight state, 0 = off, 1
when on, 0 when off.
= 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-24PLC
light_timeRemainingfloatPLS
Time 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/timeRemainingfloat0-24PLC

Time remaining of tank 1 state. Given in hours.

/system/tank2/timeRemainingfloat0-24PLC

Time remaining of tank 2 state. Given in hours.