Laundry Alert Page
The Laundry Alert Device!
Don't you just hate it when you walk all the way down to the laundry room to find every single machine in use? Our 'Laundry Alert Device' idea will bring a solution to this problem. Our idea consists of a device that will alert, through text message, a washing machine's user that his or her laundry is done. We believe our device will cut the waiting time by a significant amount. To meet this goal, we will be creating a device using a raspberry pi 0 and vibration sensors. First the user will text the number attached to the device "Start" to notify it that they have started their laundry load. The pi will use the vibration sensor to determine when the laundry machine has finished the load. When the load is finished, using Twilio API, the pi will send a text message to the user telling them that their laundry has been finished.
Link to weekly log Link to Tutorial: Link to Project Proposal Presentation.
Project Proposal Presentation
- Ezra Blair
- Young Wang
- Billy Gilbert Habimana Cyusa
- Ellen Dai (TA)
- Jim Feher (Instructor)
*Vibration sensors to determine completion of a washing cycle *Need Battery for power source *Case (preferably 3D Printed) for enclosure, protection, and presentation of device
*Distinguish between vibration and no motion *Get program to successfully send sms messages *Use ngrock to establish communication from twilio to Pi *Recognize texts received from user and store its phone number *Get program to send messages based on user response *Get a waitlist set-up for users who are waiting for a machine to be open
- Deciding Interface: one of the issues that we anticipate to encounter is choosing between using a website or a Self Contained Server.
- Connectivity to private networks
- Finding out the vibration pattern and level of the washing machine and making the Pi recognize it
- Figuring how to integrate Twilio into the interface: Considering that none of our team members has any experience with the Twilio API, we expect managing to integrate it into our interface to be difficult.
- Figuring out how to exclude the vibration noise of other washing machines or other vibrating objects nearby.
- Finding a way to demonstrate the project: we do not want to have to carry an entire washing machine for the demonstration so we will have to find a less challenging way to demonstrate our project
- Raspberry Pi Zero W (provided)
- Twilio API $20
- | A/D converter (provided)
- | Analog Vibration Sensor $13.45
- | sw-420 vibration sensor $4.45
- | ngrok $10.00
- Magnets (provided by Washington University Bookstore) $6
- | Battery $32.84
Total Cost: $86.74
Design and Solutions
- Precursor Steps
Our project required a lot of knowledge in areas that all team members were unfamiliar with, so we spent the first few weeks learning the tools that we would need for this project. The main three things to learn were how to use the raspberry pi, how to program in java, and how to use Twilio API. At the end of this stage, we were able to make the raspberry pi to send us an email with its ip address everytime on boot, program a java program that would read the values of a potentiometer and A/D converter using the GPIO pins of the raspberry pi, and program simple programs using the Twilio API to first send out a text, and then send a text as a response to recieving a text.
Initially, we thought that we would need a web server of some sort to act as an interface that would allow the user to communicate with the program. However, with further consideration and more understanding of how Twilio worked, it was decided that a web server would not be needed because the user could just directly text the Twilio number on our device to communicate with our program.
The challenge to connect to private wifi networks was never resolved other than the thought of having a directory to save a list private networks in. However, each private network would still have to manually connected to in some step anyways.
- Vibration Sensor
The first part of the project that we tackled was the vibration sensor that was going to detect when the laundry machine was washing or not. At first we used the SW-420 vibration sensor. This sensor is a digital vibration sensor meaning that it could only output values 0 and 1. This sensor had too much room for error because of the background noise from the vibration of the other laundry machines that were in the laundry room. This made us change to an analog vibration sensor, the Grove - Piezo Vibration Sensor. However, the raspberry pi GPIO pins could only take digital inputs, so for the raspberry pi to read analog sensors, the MCP 3008 Analog to Digital converter was used. The MCP 3008 is a 10-bit converter so the vibration sensor could now output values from 0 to 1023.
- Twilio Integration
With the vibration sensor now working, all that was needed was to incorporate the Twilio API into our program in the way we intended.
However, there was a problem to be resolved before this could go on. This was the problem with the school's router. To understand the problem, the way that Twilio sends and recieves texts must be discussed first. In context of our project, the user who wants to use our device would text "start" to our Twilio number which would send it to the Twilio API. The Twilio API would then send that information to the program on our raspberry pi. Our program would then respond with a response test depending on the scenario. However, with the school's router in place, when Twilio would try to communicate to the pi, because the router has one IP address and many devices are connected to it, Twilio did not know which device to send it. To solve this problem, we used ngrok which is a tunneling device that could allow us to bypass the router by making the raspberry pi's local server, public which could then be easily accessed by Twilio.
Twilio was implemented into the program in the following way. The user would send the text "start" to the number that was on our device. When received, program would send a response text told the user that we would text them when their laundry would be done. Along with that, it would start the vibration sensor. Because the laundry machine goes through different cycles, a delay timer was created so that only if the laundry machine stopped for 40 seconds that a text would be sent telling the user that their laundry was finished. The timer at first was created using the time.sleep function from the time library in python. However, using the time.sleep function would cause the whole program to sleep instead of just the timer. This would make it so that later actions would fail to execute. To fix this, A delta time loop was used to create a timer instead. Also in case the same problem came up in the future, we threaded the different functions of the program so that they could all be executed at the same time if needed to be. Now, after 40 seconds of inactivity from the washing machine, the program would send a text telling the user that their laundry was done. A buffer was also added to the value that the vibration sensor needed to read for 40 seconds in order to send a text. This buffer was set at 100 to filter out the background noise from the other vibrations in the room. Also another function was added that if the user tried to text "start" again a second time they would receive a message telling them that they were currently using the machine. If any other phrase was texted, the program would reply with "please try again."
- Implementation of the Queue
Lastly, a queue was added to the program. This made it so that when another user would text the device, it would put them into an array that would act as our waiting line. They would then receive a message that would say that they have been added to the wait line and would be texted when it was their turn use the laundry machine. If they texted the number again, it would text them that they were already in line. When the user currently occupying the laundry machine was done, it would pop them out of the array and make the next person first in line.
This is how we set-up the pi / refer to code
This is how we wired the pi / add Pics of wiring* - possible diagram we can refer to
This is how we set-up vibration sensors / refer to code
This is how we set-up the battery
Design of Case
After finishing most of the softwares for our device, a solid cover was then needed to enclose everything. This was necessary in order to prevent loose cords and wires from being exposed, for protection against drops and or damage, to be easily handled by a user, and of course for better device presentation. So the practicalities of having a good case was an obvious step we couldn't overlook.
3D Design Drafts
pics of drafts along the way and reasons for optimizations
Unfortunately, due to time and circumstance we weren't able to get our 3D designs printed. After news of the printers not working, we had to improvise. We ended up building a decent replacement case from the tools we had around us. We had ordered a battery and when it came in the mail it was much bigger then expected, even bigger then the pi. So we started with the cardboard box that the battery came in and went from there. We adjusted the size and made some cuts to the box to be optimized to fit the pi. Much of this done by trial and error, we cut holes into the box for the port holes and found good spots within the box to fit everything to go inside of it. First we attached the battery to the inner corner using duct tape. Then we screwed in the pi to the bottom using the holes in the corner of the zero with very small screws. Then we laid our breadboard and A-D converter along the inner wall of the box to prevent stuffing the box too much. The vibration sensor being attached to the pi, we stuck it out the box and attached it to the bottom so that the sensor can get good reads and direct contact to a laundry machine. Our final touch was to add the magnets to the bottom of the case. After taking apart the store-bought magnets we proceeded to hot glue the medal part on to the bottom of our device. The magnets were used to give it better attaching to a laundry machine.
- Final Product
pic of final product and basic overview of functions
*The final project was functional overall. The vibration sensor was fully functional being able to read the vibration value accurately of the laundry machine even with the background vibration in the room. The 40 second delay timer for the vibration sensor was also fully functional.
*Twilio overall was functional. There were some features that we were unable to included such as a time estimation function and line cancellation process. What worked was that when texted "start" it would text the user saying that it would text the user when the laundry machine was done and after 40 seconds of inactivity from the laundry machine, would send a text to the user to pick up the laundry. Also if texted "start" again would tell the user that they currently occupied the machine.
*The queue was fully functional, so if someone texted "start" the device as someone else was using it, it would put them in line, and text the person when it was their turn to use the washing machine. If texted "start" again, the program would tell them they were already in line.
*The 3D printed case was not printed in time, so a makeshift case using a cardboard box was created instead.
- Demo Day
Some adjustments were made in order for an easier demo. *Timer for waiting for the laundry machine to stop was set 20 seconds instead of 40 seconds. *A vibration app on the phone was used to simulate the vibration of a washing machine *The vibration sensor was calibrated to be more sensitive so that the program would work with the phone instead of the washing machine
- Final Poster
- Future Improvements
*Ngrok would be replaced with a web server in the future. This is because ngrok is only capable of tunneling on device, and if the goal was to have one device on each laundry machine in the room, then a web server would be more of a logical solution to let Twilio be able to reach all of the raspberry pis.
*Security of the device would also have to be improved on because if the device is only attached to the washing machine with magnets, it could easily be taken off and stolen. One solution to this is that since, vibration sensor on the raspberry pi is analog, the reading patterns of the vibration sensor on the washing machine would be very different to being carried away.
*More commands should be added to the program such as canceling a wait spot or a time estimation for when the laundry is done/ their turn to use the machine. Also another function to check whether machines are open should be created.