1. Project Concept

This project develops a smart trash bin that can automatically sort organic and non-organic waste using sensors and is connected to the Favoriot IoT Platform for real-time data monitoring.

Main Components:

  • Color Sensor (TCS3200) – Detects waste type based on color.
  • Weight Sensor (Load Cell + HX711) – Measures waste weight.
  • Servo Motor – Moves the waste sorting mechanism.
  • Arduino Uno – Controls the entire system.
  • ESP8266 WiFi Module – Sends data to Favoriot IoT Platform.

2. Required Components

Component Function
Arduino Uno Controls the system
ESP8266 WiFi Module Sends data to Favoriot
Color Sensor TCS3200 Detects waste type
Weight Sensor (Load Cell + HX711) Measures waste weight
Servo Motor (SG90 / MG995) Moves the sorting mechanism
Power Supply 9V Powers the system
Breadboard & Jumper Wires Circuit connections

3. Circuit Connections

Color Sensor (TCS3200) Wiring

TCS3200 Pin Arduino Pin
VCC 5V
GND GND
S0 7
S1 6
S2 5
S3 4
OUT 3

Load Cell with HX711 Wiring

Load Cell Pin HX711 Pin Arduino Pin
E+ VCC 5V
E- GND GND
A+ A+
A- A-
DT DT 2
SCK SCK 3

Servo Motor Wiring

Servo Pin Arduino Pin
VCC 5V
GND GND
Signal 9

ESP8266 Wiring

ESP8266 Pin Arduino Pin
VCC 3.3V
GND GND
TX RX (Arduino)
RX TX (Arduino)

4. Arduino Code for Waste Sorting and Data Transmission to Favoriot

#include <ESP8266WiFi.h>
#include <Servo.h>
#include "HX711.h"

#define S2 5
#define S3 4
#define sensorOut 3
#define SERVO_PIN 9
#define DOUT 2
#define CLK 3

const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* server = "apiv2.favoriot.com";
const char* apiKey = "YOUR_FAVORIOT_API_KEY";

Servo servoMotor;
HX711 scale;
WiFiClient client;

void setup() {
    Serial.begin(115200);
    
    // Set color sensor pins
    pinMode(S2, OUTPUT);
    pinMode(S3, OUTPUT);
    pinMode(sensorOut, INPUT);

    // Initialize servo
    servoMotor.attach(SERVO_PIN);

    // Initialize load cell
    scale.begin(DOUT, CLK);
    scale.set_scale(2280.f);
    scale.tare();

    // Connect to WiFi
    WiFi.begin(ssid, password);
    Serial.print("Connecting to WiFi");
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println("\nConnected to WiFi!");
}

void loop() {
    // Read waste color
    String sampleType = getTrashType();

    // Read waste weight
    float weight = scale.get_units(5);

    // Display data
    Serial.print("Waste: ");
    Serial.print(sampleType);
    Serial.print(" | Weight: ");
    Serial.print(weight);
    Serial.println(" g");

    // Control servo to sort waste
    if (sampleType == "Organic") {
        servoMotor.write(0);
    } else {
        servoMotor.write(90);
    }
    
    // Send data to Favoriot
    sendDataToFavoriot(sampleType, weight);

    delay(5000);
}

// Function to determine waste type based on color
String getTrashType() {
    digitalWrite(S2, LOW);
    digitalWrite(S3, LOW);
    int red = pulseIn(sensorOut, LOW);
    
    digitalWrite(S2, HIGH);
    digitalWrite(S3, HIGH);
    int green = pulseIn(sensorOut, LOW);
    
    digitalWrite(S2, LOW);
    digitalWrite(S3, HIGH);
    int blue = pulseIn(sensorOut, LOW);

    if (red < green && red < blue) {
        return "Organic";
    } else {
        return "Non-Organic";
    }
}

// Function to send data to Favoriot
void sendDataToFavoriot(String wasteType, float weight) {
    if (client.connect(server, 80)) {
        String jsonData = "{\"device_developer_id\":\"trashbin01\",\"data\":{\"type\":\"" + wasteType + "\",\"weight\":" + String(weight) + "}}";
        
        client.println("POST /v2/streams HTTP/1.1");
        client.println("Host: apiv2.favoriot.com");
        client.println("Content-Type: application/json");
        client.println("apikey: " + String(apiKey));
        client.print("Content-Length: ");
        client.println(jsonData.length());
        client.println();
        client.println(jsonData);
        
        Serial.println("Data sent to Favoriot!");
    } else {
        Serial.println("Connection to Favoriot failed!");
    }

    client.stop();
}

5. Integration with Favoriot

  1. Register at Favoriot
  2. Create a Device in Favoriot
    • Go to Device Management > Add Device
    • Enter device_developer_id = trashbin01
    • Copy the API Key to use in the Arduino code.
  3. Check Data in Favoriot
    • Go to Streams to view waste data sent from Arduino.

6. Additional Features

  • Monitoring Dashboard: Use Favoriot to create a visual dashboard of accumulated waste data.
  • Telegram Notifications: Add a function to send notifications when the bin is full.
  • AI Integration: Use AI to improve waste classification accuracy.

Conclusion

This Automatic Sorting Trash Bin project enables automatic waste separation with real-time monitoring via the Favoriot IoT Platform. It can help cities and universities manage recycling systems more efficiently.

The future of waste management is smarter with IoT and Favoriot!

Conclusion

This Automated Parking System enables real-time vehicle monitoring via Favoriot IoT Platform. You can enhance it by integrating:

✅ Payment systems for parking fees
✅ Mobile notifications for users
✅ Data analytics for optimizing parking usage

This project demonstrates a scalable smart parking system with IoT and cloud-based monitoring.

References

Disclaimer

This article provides a step-by-step guide and only serves as a guideline. 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