Designing an Industrial Automation System with Raspberry Pi and PyQt5

Designing an Industrial Automation System with Raspberry Pi and PyQt5 Raspberry Pi Industrial Automation HMI GUI designing using PYQT5 Software 5.5 inch Touch Screen 0.jpg 62 ezgif.com webp to jpg converter

Welcome to the exciting world of Raspberry Pi-based industrial automation! Today, we’ll embark on a journey to create a functional Human-Machine Interface (HMI) or Graphical User Interface (GUI) using Python and PyQt5. This is the first installment in our series, and we’re starting with some basics — controlling relays with a Raspberry Pi.

Getting Started: Meet Our Sponsor

Before diving into the technical details, a big shout-out to our sponsor, GF-Robot. They are pioneers in robotics and open-source hardware, providing user-friendly and innovative solutions. If you’re looking to explore the world of electronics, be sure to check out GF-Robot for all your component needs.

Overview of the Project

In this tutorial, we will use the following components to set up our Raspberry Pi-based industrial automation system:

  • Raspberry Pi 3B+: The heart of our system.
  • 5.5-inch OLED Touchscreen: For a dynamic display and interaction.
  • Wi-Fi Keyboard and Mouse: For easy control.
  • 7-Channel Relay Module: We’ll focus on four of these relays.
  • Various Tools and Accessories: Available on ProBoat and Amazon. Links are in the description.

With these, you will learn how to employ Python programming, integrating it seamlessly with your Raspberry Pi to control power loads such as 220V AC bulbs.

Software Tools

Our primary software tools for this project include:

  • Pi Qt5 Software: Perfect for designing HMI applications.
  • Thonny IDE: A sleek Python IDE, ideal for beginners.

This combination allows us to tailor-make a system that controls relays and eventually expands to monitor sensors in more advanced parts of this series.

Subscribe for More Learning

Make sure to subscribe to get updated on parts 2 and 3, where we’ll delve into more advanced features like sensor monitoring and further control of electrical loads. Don’t miss out on any valuable content!

Component Connections and Setup

Designing an Industrial Automation System with Raspberry Pi and PyQt5 Raspberry Pi Industrial Automation HMI GUI designing using PYQT5 Software 5.5 inch Touch Screen 0.jpg 2741 ezgif.com webp to jpg converter

Relay Connections

First, let’s set up the relay module. We’re using a 7-channel relay but will focus on these four relays:

  1. GPIO Pins: Connect relays to GPIO pins 26, 19, 13, and 21.
  2. Ground Connection: Use the gray wire for the ground connection on your Raspberry Pi.
  3. Power Supply: The relay module requires a 12V power adapter.

Image for Relay Setup

Touchscreen Connections

  1. Power Supply: The touchscreen is powered using the Raspberry Pi’s USB board.
  2. Display Connection: Connect the LCD through the HDMI port using an adapter.

Image for Touchscreen Setup

Organizing Your Project

Start by organizing your project files into a dedicated folder. This will help you manage your designs and code efficiently.

Designing the HMI with Qt5

Open your Qt5 Designer Software – a powerful tool for creating advanced Raspberry Pi HMI systems. Here’s how you can use it effectively:

Creating Your GUI

  1. Drag and Drop: This user-friendly feature makes designing intuitive.
  2. Component Selection: Choose from a vast array of components to add functionality.
  3. Configuration: Tailor your GUI to meet your automation needs.

Image for GUI Design Interface

Programming with Thonny IDE

Designing an Industrial Automation System with Raspberry Pi and PyQt5 Raspberry Pi Industrial Automation HMI GUI designing using PYQT5 Software 5.5 inch Touch Screen 0.jpg 6091 ezgif.com webp to jpg converter

Next, open the Thonny IDE to start coding your application that will control the relays:

Writing the Code

import RPi.GPIO as GPIOimport time# SetupGPIO.setmode(GPIO.BCM)relays = [26, 19, 13, 21]for relay in relays:GPIO.setup(relay, GPIO.OUT)# Function to control relaysdef toggle_relay(relay_num, state):GPIO.output(relays[relay_num], state)# Main looptry:while True:toggle_relay(0, GPIO.HIGH)time.sleep(1)toggle_relay(0, GPIO.LOW)time.sleep(1)except KeyboardInterrupt:GPIO.cleanup()

This basic script toggles the first relay on and off every second. You can expand this to control additional relays or integrate with your HMI.

Image for Thonny IDE Interface

Additional Resources

For a step-by-step program explanation, refer to our detailed article available on Electronic Clinic. More programming examples and code snippets can be found there.

Blurb to Attract Further Engagement

“Unlock the potential of your Raspberry Pi with seamless HMI control! Subscribe for the full series.”

Conclusion and Future Insights

In this introductory tutorial, we successfully laid the groundwork for building a Raspberry Pi-based industrial automation system. Stay tuned for the next installments where we’ll expand on this system to include sensor monitoring and advanced control capabilities.

This blog post introduces the core concepts of designing an industrial automation system using Raspberry Pi and PyQt5. It covers essential steps from hardware setup to creating the GUI and programming relays, offering a foundation for anyone interested in electronics and automation technology.