Raspberry Pi Laundry Notifier

by dwmuchow in Circuits > Raspberry Pi

200 Views, 1 Favorites, 0 Comments

Raspberry Pi Laundry Notifier

81hyqDgm8vL.jpg
Untitled video 7

This is the instructions to create a laundry notifier via Alexa with a raspberry pi and gyroscope.

Supplies

  • Raspberry Pi 3B+
  • Breadboard
  • MPU6050 Gyroscope
  • RPi Case
  • Tape/something to attach the case to a washing machine

Thought Process

When I was asked what I wanted kind of project I wanted to do, I thought that doing one for myself would be lame. So, I asked my mom what would make life easier for her and she said some sort of notification when the washer/dryer finishes. That is kind of easy, but because I wanted to use an RPi and gain more experience using Python, I decided to add a twist to that idea. While notifying her I would also take measurements about how long it takes for a washer cycle to finish. For fun.

First, I tried to use a vibration sensor. It was not sensitive at all, and required some weird shenanigans to convert from analog to digital using an ADC. When that didn't work after some testing, I realized that I had a gyroscope, which had an accelerometer, laying around in my sensor box.

I plugged in the gyro, learned how I2C worked, and then set up some memory addresses in code. Soon, I was able to read acceleration values and basically just printed them all out so I could see which changed the most when the washing machine vibrated. In hindsight, it is obvious it was going to be the Z-axis, because of how the gyro is mounted.

Anyway, I did some analyzation and determined a setpoint for the average of the instantenous accelerations every 1s over 15s would be high enough to warrant the code to set the on state as true.

Set Up Your Pi

Screenshot_20230130_083755.png
Screenshot_20230130_083915.png

Before setting up anything physical, you are going to want to set up your pi. If you have already done this before and can verify that at least Python 3.9.2 exists on your system, you can skip this step.

Otherwise, to do this, you want to first download and install Raspberry Pi Imager on a different device. Download and open Raspberry Pi Imager. Take your SD card installed inside your Raspberry Pi and plug it into an SD card flasher. In this menu, select these options and make sure to choose YOUR SD card.

In the bottom right, there is also a settings gear. Click on that and make sure it matches the above settings. Make sure to write down what you set as the host name, as it will make accessing this much easier later on.

Take out your SD card from your flasher and reinstall it into the Pi. Now, your Pi is set up.

Connecting to the Pi

Screenshot_20230130_084853.png
Screenshot_20230130_085022.png
Screenshot_20230130_085137.png

The RPi has to be able to be connected to w/o a monitor because it's going to be mounted to your washing machine. To do this, we are going to be using ethernet to directly interface between your chosen device and the RPi. When you connect power and ethernet from your device to the RPi, you should be able to directly SSH into the device.

To do that depends if you're on windows or linux:

If you are on Linux, it is usually (but not always) very simple. Using "ssh hostname@username" will most likely suffice.

On Windows, it is a little harder. I would suggest downloading the latest 64-bit x86 PuTTY. After that is done installing, open it. A screen like the one above should appear. Now, enter the host name you set for the Pi in the Host Name box. For me, it is "pi," and looks like the second picture. After pressing "Open" you should be prompted with a terminal screen asking for a user name. Enter in the username "pi" and whatever you set the password as for the RPi. Above is my terminal after logging in.


Now you are ssh'd into your device!

Confirm Python

Screenshot_20230130_085327.png

In your SSH shell, type:

whereis python3

If anything above or equal to python3.9 appears, you can continue. Otherwise, you might have to go back and change which OS you choose and then try again.

Set Up the Listener

Next, we are going to have set up the listener program which will take in Gyro inputs and, over internet, talk to the Alexa to alert you.

First, travel to the github page for this project @ https://github.com/davidmuchow/pcl-homeauto. This is where you'll pull your code.

Second, on your ssh shell, travel to the pi directory by typing:

cd ~/

Now, you have to pull the repo by running

git pull https://github.com/davidmuchow/pcl-homeauto.git

This will create a directory called "pcl-homeauto" and is where all the files will live.

Next, you will have to run the startup script which will download all the dependencies to run this. Move to that directory by running

cd pcl-homeauto/

This will take to the homeauto directory. Now, run

. setup.sh

This will run the built in dependency installer so you don't have to go through each error message looking for what to install.

All your dependecies are installed and we can move on to setting up the physical aspect.

Setting Up the Gyro

Screenshot_20230130_093000.png
Screenshot_20230130_093009.png

Put your PI into the case and secure it to the washing machine.

Next, place the gyro onto a breadboard. Then, follow the pinout like shown in the two pictures. Take off the sheath for the sticky stuff on the back of the breadboard and also place that onto the side of the washing machine. Make sure that the label "VCC" faces the ceiling!


On the RPi, you'll also want to enable I2C. To do this, type

sudo raspi-config

into the ssh shell.

Go to Option 3, Interface Options. Scroll down to I2C and select Yes.

Setting Up the Alexa

Screenshot 2023-01-30 214511.png
Screenshot_20230130_094833.png

First, you need to create a Monkey which allows the alexa to speak with TTS. The website is here. Set up your device to be connected to a Monkey and then save the device's name that you saved it as. For me, mine is named "monk." Now, go to Ifttt and set up an applet with the correct settings, as shown above. This will allow your raspberry pi to connect to your Alexa. However, we also have to give the Ifttt module on the Raspberry Pi the correct ID. To do that, we grab the key from this page on Ifttt. We only want the last part, as shown in the picture. Copy that ID and go to your SSH terminal. Make sure you are in the pcl-homeauto and type the command:

. changeid.sh

This will automatically prompt you for the id, and all you have to do is copy and paste and press enter.

Now, it should be fully set up and ready to go. Type this into your ssh shell:

python main.py

Now, it should be working!

Optional: VNC

Screenshot_20230130_101709.png
Screenshot_20230130_101724.png

You can view some datapoints about how much your washer is vibrating in real time using VNC Viewer. First, go install VNC Viewer on your device. Enable VNC on your raspberry pi as well by running

sudo raspi-config

and going to Interface Options, and then to VNC. Select Yes.

Now, open VNC Viewer on your device and type in the hostname on the top bar. You should be prompted with a username/password query. Enter in "pi" for the username and whatever you set as the password for the password.

Then, it should open your Pi's screen through this application. Open a terminal, go to the pcl-homeauto directory and run main.py. It should automatically open up a graph for you of the current Z-axis acceleration in Gs.

Optional: Viewables

Screenshot_20230206_112327.png
Screenshot_20230206_112721.png

There are two viewable data collections: the actual X acceleration in G in real time, and the data collection for how long each washer cycle has last.

Note: the washer cycle picture shows "non-natural" data. I was activating and de-activating the washer rapidly to gain data points.

The washer cycle data is available for download by running scp on the "data.xlsx" file in the created pcl-homeauto directory.

The real time acceleration data is only available if the user has VNC connected in Step 7.

Make a Contribution

If any problems arise, create an issue on the github page and/or a pull request to the problem. I will personally test on my device, and then pull if the issue is fixed.

Thank you!