Our project "Bin Alert" stems from our understanding for the usage of multiple sensors and actuators. Combined with a conditional function, we can utilize it to achieve numerous interactive functions. The project is inspired a lot from the kinetic wearable project both in terms of coding as well as the building process. Our emphasis on interactivity is demonstrated by combining practicability with entertainment, which can not only be feasible in solving problems, but also bring about enjoyments. This stems from our observation both on campus and in streets of Shanghai. As there are limited numbers of trash bins in the streets and thus may constantly meet with overflow problems. On campus, problems still occur when students keep throwing trash into a garbage bin that has already been full. The project is intended to solve problems regarding the overflow of garbage both in streets and on campus, with clear indications of whether the bin is full or not.
CONCEPTION AND DESIGN
The project "Bin Alert" is a smart garbage bin that serve as an indication for the fullness of garbage that's contained inside. We wanted the signs and indication to be clear, implying that people should no longer throw in garbage when the bin is full. Also, we would like to think of a method to inform relevant people to come and take away the garbage contained inside. In order to achieve this goal, we turned to the usage of ESP WIFI Module, when the hot-spot is connected, it will send a message to a relevant gmail account. For the fullness indication part, we thought of constructing a sign that can show the status of "full" and "not full" on a pad that can switch inside the bin, while leaving holes on the outside of the bin. However, after the user testing period, we quickly find out that this method is actually not that interactive comparing to other alternatives. Also, professor Andy suggested that we can try to make this bin more humanized. We then thought about creating a face of this bin, with its emotions controlled by actuators, which can change according to the state of garbage fullness. Also, we attached a plastic board to an extra servo at the top of the garbage bin, which will block the hole when the bin is nearly full, stopping people from throwing bigger trash inside, but still allowing small garbage to be thrown inside. When selecting the materials, we wanted the outer structure to be as stiff and firm as possible, and the inner structure to take up as less weight as possible while remaining firm at the same time. Ultimately, we chose two layers of cardboard as the outerstructure while using plastic board as the inner structure.
My partner Enes is mainly reponsible for the coding part, while I for the building part. Initially, we thought about using signs to demonstrate the fullness of the garbage bin. However, this idea didn't work out for numerous reasons. First of all, the spinning part of signs did not necessarily coincide with the hole on the surface that we would want it to show through. Also, as the sign is attached inside the bin, audience would have a harder time trying to observe the changes, thus decreasing the interactive function of the the entire project. The ESP WIFI Module part of our project didn't stand out as much as we previously expected. All of these were problems that we found during the user-testing period. luckily, after we consulted professor Andy and Viola for advice, we decided that we should engage in a new approach. Instead of hiding all the signs and indications inside the bin, we should actually make it stand out. Also, we don't necessarily have to make something that's bound to hold practical purpose, as this idea may in some way tangle our brainstorms. We can still point our goal towards bringing entertainment and joy along with the process. Thus, we ultimately devided to give this bin a face that may change accordingly with the fullness of garbage.
For the overall structure, we would want the whole project to be as stable as possible. Thus, we attached two layers of cardboards together to make everything firm. In steps of assembling two sides of cardboards together, I combined the usage of hot-melt glue together with soft iron, fixing them together as stable as possible. About the changeable emoji part, we originally deided to attach the servo directly on the surface, however, this method doesn't turn out to be successful. We decided to cut open several holes that can directly fit the servo inside in the cardboard, enhancing the stability.
For the project, there are four servos attached in all. Three of them are used to demonstrate the changes of emotion, and the other is used to block the opening of the bin when approaching a state of fullness. The three servos move simultaneously when the ultra-sonic detection device reads within a certain number. After 15 seconds of delay, the plastic board that's previously attached to the upper lid of the bin will close, turning in a pre-set angle. (45 degrees to be exact)
For the circuit, it is quite a complicated one which will need external power supply. Also, as our project is based on an ESP WIFI module, we have to do it in a way different from a conventional Arduino microcontroller. As the process involves the sending of messages, the device should be always connected online through hotspot. In order to achieve this, we used specific breadboard with wires directly connected to the wifi module. Afterwards, electric soldering iron is used to spread and connect the lines, together with the emoji servers as well as the bin locker. All of the modules mentioned above is connected and controlled by the if() else() function, which simultaneously function together. There are numerous difficulties that we've run into, regarding the damage of machines and the connection between wires. For several times, we found the servos and the ultra-sonic sensor to be damaged or unable to function its appropriate purpose. To cope with this issue, we checked and excluded every aspect of our project in order to indentify which part exactly is broken. Furthermore, after the user-testing session, we reflected upon our previous work and decided that we will need to redo everything from scratch. However, for the second time, as we've already taken enough experience from the first time, we did it a lot more quickly than previously. In this time, we also tried decorating the outer surface in order to make it simpler. Meanwhile, as our first model works on the turning of signs with a server, it will easily be blocked if there is garbage piled in its way. In other words, any bigger mechanism inside the bin will face the problem of being blocked. Thus, as the second model of our project is directedly powered by the servos, it takes up less space significantly, avoiding this problem while saving up the space inside the bin as well.
Prototype
(inside)
Prototype
(connection)
Prototype
(inside)
Prototype
(connection)
inside servo connection
emoji connection
#include <WiFi.h>
#include <HTTPClient.h>
#include <ESP32Servo.h> // Include the library for ESP32 servos
// Wi-Fi settings
const char* ssid = "OPPO Find X7 Ultra";
const char* password = "e6g6nn76";
// Server address
const char* serverName = "http://194.32.141.194:5000/api";
// Pins for the ultrasonic sensor and LED
#define TRIG_PIN 12
#define ECHO_PIN 4
#define LED_PIN 0
#define SERVO_EMOJI_PIN 25 // Pin for the emoji servo (face)
#define SERVO_BROW_LEFT_PIN 26 // Pin for the left eyebrow servo
#define SERVO_BROW_RIGHT_PIN 14 // Pin for the right eyebrow servo
#define SERVO_LOCK_PIN 13 // Pin for the lock servo
// Threshold distance value
const int thresholdDistance = 15;
// Variables for state
Servo servoEmoji;
Servo servoBrowLeft;
Servo servoBrowRight;
Servo servoLock;
bool isFull = false;
bool awaitingMotion = false;
// Connecting to Wi-Fi
void setupWiFi() {
Serial.print("Connecting to Wi-Fi");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("\nConnected to Wi-Fi!");
}
// Function to measure distance
long measureDistance() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
long duration = pulseIn(ECHO_PIN, HIGH);
long distance = duration * 0.0343 / 2;
Serial.print("Measured distance: ");
Serial.print(distance);
Serial.println(" cm");
return distance;
}
// Function to send data to the server
void sendDataToServer(bool isFull) {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin(serverName);
http.addHeader("Content-Type", "application/json");
String postData = isFull ? "{\"status\": \"full\"}" : "{\"status\": \"not_full\"}";
int httpResponseCode = http.POST(postData);
if (httpResponseCode > 0) {
String response = http.getString();
Serial.println("Data sent successfully");
Serial.println(response);
} else {
Serial.print("Error sending data: ");
Serial.println(httpResponseCode);
}
http.end();
} else {
Serial.println("Wi-Fi Disconnected");
}
}
// Function to control the emoji servo (face)
void updateEmojiServo(int angle) {
servoEmoji.write(angle);
delay(500); // Delay for the servo to move
}
// Function to control the eyebrow servos
void updateBrowServos(int angleLeft, int angleRight) {
servoBrowLeft.write(angleLeft); // Control the left eyebrow
servoBrowRight.write(angleRight); // Control the right eyebrow
delay(500); // Delay for the eyebrow movement
}
// Function to lock the trash can
void lockTrashCan(bool lock) {
if (lock) {
servoLock.write(45); // Turn to 45 degrees to lock
Serial.println("Trash can locked.");
} else {
servoLock.write(0); // Return to 0 degrees to unlock
Serial.println("Trash can unlocked.");
}
}
// Setup function
void setup() {
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
// Attach the servos
servoEmoji.attach(SERVO_EMOJI_PIN);
servoBrowLeft.attach(SERVO_BROW_LEFT_PIN);
servoBrowRight.attach(SERVO_BROW_RIGHT_PIN);
servoLock.attach(SERVO_LOCK_PIN);
setupWiFi();
}
// Main loop function
void loop() {
long distance = measureDistance();
if (distance < thresholdDistance) {
if (!isFull) {
// Trash can is full, turn on LED, show a sad face, and lower eyebrows
Serial.println("Trash can is full. LED on, emoji is sad, and brows are down.");
digitalWrite(LED_PIN, HIGH);
updateEmojiServo(180); // Sad face
updateBrowServos(130, 40); // Lower eyebrows (both servos at 45 degrees)
sendDataToServer(true);
lockTrashCan(true); // Lock the trash can
isFull = true;
awaitingMotion = true;
} else if (awaitingMotion) {
// Waiting for movement after the trash can is full
Serial.println("Additional motion detected in a full trash can.");
updateEmojiServo(240); // Face of irritation
awaitingMotion = false;
}
} else {
if (isFull) {
// Trash can is not full, reset state to a smile and raise eyebrows
Serial.println("Trash can is not full. LED off, emoji is happy, and brows are neutral.");
digitalWrite(LED_PIN, LOW);
updateEmojiServo(0); // Smile
updateBrowServos(0, 0); // Eyebrows in neutral position (both at 0 degrees)
sendDataToServer(false);
lockTrashCan(false); // Unlock the trash can
isFull = false;
}
}
delay(5000); // Delay 5 seconds before the next measurement
}
ReplyForward
CODE for server
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from flask import Flask, request, jsonify
app = Flask(__name__)
# Конфигурация для отправки email
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
EMAIL = 'testup.kz@gmail.com'
PASSWORD = 'mhwt udgu kenn ehex'
def send_email(subject, message, recipient):
msg = MIMEMultipart()
msg['From'] = EMAIL
msg['To'] = recipient
msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain'))
try:
server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
server.starttls()
server.login(EMAIL, PASSWORD)
server.sendmail(EMAIL, recipient, msg.as_string())
server.quit()
print("Email sent successfully")
except Exception as e:
print(f"Failed to send email: {e}")
@app.route('/api', methods=['POST'])
def update_status():
data = request.get_json()
container_status = data.get('status')
if container_status == 'full':
subject = "Container Full Alert"
message = "The container is full and needs to be emptied."
recipient = "enessissenbi@gmail.com" # Замените на адрес получателя
send_email(subject, message, recipient)
print(f"Container status: {container_status}")
return jsonify({'message': 'Status received'}), 200
if __name__ == '__main__':
app.run(debug=True)
ReplyForward
The final version of our project mostly meets our anticipated goal, as we've already built a garbage bin that's capable of indicating its fullness through emojis and blocking itself. Also, the wifi module performed better than we expected. The final result has significantly improved from the version of the user-testing session. In the interaction process, users can not only use it for practical purpose, but also receive feedbacks given by the bin itself, thus "Bin Alert". However, there are still quite some flaws with the device, as it still cannot detect the fullness with adequate accuracy, and from time to time it may also become unstable. When users throw in trash, delay problems may still occur occasionally. Regarding its interactive level, as the primary part of our project focuses on practical purpose and the sending of email, it requires limited amount of interactivity but more for practical usage. If having the opportunity to adjust and imporve, we would try to give the bin more of human's personality, beyond merely giving emojis. This will enhance the level of interaction while keeping its practical purpose as well.
Overall, this opportunity serve as the first time that I've been fully engaged in the building process of an interactive project. Of all the steps of process I've been through, each step provides me with help in different ways. The initial planning process gives us a hint of the direction of our project, while the users-testing session deliberately reveals in what level are we processing and exactly in which parts can we make improvements. And the report of our final project serve as a summary that reflects the good parts of our project and its flaws in the same time. In conclusion, Bin Alert is an interactive device that can also be a mean of solving real life issues. It holds a moderate amount of interactivity and can also be entertaining in some ways.