Interface MySQL with PLC

Interface MySQL with PLC


Get access to more than 50+ HQ videos with quiz and resources tp learn how to store PLC data in MySQL database via Node-RED

🗒️ Introduction

The industry data is playing a significant role in the decision-making process. It is very important to know how to fetch data from the shop floor and convert it into information.

There are thousands of sensors on the shop floor which are reading data from the process every millisecond. As a PLC Programmer, we know we cannot store all the information in the PLC memory as it has some limitations. To store the data from the last 5-10 years or more, we need an external database.


In this course, you will learn how to store the data from Siemens S7-1200 PLC or any other controller in an external database like MySQL with the help of Node-RED.

You will learn how to search, insert, update, or delete data from the database via Node-RED programming.

📚 Curriculum

Section 1: Introduction

Course Content
  • What is database?
  • Installing database software - MySQL
  • How to create your first database and table

Section 2: Understanding basic MySQL commands

Course Content
  • How to INSERT values in the database via query
  • How to SELECT values in the database via query
  • How to UPDATE values in the database via query
  • Accessing OPC UA server in PLCnext via Node-RED
  • How to DELETE values in the database via query

Section 3: Database management via Node-RED

Course Content
  • How to connect Node-RED to MySQL
  • How to execute SELECT and INSERT query via Node-RED
  • How to execute INSERT query via Form in Node-RED
  • How to view information on the table in Node-RED
  • How to execute UPDATE and DELETE query via Node-RED

Section 4: MySQL Dashboard on Node-RED

Course Content
  • Node-RED MySQL Dashboard

Section 5: Project 1: Tank Level - Log PLC data in MySQL database

Course Content
  • Exercise 1- How to store PLC data in the database
  • Exercise 2 - Making UI
  • Exercise 3 - Adding timestamp to the database value
  • Exercise 4 - Adding timestamp from PLC Controller
  • Exercise 5 - Logging only when value changes via 'Subscription'
  • Exercise 6 - Logging only when value changes via 'rbe' node
  • Exercise 7 - Logging only when value changes - Industrial Example
  • Exercise 8 - Making a chart from database values - Industrial Example
  • Exercise 9 - Adding another value in a chart - Industrial Example
  • Exercise 10 - Comparing values from two processes in a Graph
  • Exercise 11 - Sorting values based on timestamp

Section 6: Synchronize Data between PLC and MySQL

Course Content
  • Exercise 1- Sync from PLC to Database - Case 1
  • Exercise 2 - Sync from PLC to Database - Case 2
  • Exercise 3 - Sync from Database to PLC

Section 7: Project 2: 3D Camera/RFID - Log real world data in MySQL database

Course Content
  • Exercise 1 - Understanding the project of object measurement and RFID tag reading
  • Exercise 2 - Write PLC data to MySQL Database - 1
  • Exercise 3 - Write PLC data to MySQL Database - 2

Section 8: Project 3: Login/Logout using database

Course Content
  • Introduction to the Login/Logout Project
  • Understanding Password Encryption
  • User registration
  • User login
  • User management
  • Interlocking screens

Section 9: How to generate reports in Node-RED

Course Content
  • Understanding the project
  • How to make a simple pdf file
  • How to generate reports of real time values in pdf

Section 10: How to read/write PLC info with Google SQL

Course Content
  • Understanding the project
  • Setting up database in Google cloud
  • Interfacing Google Cloud MySQL with Node-RED
  • Understanding the Project Part - 1 and 2


👨🏻‍💻 Hardware & Software

The following is the recommended hardware and software to use along with this course:


Computer or Laptop
Well, I hope you would be having it 😎
S7-1200 PLC
It's optional. If you do not have a PLC, you can also use PLCSIM from TIA Portal and interface with OPC UA inside Siemens PLC via Net2PLC. You can also use any other PLC which supports OPC UA or MODBUS
An open-source software
3D Simulation software to visualize industrial control system
MySQL Workbench
To store the PLC or controller information in the database

Check the web-links for hardware and software at this page

💲 Price and Enrollment


Get 10% off by using the coupon code WIKI while checking out

📚 Resources


The students get access to all the presentation, project and Node-RED code used in the lessons