Smart Home - Arduino Trash Indicator With BLE

14,766

96

27

Nobody likes emptying the trashcan at home, especially when it's too full. Here is a device that indicates the level of the trash in the bin alerting everyone , with the use of a simple mobile app. This small home improvement has lead to a more efficient system.

Follow on to see how this simple device could make your home smarter, with basic skills in electronics, programming and hardware! Do check out the video to better appreciate the project.

If you like what we made, you might like our instrcutables which tackles this system on a larger scale, the bins of the city. Click here to see how we made it.

Do support us by voting for us in the contests, thanks!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: COMPONENTS IN OUR SYSTEM

The basic Model works like so...

To start with you will first have to enter the height of the dustbin. This will help us generate the percentage of trash in the trashcan. We then have two criterias which needs to be satisfied to show that the particular bin needs to be emptied :

1. The amount of trash, in other words let's say if your bin is half full you don't really need to empty it. Our thresh, or maximum amount that we permit of trash, is 75% of the bin. (You could alter the thresh according to your preference.)
2. If supposing a particular trashcan fills up 20% and then for a week doesn't change, it comes into our second criteria, time. With time even the little amount will start rotting leading to a smelly surrounding. To avoid that our tolerance level is 2 days, so if a trashcan is less than 75% but it is two days old it then will also need to be emptied.

With these criterias in mind let's understand the technical part:

• An ultrasonic sensor (A.K.A a distance sensor) will be placed on the interior side of the lid, the one facing the solid waste. As trash increases, the distance between the ultrasonic and the trash decreases.
• This live data will be sent to our micro-controller.Our micro- controller then processes the data and through the help of WiFi sends it to an app.
• What the app does it visually represents the amount of trash in the bin with a small animation.

This process will indicate all the bins which require attention, leading the user to take the most effective steps.

We post all of our projects on Instructables, a place that lets you explore, document, and share your DIY creations. You can also subscribe to our YouTube Channel Here. We post lots of in progress photos and have conversation on our Facebook Page Here and Instagram.

If you like what we make and wish to support us, do it on Patreon here. For work related inquiries contact us on : technovationrobot@gmail.com

Step 3: MATERIALS NEEDED

Hardware:

• Plastic Container (Gearbest) - I found an old plastic container in which all the components could fit. The box is important as you can easily access the components and it's waterproof.
• Ultrasonic Sensor (Gearbest) - An ultrasonic sensor measures distance. It will be attached to the lid indicating the quantity of trash. Our system's key component.

Tools:

Software:

• Arduino IDE
• Blynk - an android app that allows communication with WiFi compatible micro-controllers.

Quick word about Gearbest, you can find all products especially for hobbyists.They have good quality products highly recommended, do check them out!

Step 4: Constructing the Model

It's time to make our very own system to test our concept at home on a small scale! Look for an old small plastic container and make sure your components fit.

Now remove the lid and trace the two ''eyes'' of the ultrasonic sensor. this will be the side facing the bottom of the bin.

Step 5: Drilling the Holes

Now with your biggest drill bit, mine was 10 mm, drill the two holes.If they still are a bit small lightly file them till the ultrasonic sensor snugly fits in, completely flush to the surface.

Step 6: Fit Into the Box

Now with the holes drilled, place all of the electronics into the box, to see if everything fits well. Keep in mind for a small space for the 9 volt battery. Once this is done you can beautify your box by giving it few coats of spray paint!

Step 7: SPRAY PAINTING

We chose white but you could choose whatever colour you prefer. Apply two coats of paint both inside and out, don't forget the cover.

Note: The fumes are toxic do it outside.

Step 8: Installing Drivers and Libraries Necessary

To be able to program the Arduino 101, you need to first install the drivers needed. To check if you already have them installed open the Arduino IDE, click on tools, then boards and look if either Arduino or Genuino 101 in the list. If they are there, skip to next step, if not follow along…

To download the necessary drivers, to be able to use Arduino 101, open the Arduino IDE again, click on tools, boards, then boards manager.

Now in the search bar, search for "Intel curie boards", select your Arduino IDE version and download the one that appears (double check with the picture below)

Once your drivers are installed, go ahead and download the libraries now. For our program to run we need the WiFi101 library, the Blynk library and the ultrasonic library, all three can be found in Arduino IDE's built in library manager. Open to sketch then include library, then library manager.

Now in the search bar, search for WiFi101, Blynk and ultrasonic, choose your IDE version and install. (keep double checking with the pictures below if your not sure about what you are doing)

Step 9: The Circuit

Once you've installed the libraries and drivers, connect the ultrasonic sensor to the arduino.

In our case we used a grove distance sensor which used just three pins to connect to the arduino.

• vcc on sensor goes to 5v on arduino
• gnd on sensor goes to gnd on arduino
• sig of sensor goes to pin 7 of arduino
• nc could remain unconnected

But if you are not using a sensor of this kind, and would like to stick with the regular types which have a trigger and echo pin, a.k.a hc sr04 or something, you need to connect it to the the arduino as shown below. And the code needs to be modified a bit, will explain the details in the next step.

• vcc on sensor goes to 5v on arduino
• gnd on sensor goes to gnd on arduino
• trig of sensor goes to pin 12 of arduino
• echo of sensor goes to pin 13 of arduino

Step 10: Stick the System

Your project is almost complete, simply attach it to the lid by using double sided tape to secure it in place. And remember ultrasonic down!

Go and fetch your dustbin which is ready to be transformed. Any dustbin will do although keep in mind that this system needs a lid.

Cut two strips of double sided tape and stick it on the lid of the box.

Peel, and firmly press it against the lid, then clip your box on.

And there you have it the system now installed, let's move on to the code and the app.

Step 11: The App

Once you've downloaded and installed the Blynk app on your mobile device, go ahead and open it then create a new project. Start by selecting the micro controller you're using, choose the "Arduino 101". And as connection type choose "BLE (Bluetooth low energy)".

(Follow along using the pictures below)

Once that's done you will be sent a mail to your registered email id containing the "Auth token", theAuth token needs to be copied and replaced into the program (explained in the next step)

Now click on the "+" icon on the top right of the screen and add three LEDs. The LEDs need to be assigned to virtual pins 0,1 and 2, and the colors of each led could be changed according to your liking, in our case we made the bottom one Green, the one in the center Orange and the top one Red, indicating the level of your trash from low shown with the Green Led lighting up to high being the Red one.

This is how it should finally look like!

Step 12: The Code

The code is attached below, and like mentioned in the previous step, according to the kind of distance sensor you are using you need to modify the code a bit. If your using an ultrasonic sensor which has just a single signal pin (like the one we're using), there's nothing you need to change.

If you are using the other kind (with the trigger and echo pins) you need to change the "7" on line 17 of the program to "12, 13" (refer to the picture below for help)

Another thing that you will have to change is the Auth token, to the one you will be given through mail while creating the Blynk project (on line no. 9 in the program)

Step 13: Connecting It All Together, Testing!

Once the program is uploaded onto your arduino, and the app is setup, you can begin communicating between the Arduino and your phone. Click on the Bluetooth icon on the app you just created, your Arduino should now show up on the list of BLE devices around, select it and connect.

These are screenshots of my phone as I filled the dustbin. On the blynk application, Green ranges from 0 to 25% full, Orange from 25 to 65% and Red from 65 to 100%. Here are the successful results :

After having put 10% of trash and closing the bin we have the green LED that comes on the other two stay off.

50% full...

...and finally we put all the trash possible, and all three LEDs and a smile lit up! Congratulations the model works : )

After having made one ourselves we realized how widely this system could be used to turn this rather horrible cumbersome chore into a really efficient one!

The way it can impact the city or even a country on a big scale is understandable, and hopefully in the future it is implemented. But other than that each individual can benefit with this concept. A community, an apartment complex or even a house can all use this powerful tool fueled by connectivity of devices to make their life a whole lot simpler!

To conclude, this project on the whole looks promising. We would love to see your versions, or even suggestions or ideas, do drop them in the comment section.
Hope you guys enjoyed this Instructables, let's continue working on ideas to impact our lives and environment. As usual like share, and subscribe so that you don't miss our next projects.

Last thing do vote for it in the HOME IMPROVEMENT 2017 CONTEST and the MAKE A BOX 2017 CONTEST to help us win!

HAPPY MAKING : )

Step 15: POPULAR PROJECTS

If you like what we make check out some of our popular uploads!

Quattro the quadruped robot, see the instructables

You must see the video the fully appreciate it WATCH the video HERE

Participated in the
MacGyver Challenge

Participated in the
Box Contest 2017

Recommendations

• Internet of Things Class

22,085 Enrolled

27 Discussions

Can I use esp32 module instead of Arduino 101 .
Because esp32 has also has BLE.
And can you tell me how to edit the code when we use esp32 for this project.

I am a bit confused. I'm adding two photos from your project page and have encircled the parts I am confused about. Can you tell me what they are and if I need them to make this project?

That is an mkr1000 microcontroller which lets you use wifi instead of ble, you can do without it

Arduino: 1.8.5 (Windows 8), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Praveen Patel\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10805 -build-path C:\Users\PRAVEE~1\AppData\Local\Temp\arduino_build_133154 -warnings=none -build-cache C:\Users\PRAVEE~1\AppData\Local\Temp\arduino_cache_566194 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Praveen Patel\Downloads\smart_trash_program\smart_trash_program.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Praveen Patel\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10805 -build-path C:\Users\PRAVEE~1\AppData\Local\Temp\arduino_build_133154 -warnings=none -build-cache C:\Users\PRAVEE~1\AppData\Local\Temp\arduino_cache_566194 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Praveen Patel\Downloads\smart_trash_program\smart_trash_program.ino

Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Build options changed, rebuilding all

Detecting libraries used...

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\PRAVEE~1\AppData\Local\Temp\arduino_build_133154\sketch\smart_trash_program.ino.cpp" -o "nul"

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Praveen Patel\Documents\Arduino\libraries\arduino_353722\src" "C:\Users\PRAVEE~1\AppData\Local\Temp\arduino_build_133154\sketch\smart_trash_program.ino.cpp" -o "nul"

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Praveen Patel\Documents\Arduino\libraries\arduino_353722\src" "C:\Users\PRAVEE~1\AppData\Local\Temp\arduino_build_133154\sketch\smart_trash_program.ino.cpp" -o "C:\Users\PRAVEE~1\AppData\Local\Temp\arduino_build_133154\preproc\ctags_target_for_gcc_minus_e.cpp"

C:\Users\Praveen Patel\Documents\Arduino\libraries\arduino_353722\src/BlynkSimpleCurieBLE.h:25:22: fatal error: CurieBLE.h: No such file or directory

#include <CurieBLE.h>

^

compilation terminated.

Using library arduino_353722 at version 0.4.10 in folder: C:\Users\Praveen Patel\Documents\Arduino\libraries\arduino_353722

exit status 1

Error compiling for board Arduino/Genuino Uno.

very nice project,,can you send your complete code Im using genuino 101..but this is my first time to make this project...

Sure you will find the complete code in the instructables!

If I using Grove Distance Sensor, so what type of ultrasonic should i use in the library?

#define Blynk_PRINT Serial

#include <BlynkSimpleSerialBLE.h>

#include <SoftwareSerial.h>

#include <Ultrasonic.h>

SoftwareSerial SwSerial (10, 11) ; // RX , TX

// You should get Auth Token in the Blynk App.

// Go to the Project Settings (nut icon).

char auth [] = "05cb041df2754c74bd58f43b47cda2e4" ;

SoftwareSerial SerialBLE (10 ,11) ; // RX , TX

//BLEPeripheral blePeripheral();

WidgetLED green(V1);

WidgetLED orange(V2);

WidgetLED red(V3);

Ultrasonic ultrasonic(8,9);

int distance = 0;

int thresh [3] = {20,12,4};

void setup()

{

// Debug console

Serial.begin(9600);

SerialBLE.begin(9600);

Blynk.begin(SerialBLE , auth);

Serial.begin(9600);

delay(1000);

blePeripheral.setLocalName("garbage");

blePeripheral.setDeviceName("garbage");

blePeripheral.setAppearance(384);

Blynk.begin(blePeripheral, auth);

blePeripheral.begin();

Serial.println("Waiting for connections...");

}

void loop()

{

Blynk.run();

Serial.print(distance);

Blynk.run();

if(distance<=thresh[0]&&distance>=thresh[1]&&distance>=thresh[2])

{

green.on();

//Serial.println(1); //debugging sake

}

else if(distance<=thresh[0]&&distance<=thresh[1]&&distance>=thresh[2])

{

green.on();

orange.on();

//Serial.println(2);

}

else if(distance<=thresh[0]&&distance<=thresh[1]&&distance<=thresh[2])

{

green.on();

orange.on();

red.on();

//Serial.println(3);

}

else

{

green.off();

orange.off();

red.off();

//Serial.println(0);

}

delay(100);

// You can inject your own code or combine it with other sketches.

// Check other examples on how to communicate with Blynk. Remember

// to avoid delay() function !

}

the error is :

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\Acer\Desktop\UMS\FYP\Coding\Blynk\sketch_feb23a\sketch_feb23a.ino: In function 'void setup()':

sketch_feb23a:37: error: 'blePeripheral' was not declared in this scope

blePeripheral.setLocalName("garbage");

^

exit status 1

'blePeripheral' was not declared in this scope

"Show verbose output during compilation"

option enabled in File -> Preferences.

can you help me ?

Hye , i change certain item because its very hard to find in my area . .okay , i use arduino uno , bluetooth module hc05 to connect to the blynk apps , ultrasonic sensor hc-sr04 , buzzer . i found the coding in blynk browser . the part of coding sensor i copy in my sketch ,but why still error . .

this is the error messages :

sketch_feb23a:37: error: 'blePeripheral' was not declared in this scope

blePeripheral.setLocalName("garbage");

^

exit status 1

'blePeripheral' was not declared in this scope

"Show verbose output during compilation"

option enabled in File -> Preferences.

Would a clear plastic bin accomplish the same thing?

Not really, our whole concept is to know how much trash is in the dustbin from anywhere in the house. Like a smart home, I guess this will work more efficiently the more the dustbins!

WOW!!! Great idea!! GREAT VIDEO!!! I have a dream to visit your part of the world...one day ....
GREAT WORK!!!

Thanks for all the positive feedback!

I love your idea and the philosophy behind it. Also, the video is very well produced!

Just a couple of suggestions, if you're thinking about producing a lot of these: first, the connector shield is overkill and adds to the cost and the size. The sensor etc. can be connected directly to the Arduino.
Second, an Arduino nano would be smaller, cheaper, and would draw less power. You could use an inexpensive HM-10 Bluetooth BLE module or even an esp8266 wifi module for better range.

With those changes you could save money and use a much smaller enclosure.
Nicely done!