Skip to main content

Example: Greenhouse Simulator

Product: CODESYS IIOT Libraries SL

This example uses a greenhouse simulator to show how to use cloud communication with AWS IoT Core AWS Service.

Description

The example uses a greenhouse simulator to show how to use communication with the "AWS IoT Core" AWS service via the AWS IoT Core Client SL library. The library is part of the CODESYS IIoT Libraries SL product. The program simulates two greenhouses which read the target values from the cloud and send the actual values to the cloud. The visualization of the "Observation and control unit" (OCU) can be used to monitor actual values of the greenhouses and write target values to the greenhouses.

The program needs three devices on "AWS IoT Core", two for the simulated greenhouses, and one for the control unit. The simulators and the control unit are implemented via function blocks and can be operated independently of each other. In the example, the function blocks are called via a single program. The control unit (OCU) has a visualization to set target values (configuration view) and monitor actual values (observation view). The values are stored in "AWS IoT Core" via "Device Shadows". A "Device Shadow" is a JSON file with the actual and the target values.

For more information about "Device Shadows", see: AWS IoT Device Shadow service

Procedure. Getting Started
  1. Download and install the CODESYS package CODESYS IIoT Libraries SL from the CODESYS Store International.

  2. The first thing to do with "AWS IoT Core" is to create three devices with classic device shadows (Greenhouse1, Greenhouse2, and GreenhouseControlUnit) and set up the certificates. For a detailed description of how to use certificates, see the product data sheet of the AWS IoT Core Client SL library.

  3. Open the Greenhouse Simulator.project sample project.

  4. Set your "AWS IoT Core" endpoint to the variable Main.sEndpointName.

  5. Download the application to the controller and run it.

  6. Open http://localhost:8080/webvisu.htm in a web browser.

  7. Click the _example_img_greenhouse_simulator0.png button to switch to the configuration view.

  8. Set the target values:

    _example_img_greenhouse_simulator1.png
  9. Click Apply Changes and press the _example_img_greenhouse_simulator0.png button to switch to the observation view.

  10. Watch the simulated values for the selected greenhouse:

    _example_img_greenhouse_simulator2.png

System requirements and restrictions

Programming system

CODESYS Development System (version 3.5.18.40 or higher)

Runtime system

CODESYS Control Win (version 3.5.18.40)

Add-on components

AWS account with access to AWS IoT Core

Note

_example_icon.png DOWNLOAD Project