PYTHON FOR ENGINEERS
Python for Automation Engineers: What to Learn and What to Build
Where Python fits beside a PLC, the libraries worth learning first, five projects that pay back quickly, and the rules that keep a script from upsetting a running plant.

Python for automation engineers is worth learning because it handles what a PLC should not: reading plant data over Modbus or OPC UA, cleaning and analysing it with Pandas, automating reports and building machine learning models. It runs beside the PLC, never instead of it. Start with plain Python on exported data, then connect to a simulator.
In this lesson by APMonitor.com, moving data with Modbus, OPC and SQL is introduced from the Python side. Watch it for the overview, then use the notes below to plan what to learn and build.
Where Python fits beside a PLC
Think of the plant in layers. The PLC runs the machine every scan, with deterministic timing and, where needed, certified safety. SCADA shows and records the process. Python sits alongside both as a client: it asks for data through the same protocols SCADA uses, does something useful with it, and hands the result to a person, a database or a dashboard.
That position gives you one firm rule: Python reads, analyses and reports. It does not control the machine and it never sits in a safety path.
What automation engineers actually use it for
- Reading plant data. Pull values from PLCs, meters and drives over Modbus or OPC UA, or from historian and SCADA exports.
- Cleaning and analysing. Resample messy logs to regular intervals, fill or flag gaps, group by shift or batch, compare lines.
- Automating the boring work. Turn a monthly meter export into a report, check a tag list for duplicates, generate I/O lists from a spreadsheet, parse alarm logs to find the ten worst offenders.
- Moving data. Publish values over MQTT, write them to a database, or feed a dashboard.
- Predicting. Once the data is clean and has history, build models for predictive maintenance or anomaly detection.
The libraries worth learning

Learn plain Python first: variables, lists, dictionaries, loops, functions, reading files and handling errors. Then pandas, because nearly every plant data job ends up as a table with a time index. After that, pick one protocol library for the equipment you work with: PyModbus covers Modbus RTU and TCP, client and server, and asyncua covers OPC UA clients and servers. Machine learning comes last, and it only works if the earlier steps were done well.
Five first projects that pay back
- Energy report from a meter export. Load a year of 15-minute readings, resample to daily and monthly totals, chart them and flag missing days. This is the classic first notebook and useful in almost any plant.
- Alarm league table. Read an alarm log export, count alarms by tag and by shift, and list the ten that fire most. It often shows nuisance alarms nobody had counted.
- Modbus reader against a simulator. Run a Modbus server simulator on your laptop, read a block of holding registers with pymodbus, scale them to engineering units and print them. Then handle the case where the server stops responding. Our Modbus tutorial explains the register maps.
- OPC UA subscriber. Build a small OPC UA server in Python with a simulated variable, then a client that subscribes to it and logs every change. See OPC UA explained.
- Downtime log to a database. Record machine state changes with timestamps into SQLite and query total downtime per day with SQL.
Each one is small, finishes in a weekend, and gives you something to show in an interview.
Rules for scripts that touch a plant

The most important is the first. Writing to a running PLC from a script can start equipment or change a setpoint without anyone at the machine knowing. Keep scripts read-only unless the person responsible for the plant has agreed, in writing, what may be written and when. Poll at sensible intervals, because a loop that asks a PLC for data as fast as it can may load its communications. Handle dropped connections, log what the script does, and always prove it against a simulator first.
Python for automation engineers: a learning plan in four stages
- Plain Python on files. Work in Google Colab, which is free and needs no setup, so there is nothing to install. Read a CSV export, loop through rows, write a function that converts a raw 4 to 20 mA value to engineering units (check your answers against our free engineering calculators), and handle a file with a missing column without crashing.
- Pandas and charts. Load a real export into a DataFrame, set a time index, resample to hourly means, group by shift and plot a trend. Most everyday plant analysis lives here.
- Live data from simulators. Install Python on your laptop, run a Modbus or OPC UA simulator, and read from it. Add logging, reconnection and a sensible poll rate.
- Storage, dashboards and models. Write readings to SQLite, query them with SQL, chart them, and only then try a model that predicts or flags something.
Keep every notebook and script from each stage. Together they are a portfolio that shows, better than any certificate, that you can turn plant data into something useful.
How long does it take?
With an automation background, the basics of Python and Pandas take a few weeks of evenings, because the data already makes sense to you. Protocols then take days rather than weeks, since you already know what a holding register or an OPC UA node is. Machine learning is a longer path; our post on free machine learning for engineers sets it out, and predicting machine failure in Colab is a worked example.
Python and the PLC languages
Structured text will feel familiar: IF, CASE, FOR and WHILE all exist in Python, just spelt differently. The big differences are that Python does not run in a scan cycle, has no built-in timers bound to I/O, and does not stop you from doing something slow. Write it like a careful engineer, not like a PLC program.
Learn it free
Python for AI and Engineering Data teaches Python from zero on engineering data in Google Colab, ending with a year of plant energy data cleaned and reported. Industrial Data with Python reads Modbus and OPC UA devices, publishes over MQTT and stores time series, all against simulators. SQL for PLC and SCADA Engineers covers the database side, and Machine Learning with Python comes next. The industrial AI engineer path and all free AI courses show the wider route. Learning is free in full. Python for AI and Engineering Data is a beginner course: if you pass its final assessment, the optional EDWartens Certificate of Completion is a small one-off fee, US$8.99. It is verifiable at edwartens.com/verification and is not a university or vendor qualification.
Take the free course
Questions
Should a PLC engineer learn Python?
It is worth it once you are comfortable with PLCs. Python does not replace the PLC, but it lets you read plant data, clean and analyse it, automate reports and try machine learning, which are increasingly part of automation roles.
Can Python replace a PLC?
Not for machine control. A PLC runs deterministic scans, handles I/O in harsh conditions and carries certified safety options. Python on a PC or edge device is for data, analysis and integration beside the PLC.
How do I read PLC data with Python?
Use a standard protocol the PLC already supports: pymodbus for Modbus TCP or RTU, or asyncua for OPC UA. Start read-only, against a simulator, and only then connect to real equipment with permission.
Which Python libraries should an automation engineer learn first?
Plain Python, then pandas for tables and time series, matplotlib for charts, and one protocol library for the equipment you work with, usually pymodbus or asyncua. Add scikit-learn when you reach machine learning.
Do I need to install Python to start?
No. Google Colab runs Python in the browser for free, which is enough for learning and for analysing exported data. You will want Python on your own laptop once you connect to Modbus or OPC UA devices.
Sources
- PyModbus documentation
- FreeOpcUa: opcua-asyncio (asyncua) on GitHub
- pandas: Python data analysis library
- Google Research: Colaboratory FAQ
Written by the EDWartens engineering team for general education. Product names are trademarks of their owners; mentioning them does not imply endorsement. Prices and terms of other providers were checked on the date shown and can change.

Machine Learning for Beginners: What It Is, How It Works and How to Start Free

Data Engineering for Industrial AI: Getting Plant Data Ready for a Model

MQTT Sparkplug B Explained: Topics, Birth/Death and UNS (Video)

Node-RED PLC Dashboard: Read Live Data and Build an Operator Page (Video)

Edge AI in Industrial Automation: When to Run Models on the Plant Floor

Modbus TCP Explained by Doing: Read a Register in 10 Minutes (Video)



