SmartBin

The main purpose of this project is to create an electronic device which uses at least one Raspberry Pi. The team is made of 5 future mechanical engineers and one automation engineer. Our project consists of making a trash can that opens and closes automatically triggered by a foot movement under the motion detector located in the center on the front of the trash can. A Wifi USB stick is used to send data onto a website. This bin is called "The SmartBin". The humorous video above introduces our innovative SmartBin.

In order to carry out this project and this remarkable SmartBin, several tools were necessary:

  • A meter
  • Strong glue
  • An adhesive tape
  • A wood saw
  • A screwdriver
  • A drill machine
  • A clamp
  • A knife

Step 1: SmartBin Equipment

The SmartBin is composed of green, orange and red LED lights which are placed on a fixture on the left side of the bin which will indicate how filled it is. These lights will be clearly visible and will alert the user when it is necessary to replace the trash bag. The programming language used is Python. The measured filling level of the bin is transmitted to the following website: https://guillaumejacquemin3.wixsite.com/website?fb...

Here are the elements that have been used but you can easily find an alternative solution:

  • 1 Bin ("swing cover" bin)
  • 1 Servomotor to open the bin
  • 1 Raspberry Pi 2
  • 2 Power supplies (5V mobile phone charger and 6V power supply) to supply the Raspberry Pi and the servomotor
  • 1 Ultrasonic sensor to measure the filling level of the bin
  • Some LED's to display the filling level (4 green, 2 orange and 1 red)
  • 1 Ultrasonic motion detector to detect a movement
  • 1 16Gb SD-card
  • Electrical resistors (10.000 Ohms, 2000 Ohms and 1000 Ohms)
  • 1 WiFi usb stick to enable wireless transmission to the website.
  • 1 Breadboard and some Raspberry cables

The estimated manufacturing price is 80€.

Step 2: Manufacture of the Raspberry Box and the LED Bar

To manufacture the Raspberry box, use wood saw. Fasten every side of the box with rivets to make it look clean. As its name suggests, this box it will contains not only the Raspberry Pi but will also include the motion sensor which you will place at the bottom. Once the box is built, paint it in the same colour as the bin. 3D printing technology could be use to create this box.

For the manufacture of the LED bar, use an electric duct in which you drill holes to allow the LED lights to be installed. The LED bar has also to be painted. When everything is ready, install the LEDs in the duct and make the electrical connection. Pay attention to properly number each LED cables with adhesive tape. It will help you to identify each LED during wiring.

Finally, attach the box and the LED bar to the front of your bin.

Step 3: The Lid Part

Concerning the lid of the bin, the first step is to glue the servomotor to the lid. An extension of the leverage has to be previously made. The lever will hit a stop which was previously handmade. Attach a screw box to the lid and make a hole in it in order to hold the ultrasonic sensor in the right position. Make sure you correctly attach cables on the lid with tape.

Step 4: Software Part and Data Acquisition

Concerning the software part, we used the python programming language. The program is saved in the SD-card which will be run by the Raspberry Pi when it is turned on. The wiring scheme is available above. The Gpio pins image is available for all the raspberry types on the link below:

https://www.raspberrypi-spy.co.uk/2012/06/simple-g...

It is possible to use an ultrasonic sensor to replace the movement detector, you just need to create an "if loop" in the code.

As mentioned above, the data concerning the level to which the bin is filled are transmitted to a website created on wix.com. On this website, you can find different tabs which gather team members, hardware and software presentation, ... The interesting tab is actually the "Database" tab which collects the information regarding the amount of trash directly from the SmartBin and creates a graph with the data. The graph displays the evolution of the level of the filling. It is possible to see or download datas from the website. The link below is the website we used and will show you how to read and write on google sheets with python:

https://www.makeuseof.com/tag/read-write-google-sh...

Concerning the "autorun part" of the code, write in the terminal:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

Then, in the end of the script which has just opened, write these two code lines:
python /home/pi/main.py &
python /home/pi/csvcontrol.py &

To save the aurorun, press:
Ctrl + O
Then, press:
Enter
Then, press:
Ctrl + X

Write as last code line:
sudo reboot

You are also able to download the attachment which is the full python code used for the project. Both codes are run at the same time !

Here is the main.py code:

import RPi.GPIO as GPIO
import datetime import time import csv

GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False)

capteurP = 7 servo = 17

GPIO.setup(servo, GPIO.OUT) GPIO.setup(capteurP, GPIO.IN)

pwm=GPIO.PWM(17,50)

GPIO.setup(5, GPIO.OUT) GPIO.setup(6, GPIO.OUT) GPIO.setup(13, GPIO.OUT) GPIO.setup(19, GPIO.OUT) GPIO.setup(20, GPIO.OUT) GPIO.setup(21, GPIO.OUT) GPIO.setup(26, GPIO.OUT)

Trig = 23 Echo = 24

GPIO.setup(Trig,GPIO.OUT) GPIO.setup(Echo,GPIO.IN)

GPIO.setwarnings(False)

GPIO.output(5, False) GPIO.output(6, False) GPIO.output(13, False) GPIO.output(19, False) GPIO.output(20, False) GPIO.output(21, False) GPIO.output(26, False)

GPIO.output(Trig, False)

timeset = time.time() distance=100 memory=0 time.sleep(2) pwm.start(12.5)

while True: timetac = time.time() if GPIO.input(capteurP) and timetac-timeset<15: pwm.ChangeDutyCycle(9) print ("ouvert") memory=1 time.sleep(5) else: if memory>0.9: pwm.ChangeDutyCycle(2.5) time.sleep(0.2) memory=-0.5 pwm.ChangeDutyCycle(0) timetac = time.time() time.sleep(0.5) if timetac-timeset>15 or memory>0.4: if memory>0.4: pwm.ChangeDutyCycle(2.5) time.sleep(1) for x in range(0,1): # GPIO.output(Trig, True) time.sleep(0.01) GPIO.output(Trig, False)

while GPIO.input(Echo)==0 and timetac-timeset<17: timetac = time.time() debutImpulsion = time.time()

while GPIO.input(Echo)==1: finImpulsion = time.time() if timetac-timeset<17: distance1 = round((finImpulsion - debutImpulsion) * 340 * 100 / 2, 1) distance2=distance if (distance1-distance2)<1 and (distance2-distance1)<1: distance=round((distance1+distance2)/2,1) else: distance = distance1 print ("La distance est de : ",distance," cm") timeset = time.time() if memory>0.4: dis=round((60-distance)*5/6,1) with open('capteur.csv','w') as csvfile: capteurwriter= csv.writer(csvfile) time_str= datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') print('Time:{0} Quantitee:{1}'.format(time_str, dis)) capteurwriter.writerow([time_str,dis]) memory=-0.1 if distance < 52.5: GPIO.output(5, True) else: GPIO.output(5, False) if distance < 45: GPIO.output(6, True) else: GPIO.output(6, False) if distance < 37.5: GPIO.output(13, True) else: GPIO.output(13, False) if distance < 30: GPIO.output(19, True) else: GPIO.output(19, False) if distance < 22.5: GPIO.output(20, True) else: GPIO.output(20, False) if distance < 15: GPIO.output(21, True) else: GPIO.output(21, False) if distance < 7.5: GPIO.output(26, True) else: GPIO.output(26, False)

Here is the csvcontrol.py code. Don't forget to paste the created ".json" file in the same directory of the main.py. The ".json" file is created with google API. A screenshot is available in the pictures.

import datetime
import time import csv import gspread

from oauth2client.service_account import ServiceAccountCredentials from time import sleep import traceback

timec2='lol' while True: time.sleep(5) loc=('capteur.csv') with open(loc) as csvfile: readCSV = csv.reader(csvfile, delimiter=',') for row in readCSV: print(row[0]) timec=row[0] print(row[1]) distance=row[1] distance=float(str(distance)) if timec2!=timec: timec2=timec print('Time:{0} Quantitee:{1}'.format(timec, distance))

SCOPES = ['https://www.googleapis.com/auth/spreadsheets', "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"] credentials = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json',SCOPES) gc = gspread.authorize(credentials) wks= gc.open("graph").sheet1 wks= wks.append_row((timec,distance))

Share

    Recommendations

    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Fandom Contest

      Fandom Contest
    • 1 Hour Challenge

      1 Hour Challenge

    Discussions