DEV Community

Rafael Levi Costa
Rafael Levi Costa

Posted on

Unlocking the Potential of Industry IoT: A Journey of Intelligent Production

“The IoT enables us to collect more data about our world than ever before, and it’s giving us the opportunity to make sense of it.” — Erik Brynjolfsson

🌐 Introduction: Embracing the power of Industry IoT, I was called upon in 2017 by a factory manager to address a production line challenge. The factory relied on an outdated electrical panel for daily item count, but a smarter solution was needed to store and analyze production data in a more stratified manner. This article takes you through my experience and the transformative journey we undertook.

💡 Leveraging Raspberry Pi and Python: To capture real-time production data at various points along the assembly line, we installed Raspberry Pi devices connected to the Programmable Logic Controller (PLC). These devices received production signals and utilized Python scripts to extract and store the data in a SQLite database. Here’s an example of how we captured and saved the data:

import sqlite3

# Connect to SQLite database
conn = sqlite3.connect('production_data.db')
cursor = conn.cursor()

# Read production signal from Raspberry Pi
production_signal = read_production_signal()

# Store production data in SQLite database
cursor.execute("INSERT INTO production_data (timestamp, quantity) VALUES (?, ?)", (current_timestamp, production_signal))
conn.commit()

# Close database connection
conn.close()
Enter fullscreen mode Exit fullscreen mode

🖥️ Real-time Visualization with PHP: To provide real-time insights on the production floor, we developed a PHP-based panel that retrieved and displayed the stratified production data from the SQLite database. Each Raspberry Pi-connected TV screen showcased the data for its respective production line. This empowered operators and managers with up-to-the-minute information. Here’s an example of how we fetched and displayed the data:

<?php
// Connect to SQLite database
$database = new SQLite3('production_data.db');

// Query production data for the current hour
$query = "SELECT strftime('%Y-%m-%d %H:00:00', timestamp) AS hour, SUM(quantity) AS total FROM production_data GROUP BY hour";
$result = $database->query($query);

// Display data in a table
echo "<table>";
echo "<tr><th>Hour</th><th>Total Quantity</th></tr>";
while ($row = $result->fetchArray()) {
    echo "<tr><td>".$row['hour']."</td><td>".$row['total']."</td></tr>";
}
echo "</table>";

// Close database connection
$database->close();
?>
Enter fullscreen mode Exit fullscreen mode

📊 Cloud-powered Data Analytics with IBM Cloud: Taking production analysis to the next level, we integrated IBM Cloud to leverage its advanced capabilities for real-time cloud analytics. By exporting data from each production line, we could cross-reference production insights across multiple lines. The IBM Watson IoT Platform played a pivotal role in securely connecting and receiving data from our IoT devices. This platform offers real-time information on connected IoT devices, facilitating seamless data flow. With the data securely transmitted to the IBM Cloud, we used IBM Cloud Analytics to create a powerful BI dashboard. This allowed us to visualize and monitor production metrics for each line in real-time.

“Data really powers everything that we do.” — Jeff Weiner

By integrating IoT devices, leveraging cloud analytics, and harnessing the power of IBM Cloud, we transformed the factory’s production process. Real-time monitoring and advanced analytics provided actionable insights, empowering operators and managers to make data-driven decisions.

Here’s an example of Python code that sends production signal data to the IBM Watson IoT Platform:

import paho.mqtt.client as mqtt

# IBM Watson IoT Platform credentials
organization_id = "your_organization_id"
device_id = "your_device_id"
auth_token = "your_auth_token"

# Connect to the Watson IoT Platform
client = mqtt.Client(client_id=device_id)
client.username_pw_set("use-token-auth", auth_token)
client.connect("{}.messaging.internetofthings.ibmcloud.com".format(organization_id), 1883, 60)

# Define the production signal data
production_signal = 100  # Replace with your actual production signal value

# Publish the production signal data to the Watson IoT Platform
topic = "iot-2/evt/production-signal/fmt/json"
payload = '{{"d": {{"production_signal": {}}}}}'.format(production_signal)
client.publish(topic, payload)

# Disconnect from the Watson IoT Platform
client.disconnect()
Enter fullscreen mode Exit fullscreen mode

This code establishes a connection to the Watson IoT Platform using the MQTT protocol, publishes the production signal data to a specific topic (iot-2/evt/production-signal/fmt/json in this example), and then disconnects from the platform.

Diagram of this architecture:

Image description

✨ Conclusion: The Industry IoT revolutionizes the way we approach production. By combining edge devices like Raspberry Pi, scripting languages such as Python, real-time visualization with PHP, and cloud-powered analytics from IBM Cloud, we unlock the potential of intelligent production.

In closing, I invite you to join the conversation and share your thoughts and experiences with Industry IoT projects. Let’s discuss the challenges, successes, and future possibilities of implementing IoT in the manufacturing sector. I encourage you to leave your comments and questions below the article, as well as engage with other readers who are passionate about driving innovation in the industrial landscape.

Together, we can create a vibrant community where we exchange knowledge, ideas, and best practices for leveraging IoT technologies to revolutionize the way we produce and operate. As the famous technologist Grace Hopper once said, “The most dangerous phrase in the language is, ‘We’ve always done it this way.’” Let’s challenge the status quo and embrace the transformative potential of Industry IoT.

I look forward to reading your insights and engaging in fruitful discussions that will further advance the field of Industrial IoT. Together, we can shape the future of manufacturing and drive the next wave of industrial revolution.

Top comments (0)