This project focuses on automating the bottle filling and capping process using a combination of pneumatic systems, controllers, sensors, and IoT technology via FAVORIOT. The system aims to increase efficiency and reduce manual labor in the food and beverage industry.


1. System Overview

The automated system will consist of:

  • Bottle Detection: This uses sensors to detect the presence of a bottle.
  • Liquid Filling: A pneumatic system controlled via a solenoid valve.
  • Capping Mechanism: A stepper motor is used to secure bottle caps.
  • Conveyor System: Moves bottles along the filling line.
  • IoT Integration: Monitors real-time status and errors via FAVORIOT.

2. Suggested Controllers & Sensors

2.1. Microcontroller/PLC Options

  • Arduino Mega 2560 (Best for IoT & small-scale automation)
  • ESP32 (For direct WiFi-based IoT integration)
  • Siemens S7-1200 PLC (For industrial applications)
  • Raspberry Pi (For advanced control with vision-based quality check)

2.2. Sensors & Actuators

Component Purpose
Ultrasonic Sensor (HC-SR04) Detects bottle presence
Infrared Sensor (TCRT5000) Detects bottle position on the conveyor
Load Cell + HX711 Module Measures the filled liquid weight
Solenoid Valve (12V DC) Controls liquid dispensing
Stepper Motor (NEMA 17) Tightens bottle caps
Relay Module Controls pneumatic system & conveyor

3. Hardware Setup

3.1. Wiring Connections

Bottle Detection (Ultrasonic Sensor)

  • Trigger Pin → Arduino Digital Pin 7
  • Echo Pin → Arduino Digital Pin 8

Filling System (Solenoid Valve via Relay)

  • Relay IN Pin → Arduino Digital Pin 9
  • Relay VCC & GND → Arduino 5V & GND
  • Solenoid Valve → 12V DC Power Source

Capping Mechanism (Stepper Motor)

  • Stepper Motor Driver (A4988) → Arduino Pins 10, 11, 12, 13
  • Stepper Motor → Power Supply 12V

Conveyor Motor

  • Motor Driver (L298N) → Arduino PWM Pins 5, 6
  • Motor Power Supply → 12V DC

4. Software Development

4.1. Arduino Code for Automation & IoT Integration

This code manages bottle detection, filling, capping, and data transmission to FAVORIOT.

4.1.1. Required Libraries

#include <WiFi.h>  // For IoT (ESP32)
#include <HTTPClient.h>
#include <AccelStepper.h> // For Stepper Motor


4.1.2. WiFi & FAVORIOT Setup

const char* ssid = "Your_WiFi";
const char* password = "Your_Password";
String apiKey = "your_favoriot_api_key";
String deviceId = "your_device_id";

void sendDataToFavoriot(int bottleCount, int errorStatus) {
    HTTPClient http;
    String serverPath = "https://apiv2.favoriot.com/v2/streams";
    
    String jsonData = "{\"device_developer_id\":\"" + deviceId + 
                      "\", \"data\": {\"bottles_filled\":\"" + String(bottleCount) + 
                      "\", \"error_status\":\"" + String(errorStatus) + "\"}}";

    http.begin(serverPath.c_str());
    http.addHeader("Content-Type", "application/json");
    http.addHeader("Apikey", apiKey);
    
    int httpResponseCode = http.POST(jsonData);
    http.end();
}


4.1.3. Ultrasonic Sensor for Bottle Detection

#define TRIG_PIN 7
#define ECHO_PIN 8

long duration;
int distance;

bool detectBottle() {
    digitalWrite(TRIG_PIN, LOW);
    delayMicroseconds(2);
    digitalWrite(TRIG_PIN, HIGH);
    delayMicroseconds(10);
    digitalWrite(TRIG_PIN, LOW);
    duration = pulseIn(ECHO_PIN, HIGH);
    distance = duration * 0.034 / 2;
    
    return (distance < 10); // Detect if bottle is within 10cm
}


4.1.4. Filling Process (Solenoid Valve Control)

#define SOLENOID_PIN 9

void fillBottle() {
    digitalWrite(SOLENOID_PIN, HIGH);
    delay(2000); // Fill for 2 seconds
    digitalWrite(SOLENOID_PIN, LOW);
}


4.1.5. Capping Process (Stepper Motor)

#define STEP_PIN 10
#define DIR_PIN 11

AccelStepper stepper(1, STEP_PIN, DIR_PIN);

void capBottle() {
    stepper.setMaxSpeed(500);
    stepper.setAcceleration(250);
    stepper.move(200);  // Rotate motor to tighten cap
    stepper.runToPosition();
}


4.1.6. Conveyor Control

#define CONVEYOR_PIN 5

void moveConveyor() {
    digitalWrite(CONVEYOR_PIN, HIGH);
    delay(1000); // Move bottle to next station
    digitalWrite(CONVEYOR_PIN, LOW);
}


4.1.7. Main Loop

void setup() {
    Serial.begin(115200);
    pinMode(TRIG_PIN, OUTPUT);
    pinMode(ECHO_PIN, INPUT);
    pinMode(SOLENOID_PIN, OUTPUT);
    pinMode(CONVEYOR_PIN, OUTPUT);

    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
        Serial.println("Connecting...");
    }
    Serial.println("Connected to WiFi");
}

void loop() {
    if (detectBottle()) {
        Serial.println("Bottle detected!");
        fillBottle();
        capBottle();
        moveConveyor();
        
        // Send data to FAVORIOT
        sendDataToFavoriot(1, 0);
    }
    delay(1000); // Wait before next detection
}


5. IoT Dashboard & Remote Control Using FAVORIOT

5.1. Setting Up FAVORIOT Dashboard

  1. Create a Device on FAVORIOT.
  2. Define Parameters: Bottle count, filling status, errors.
  3. Enable Alerts: Notify if liquid is low or if a bottle is missing.

5.2. Remote Control Features

  • Start/stop the filling process remotely.
  • Adjust fill time dynamically via IoT API.
  • Monitor real-time status from a mobile app.

6. Testing & Troubleshooting

Issue Possible Cause Solution
No bottle detection Sensor misaligned Adjust sensor position
Over/underfilling Solenoid valve timing Calibrate filling time
Capping failure Stepper motor not aligned Adjust torque settings
IoT connectivity issues WiFi disconnects Check API key & WiFi

7. Future Enhancements

  • Vision-Based Quality Control: Add a camera to detect defects.
  • Predictive Maintenance: Monitor machine health via IoT.
  • Energy Optimization: Optimize motor and pneumatic system usage.

Conclusion

This project automates bottle filling and capping while providing real-time monitoring and remote control by integrating Arduino/PLC, sensors, stepper motors, and FAVORIOT IoT. This reduces manual labour, increases efficiency, and enables predictive maintenance in production lines.

References

Disclaimer

This article provides a step-by-step guide. The source code may need adjustments to fit the final project design.

Podcast also available on PocketCasts, SoundCloud, Spotify, Google Podcasts, Apple Podcasts, and RSS.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This

Share this post with your friends!

Discover more from IoT World

Subscribe now to keep reading and get access to the full archive.

Continue reading