Introduction: Automatic Trash Can
This is a motion detecting automatic opening trash can. It has wifi connectivity and sends a text message when it is full. This is made for ECE-297DP at the University of Massachusetts - Amherst. The main objective of this course was to gain experience with hands-on electronics as I felt I was behind my peers and would benefit me to combine the things I learned from my lectures with experiential work.
- 1x Arduino Uno
- 1x ESP-8266
- 2x Microservos
- 2x Ultrasonic HC-SR04 Motion Detectors
- 1x RBG LED
- 3x 330 Ω resistors
- 1x 3.3 Voltage Regulator
- 2x 100 uF Electrolytic Capacitor
- 1x 0.1 uF Ceramic Capacitor
- 1x Corona Extra 12-pack Longneck Bottle Beer Container
Step 1: Original Plans and Progression
At the beginning of the semester, I had no plans for what I wanted to do. I jumped into this class without an idea in mind. So to start I developed an easy way for me to slowly traverse myself in the world of hobby electronics.
1. Learn the basics of Arduino
- This was done by following the SparkFun inventor guide that comes with the starter kit. It allowed me to learn the basics of resistors, LEDs, piezo elements (sound), sensing, and general coding with Arduino.
2. Look at online DIY Arduino projects
- This was to find some inspiration to make creative and useful electronics
3. Use the inspiration to find what I wanted to make
- Because I am a lazy person, and because my friends that I am rooming with next semester do not clean up very well, I decided to make an automatic trash can.
The original plan for this came with talking to one of my Peer Mentors, Bryan Tam, another Computer Engineering student. Discussing aloud with him critiquing my designs helped me understand the design process. The process of taking a problem and thinking of a solution no matter how unfeasible, and then debating over how to do said project. It taught me that ambition and creativity are paramount for designing in engineering.
Initially, I wanted to make a trash can that would automatically, detect when the trash can was full and then close or wrap the bag. After researching into possible ways to design this, I realized that this was far out of my hands. Thus, I slightly changed the goal - to make a trash can that could send a text when it is full.
Coming near the end of the semester, I was having trouble integrating the WiFi component to send the text and was worried so I thought of other alternatives as an alarm system. I looked towards piezo elements to perhaps make an annoying sound that would not stop until the trash is taken out. Also, I looked into using LEDs to make different colors to indicate the trash level.
To create this, two sensors would be needed: One for the outside to sense when a hand is above it to open, and one on the inside to detect the level of trash. Originally, only the WiFi module would send the text as an alarm but near the end of the semester, I decided to add a light on the top of the trash can to support this.
This is the project design I stuck with and went through to the end.
Step 2: Research
To prepare for this ordeal, I researched multiple things.
First I research about the general way to code Arduino. Practicing with the SparkFun inventor kit helped immensely; getting me used to having to connect the pins to the Arduino and how to use a breadboard.
Then I particularly practiced the use of servos as I knew that is how I would need to control the lid to rotate. First, practicing controlling their timing and then combining the use with conditionals so I can control when they are activated.
Then I researched what sensors to use. There were two types: An ultrasonic sensor (HC-SR04) and an infrared sensor (PIR Motion Sensor). The ultrasonic sensor sends out a pulse that is then bounced back and is read by the HC-SR04, calculating the time in this interval, to determine the distance between it and the location of the bounce. I decided to use the ultrasonic sensor for the inner sensor as detecting distance would be more helpful, especially since trash does not emit much radiation. Then I decided it would be easier to just use an HC-SR04 for both the inner and outer sensor.
Researching about the ESP-8266, I learned a lot about how wifi works. I learned about access points and station points. I learned about web servers as a possible option as well. In the end. The ESP is its own board that can be programmed entirely separately to the Arduino. Thus, it is even possible to make this whole project just using it. To program the ESP, I connected it to the Arduino and connecting GND in the Arduino to Reset to disable it and have it act as a communicator between the ESP and the USB cable.
I then learned that I can make the ESP act as a client that wants to access or request data from a website. Knowing this, I used the IFTTT.com website to create an applet to connect webhooks to SMS texting on my whole such that when an event is triggered (when a client request data from a particular URL, it would send a text).
Another thing I researched were voltage regulators, diodes, and resistors. Resistors were needed for the LED to connect the LED to the Arduino. The diodes and the voltage regulators were possible solutions to powering the ESP-8266 as it strictly takes a 3.3V for Vcc. The voltage regulator was the easiest solution. Although there is a 3.3V option on the Arduino, I took it as an opportunity to learn more.
Following this, I learned about capacitors as they are necessary for a functioning voltage regulator. The capacitors help level out the voltage in case it "bounces" or "hiccups" too much. 2 electrolytic and 1 ceramic capacitor is the usual set up for voltage regulators.
Most of the research was trying to debug my code as there were a lot of errors as I was making it.
Step 3: Difficulties Encountered and How I Overcame Them
Much of the difficulty at the beginning of the semester was simply the fact I was inexperienced. I had never even put thought into building something before, so I was afraid of being either too ambitious or too simple. This is why I put off choosing an idea for so long.
To overcome this, talking with a senior who had experience definitely helped. Bryan was able to critique my ideas and tell me which ones were going in the right direction and which ones were going in the wrong direction. He helped me realize that I needed to consider my skill level, the resources I had access to, and time management.
Time management was also very difficult for me. I already know that I have a weakness when it comes to time management, especially since this semester was incredibly packed since I was overloaded with 21 credits.
There were times when I had to sacrifice working on my project, but to overcome this I dedicated at least one hour of research on the weekends to work on the project, and every other week on the weekends to go to M5 to work on it.
Another difficulty I had was with my lack of knowledge with much of the parts. I didn't know how they worked or what wires connected where. To overcome this, I learned the valuable asset of looking up the datasheets online, which helped me understand what the necessary voltage input was, and where VCC, GND, and inputs needed to be wired. I remember specifically working on trying to connect the servos to the motion detectors and being frustrated because the servos were not operating at all.
This led me to try different servos, hoping that something was wrong with them. However, they still didn't work, which meant it had to either be my wiring, or my code. I then tried using an external power source by connecting the servos to 4 AA batteries as I had read that sometimes, the USB on a PC might not be giving enough voltage to power them. Finally, I decided to simply look at the datasheet and realized it was just because my wiring was incorrect the whole time.
My most difficult obstacle in this was trying to integrate the WiFi component to the Arduino. I was looking up many tutorials online and simply understanding the programming for it was hard for me to grasp. However, one particular website helped me and introduced me to IFTTT. I believed I had achieved a victory however, I did not realize that the boards were separate and I had ended up programming the boards with different code. I was stuck for a week trying to figure out how to connect them but the internet did not help. To overcome this obstacle, I finally simply asked for Dr. Malloch's help. I am a very prideful person and tend to want to do things alone. He had helped me previously however, it wasn't much of a problem I had but rather a discussion of possible ways to approach my project. Simply asking Dr. Malloch immediately solved integrating my ESP-8266.
This project helped put me in my place and realize that I should be working and asking people for help more since engineering is not a solo project but a team dynamic.
Step 4: Changes to M5 to Help Streamline the Learning Process
M5 was a fantastic tool for me this semester. It already comes with a lot of resources for new explorers and seasoned veterans.
I think M5 could help streamline the learning process by having more workshops about a broader variety of topics and by making them more announced. I had barely heard of the workshops that were taking place at M5, and the only ones I knew about were the soldering workshops.
Other workshops such as "How to go about designing" or "How to use the 3D Printer" would be helpful as well. Perhaps they do have these workshops, but I was never able to hear about them.
Step 5: What I Accomplished in the End
I was able to make an automatic trash can
More importantly, however, I learned the importance of time management, how to build circuits and use electronic parts. I learned about Arduino, waves and sensing, resistors, breadboards, WiFi, the ESP-8266, web servers, voltage regulators, diodes, etc. I was able to accomplish exactly what I had in mind. To gain an understanding of a hands-on level about electronics and circuitry.
It also sparked a creative fire in me as creating this project, although extremely frustrating at times, was very fun and rewarding to do. Finally understanding how a part works or getting the code to work how I wanted was worth the hours of tweaks and changes I had to do. It helped me understand that this is what I wanted to do. At the beginning of the semester, I was hesitant about Electrical and Computer Engineering as I did not have experience in it to know if I liked it or not. Like how someone does not know if they like a sport, video game, or hobby unless they try it.
My greatest accomplishment from this was being able to say confidently that I want to continue with Electrical and Computer Engineering.
Step 6: How Somebody Else Could Follow in My Footsteps
If someone is in the same situation I was in at the beginning of the semester, I would recommend doing the same steps I outlined in "Orignal Plans and Progression". That really helped me slowly single out what I was interested in doing and what I could do.
Specifically, for this project, I will outline below how to make one.
Step 1: Go on IFTTT.com, register your phone number and then create an applet. Choose the "if" to be webhooks and the "that" to be SMS. Once it has been created, search for Maker Webhooks in the search box and click on documentation. The fill in the information with your own event name and copy the URL. This is the URL you will use for the ESP-8266 code found at the bottom.
Step 1: Connect the ESP-8266 as such:
RXD -> RX
TXD -> TX
VCC -> VCC
CH_PD --> VCC
GPIO0 -> GND
GND -> GND
Then connect the GND on the Arduino to the Reset on it to disable it.
Step 2: Enter the code at the bottom and upload it to the ESP-8266 (first download the esp-8266 board on the IDE). Then unplug the ESP-8266.
Step 3: Connect servos to pin 8 and pin 9 on the Arduino
Step 4: Connect the first HC-SR04 sensor to pins 10 and 13 (for trig and echo respectively). Then connect the second one to pins 11 and 12 (again for trig and echo respectively).
Step 5: Connect the RGB LED to pins 4 (red), 5 (green), and 6 (blue).
Step 6: Connect GPIO2 to pin 2
Step 7: Enter the code at the bottom (ECE_297_DP) and upload it to the Arduino.
Step 8: Find an old recycled beer box and a piece of cardboard for the lid. Hot glue the popsicle sticks to the servos and then hot glue the servos to the inside of the bot on each side. Tape the lid to the popsicle sticks. Tape the two sensors to the lid (the inside is the one to detect the trash (pins 11 and 12) and the outside being the one to detect motion (pins 10 and 13). Then tape the LED to the top of the lid. And Tape the wiring behind the box to hide the ugly wiring.
Step 7: What I Would Do Next
Moving forward on the project, I had some ideas to implement a sound alarm in addition to the LED. Because I got the ESP-8266 to work, I decided not to. However, if I were to move forward, it would be interesting to add one and annoy the people into taking out the trash.
Also, I would have liked to work on a more definitive project, as this is mostly a proof of concept project. If I were to move forward I would have used an actual trash can or a heftier plastic container. Additionally, I would have liked to be more efficient with the wiring as it is very messy.
One alternative to the ESP-8266 I was looking into while I was worried about not being able to integrate it was using a Bluetooth module. My friend Sean had mentioned to me that he had previously made a project in the past where he had to send data from his project to his phone and used a Bluetooth module. He said it was relatively easy. However, I got the WiFi module to work before I did any serious detective work into it. I think it would be interesting to see where that path would have led me.
Other than that, I would have loved to implement the "automatic trash bag wrapping" part, but that is still out of my league as of current. Perhaps at a future time, I will revisit this project and try to make it more efficient.