Difference between revisions of "Laundry Alert Page"

From ESE205 Wiki
Jump to navigation Jump to search
m (Protected "Laundry Alert Page" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 
(31 intermediate revisions by 3 users not shown)
Line 2: Line 2:
 
The Laundry Alert Device!
 
The Laundry Alert Device!
 
==Overview==
 
==Overview==
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.
+
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. If there happens to be a person who wants to use the machine after, he/she will text "Start" and will then be added to a waiting list. Upon completion, of the first laundry load, he/she will be notified that the machine is available for use.
  
[[Laundry_Alert_Log|Link to weekly log]]
+
*[[Laundry_Alert_Log|Link to weekly log]]
Link to Tutorial:
+
*[https://classes.engineering.wustl.edu/ese205/core/index.php?title=How_to_send_and_receive_text_messages_using_the_raspberry_pi_and_the_Twilio_API#Step_6:_Receive_and_reply_to_inbound_SMS_messages_with_Flask  Link to Tutorial]
Link to Project Proposal Presentation.
+
*[https://docs.google.com/presentation/d/1_Z8Xa3uJgJewrvXhD7aH8ir0iT577_uLS-mbA0qntTQ/edit?usp=sharing Link to Project Proposal Presentation.]
 
 
==Project Proposal Presentation==
 
https://docs.google.com/presentation/d/1_Z8Xa3uJgJewrvXhD7aH8ir0iT577_uLS-mbA0qntTQ/edit?usp=sharing
 
  
 
==Team Members==
 
==Team Members==
Line 20: Line 17:
 
==Objectives==
 
==Objectives==
 
*Hardware
 
*Hardware
  *Vibration sensors to determine completion of a  
+
-Vibration sensors to determine completion of a washing cycle<br>
    washing cycle
+
-Need Battery for power source<br>
  *Need Battery for power source
+
-Case (preferably 3D Printed) for enclosure, protection, and presentation of device<br>
  *Case (preferably 3D Printed) for enclosure,  
 
    protection, and presentation of device
 
  
 
*Software
 
*Software
  *Distinguish between vibration and no motion
+
-Distinguish between vibration and no motion <br>
  *Get program to successfully send sms messages
+
-Get program to successfully send sms messages<br>
  *Use ngrock to establish communication from twilio  
+
-Use ngrock to establish communication from twilio to Pi<br>
    to Pi
+
-Recognize texts received from user and store its phone number<br>
  *Recognize texts received from user and store its  
+
-Get program to send messages based on user response<br>
    phone number
+
-Get a waitlist set-up for users who are waiting for a machine to be open<br>
  *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
 
  
 
==Challenges==
 
==Challenges==
Line 44: Line 36:
 
*Figuring out how to exclude the vibration noise of other washing machines or other vibrating objects nearby.
 
*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
 
*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
 
 
  
 
==Gantt Chart==
 
==Gantt Chart==
[[File:Gantt chart 205 version 2.jpg | thumb]]
+
[[File:Gantt chart 205 version 2.jpg | thumb| Schedule for Project]]
  
 
==Budget==
 
==Budget==
Line 62: Line 52:
 
Total Cost:
 
Total Cost:
 
$86.74
 
$86.74
 
==Final Poster==
 
 
[[File:LAPosterFinal.jpg|thumb]]
 
  
 
=Design and Solutions=
 
=Design and Solutions=
 
*Precursor Steps
 
*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.
 
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
 
*Vibration Sensor
Line 75: Line 65:
  
 
*Twilio Integration
 
*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.  
+
With the vibration sensor now working, all that was needed was to incorporate the Twilio API into our program in the way we intended. <br>
 +
Before moving on, we had to first understand how Twilio works. <br>
 +
[[File:Twii.jpg|thumb|This demonstrates how Twilio communicates with the Flask application]]
 +
 
 +
To receive incoming messages, we created a Flask application and we had to make sure that Twilio was able to reach that applications. Basically, when Twilio received a message, it reached out to a URL in our  application for instructions on how to appropriately handle the message. However, when we were working in our flask application in our development environment, the application was only reachable by other programs on the pi, so Twilio could not talk to it. In making our app accessible over the internet is where a tool called ngrok came in. Once ngrok is started, it provides a unique URL on the ngrok.io domain which forwards all incoming requests to your local development environment. <br>
 +
 
 +
[[File:Webhook.png|thumb| ngrok works something like this]]
 
      
 
      
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.
+
Another problem to be resolved before the integration of Twilio was 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 also 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."
 
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."
Line 84: Line 80:
 
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.  
 
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.  
  
[https://youngrunk@bitbucket.org/youngrunk/laundry-alert-2.git | Link to final code]
+
[https://bitbucket.org/youngrunk/laundry-alert-2 | Link to final code]
 
 
===Set-up===
 
This is how we set-up the pi / refer to code
 
[[File:205 raspberry pi schematic bb.jpg | thumb]]
 
===Wiring===
 
This is how we wired the pi / add Pics of wiring* - possible diagram we can refer to
 
 
 
===Vibration Sensors===
 
This is how we set-up vibration sensors / refer to code
 
 
 
===Battery===
 
This is how we set-up the battery
 
  
 
==Design of Case==
 
==Design of Case==
Line 102: Line 86:
  
 
===3D Design Drafts===
 
===3D Design Drafts===
pics of drafts along the way and reasons for optimizations
+
[[File:Pi_dimensions.png|300px||1st Stage]]
 +
[[File:3D-draft.png|300px||1st Draft]]
 +
[[File:Picase2.png|300px||2nd Draft]]
 +
[[File:finalcase.png|300px||Final Case]]
 +
 
 +
First, we downloaded a starting template of the pi we found from this video [https://www.youtube.com/watch?v=YxBamwc6s7U  here.] We made all of our judgments for dimensions based off of the official pi zero dimensions. Then we designed a possible cover that can go on top of the whole thing. We made the cover larger than the base so it can go on and off easily.
 +
To complete the first draft, we added depth and added places for the ports we wanted to use. We added an outer box for the power source (We eventually ordered a different battery than we intended so we would've needed a larger area for the power source the  designed.).
 +
In our final draft, we increased the dimensions of the side to 68 mm while still maintaining the dimensions for the pins to stay in the right spots. We also increased the size of case cover as well. We did this just so we had some head room for everything that needed to fit. Along with increasing the dimensions, we changed the color to a slicker black for presentation purposes.
  
 
===Improvisation===
 
===Improvisation===
 
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.
 
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==
+
==Results==
pic of final product and basic overview of functions
+
*Final Product
 +
[[File:Frontviewla.JPG|thumb | This is the front view of the case with our Twilio phone number visible]] 
 +
[[File:Insidelacase.JPG|thumb | This shows the inside of the case]]
 +
[[File:Underneathla.JPG|thumb | This shows the bottom of the device]]
 +
[[File:205_raspberry_pi_schematic_bb.jpg |thumb | This shows how the wiring was from the vibration sensor to the MCP 3008 and from that to the raspberry pi. One note is that because the program that this schematic was created on, fritzing, does not have the grove piezo vibration sensor in their digital library, and there are no additional files of the device on the internet, a potentiometer was used to represent the vibration sensor instead. The wiring for the potentiometer would be the exact same for.]]
 +
 
 +
-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. <br>
 +
 
 +
-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. <br>
 +
 
 +
-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. <br>
 +
 
 +
-The 3D printed case was not printed in time, so a makeshift case using a cardboard box was created instead. <br>
 +
 
 +
*Immediate future improvements include:
 +
-Having a 3D printed case. <br>
 +
-Writing code that estimates the time remaining and lets a user cancel when he/she doesn't want to use the device anymore. <br>
  
===Demo Day===
+
*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.
+
[[File:LAPosterFinal.jpg|thumb|Final Poster]]
*A vibration app on the phone was used to simulate the vibration of a washing machine
+
Some adjustments were made in order for an easier demo. <br>
*The vibration sensor was calibrated to be more sensitive so that the program would work with the phone instead of the washing machine
+
-Timer for waiting for the laundry machine to stop was set to 20 seconds instead of 40 seconds. <br>
 +
-A vibration app on the phone was used to simulate the vibration of a washing machine.<br>
 +
-The vibration sensor was calibrated to be more sensitive so that the program would work with the phone instead of the washing machine.<br>
  
final poster
+
==Future improvements==
 +
We believe that even though our device is fully functional right now, the following would make it an even better overall product.
 +
*Replace Ngrok
 +
-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. <br>
  
==Future Improvements==
+
*Security
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.
  
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.
+
*Add more commands
 +
-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.  
  
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.
+
*Automatic connection to public Wi-Fis
 +
-To add versatility to our device, we would make sure that it can connect to networks that aren't Washington University's networks (for example, if a user were to bring the device to a random laundry mat). Right now, the device works while on WashU's network but it would be even more efficient if it could connect other networks when it detects them.  
  
 
[[Category:Projects]]
 
[[Category:Projects]]
 
[[Category:Spring 2018 Projects]]
 
[[Category:Spring 2018 Projects]]

Latest revision as of 12:05, 5 May 2018

Our Product

The Laundry Alert Device!

Overview

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. If there happens to be a person who wants to use the machine after, he/she will text "Start" and will then be added to a waiting list. Upon completion, of the first laundry load, he/she will be notified that the machine is available for use.

Team Members

  • Ezra Blair
  • Young Wang
  • Billy Gilbert Habimana Cyusa
  • Ellen Dai (TA)
  • Jim Feher (Instructor)

Objectives

  • Hardware

-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

  • Software

-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

Challenges

  • 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

Gantt Chart

Schedule for Project

Budget

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.
Before moving on, we had to first understand how Twilio works.

This demonstrates how Twilio communicates with the Flask application

To receive incoming messages, we created a Flask application and we had to make sure that Twilio was able to reach that applications. Basically, when Twilio received a message, it reached out to a URL in our application for instructions on how to appropriately handle the message. However, when we were working in our flask application in our development environment, the application was only reachable by other programs on the pi, so Twilio could not talk to it. In making our app accessible over the internet is where a tool called ngrok came in. Once ngrok is started, it provides a unique URL on the ngrok.io domain which forwards all incoming requests to your local development environment.

ngrok works something like this

Another problem to be resolved before the integration of Twilio was 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 also 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.

| Link to final code

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

1st Stage 1st Draft 2nd Draft Final Case

First, we downloaded a starting template of the pi we found from this video here. We made all of our judgments for dimensions based off of the official pi zero dimensions. Then we designed a possible cover that can go on top of the whole thing. We made the cover larger than the base so it can go on and off easily. To complete the first draft, we added depth and added places for the ports we wanted to use. We added an outer box for the power source (We eventually ordered a different battery than we intended so we would've needed a larger area for the power source the designed.). In our final draft, we increased the dimensions of the side to 68 mm while still maintaining the dimensions for the pins to stay in the right spots. We also increased the size of case cover as well. We did this just so we had some head room for everything that needed to fit. Along with increasing the dimensions, we changed the color to a slicker black for presentation purposes.

Improvisation

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.

Results

  • Final Product
This is the front view of the case with our Twilio phone number visible
This shows the inside of the case
This shows the bottom of the device
This shows how the wiring was from the vibration sensor to the MCP 3008 and from that to the raspberry pi. One note is that because the program that this schematic was created on, fritzing, does not have the grove piezo vibration sensor in their digital library, and there are no additional files of the device on the internet, a potentiometer was used to represent the vibration sensor instead. The wiring for the potentiometer would be the exact same for.

-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.

  • Immediate future improvements include:

-Having a 3D printed case.
-Writing code that estimates the time remaining and lets a user cancel when he/she doesn't want to use the device anymore.

  • Demo Day
Final Poster

Some adjustments were made in order for an easier demo.
-Timer for waiting for the laundry machine to stop was set to 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.

Future improvements

We believe that even though our device is fully functional right now, the following would make it an even better overall product.

  • Replace Ngrok

-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

-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.

  • Add more commands

-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.

  • Automatic connection to public Wi-Fis

-To add versatility to our device, we would make sure that it can connect to networks that aren't Washington University's networks (for example, if a user were to bring the device to a random laundry mat). Right now, the device works while on WashU's network but it would be even more efficient if it could connect other networks when it detects them.