OpenPLC with Python FB
In this article, you will learn how to use Python FB in OpenPLC Editor and send the PLC data to the ThingsBOard's Cloud Dashboard.
OpenPLC with Python FB- Sending PLC Data to the Cloud
What This Project Does
Watch Full Walkthrough with LIVE Demo
System Architecture
What is a Python Function Block?
Aspect
Standard IEC Function Block
Python Function Block
The Two Required Functions
How Variables Work in Python FBs
Example 1: Console Print (shm_in Only)
Main ST Program: Example 1
Variable Table
Main ST Program
Understanding the Sine Wave Generator
SIN value
Temperature
Python FB Code: Example_1
Variable Table
Python Code
Example 2: ThingsBoard Cloud Integration
Variable Table
ThingsBoard Cloud Setup
Python FB Code
Main ST Program
Key Gotchas: Lessons Learned
1. Use time.time() for intervals β not loop counters
time.time() for intervals β not loop counters2. Always import time
import time3. Declare ALL persistent variables as global in BOTH functions
global in BOTH functions4. Avoid special characters in comments
5. ThingsBoard Cloud requires HTTPS
When to Use Python vs ST vs C++
Task
Language
Hardware and Software Used
Component
Details
Keynotes
π Resources
β₯οΈ Work With Me
Last updated