Industrial IoT Gateway Application: Practical Implementation of PLC Data Uploading to Alibaba Cloud

Industrial IoT Gateway Application: Practical Implementation of PLC Data Uploading to Alibaba Cloud

Today, we will discuss how to use a smart gateway to transmit PLC data from the factory to the Alibaba Cloud platform. This solution is particularly suitable for small and medium-sized enterprises that require remote monitoring of equipment status, saving a significant amount of time on manual data collection, allowing real-time production line data to be viewed directly on mobile devices.

1. Hardware Preparation and Wiring

Core Devices: Mitsubishi FX3U PLC (similar models from other brands), a certain brand 4G smart gateway (with built-in Alibaba Cloud protocol), and a 24V switching power supply.

Wiring Steps:

  1. 1. Connect the PLC’s programming port to the COM1 port of the gateway using an RS485 to USB cable (default baud rate 9600).
  2. 2. Connect the DI1 terminal of the gateway to the Y0 output point of the PLC to detect the device’s operating status.
  3. 3. Connect the 4G antenna and power line to the gateway (be careful with the polarity).

Pitfall Guide: Ensure that the grounding wire between the gateway and PLC is properly connected. Last month, I encountered a situation where poor grounding caused sporadic data corruption, and it took me two days to identify the issue!

2. Three Steps to Configure the Gateway

  1. 1. Communication Parameter Settings using the gateway’s accompanying software:
  • • Protocol Type: Modbus RTU
  • • Station Number: 1 (must match the PLC settings)
  • • Data Bits: 8 bits
  • • Stop Bits: 1 bit
  • 2. Alibaba Cloud Integration After creating a product in the [IoT Platform], obtain:
    • • ProductKey
    • • DeviceName
    • • DeviceSecret Fill in the web configuration page of the gateway, and it is recommended to set the heartbeat interval to 60 seconds.
  • 3. Data Point Mapping (taking temperature monitoring as an example)
    PLC Register Address Cloud Platform Identifier Data Type
    D100 temperature float
    Y0 run_status bool
  • 3. Key Points of the PLC Program

    // Data upload trigger logic
    MOV K100 D200       // Set upload interval (seconds)
    CALL TMR T0 K100    // Timer T0
    T0 OUT M100         // Timer trigger upload flag
    
    // Temperature value processing program
    LD M8000            // Normally open contact
    MOV K50 D100        // Simulate temperature sensor value (actual connection to AI module)

    Debugging Tips: First, use the debugging tool provided with the gateway to check the raw data. Once confirmed, enable the cloud upload function to avoid abnormal alerts on the platform.

    4. Operations on Alibaba Cloud Platform

    1. 1. View real-time data in [Device Management]
    2. 2. Create a [Data Visualization] dashboard and drag the temperature curve component.
    3. 3. Set up the [Rule Engine] to send SMS alerts when the temperature > 80℃.

    Handling Emergencies: Last week, I encountered a situation where the gateway showed online but the data was not updating. I later found out it was due to maintenance at the carrier’s base station, and temporarily switching to a backup WiFi network resolved the issue.

    5. Common Fault Troubleshooting Table

    Phenomenon Check Order Recommended Tools
    Platform shows device offline 1. Check SIM card data 2. Ping gateway IP Portable WiFi hotspot
    Abnormal data values 1. Register address offset 2. Floating point format Modbus Debugging Assistant
    Scheduled reporting failure 1. PLC timer contacts 2. Gateway mapping relationship Multimeter to measure trigger signals

    Safety Recommendations

    1. 1. Set up IP whitelisting on the cloud
    2. 2. Regularly change device keys
    3. 3. Backup locally before upgrading the gateway program
    4. 4. Implement dual gateway redundancy for important parameter settings (I have suffered losses from single point failures).

    Next Steps: Install an SD card module on the local gateway to store offline data, which will be automatically uploaded once the network is restored. This feature is currently being tested, and I will share the specific plan with everyone next month. It is recommended to first use the gateway’s built-in storage function to record 24 hours of data to check for any gaps.

    Leave a Comment