Skip to content

A small IoT project that monitors your washing machine and sends a push notification when the washing cycle ends

License

Notifications You must be signed in to change notification settings

jozefcipa/laundry-alert

Repository files navigation

Laundry Alert

A small IoT project that monitors your washing machine and sends a push notification when the washing cycle ends


Laundry Alert

How it works

Diagram

The application consists of three parts

iOS Web App

A simple web application that is used to subscribe for notifications. It is installed on a phone as a web app.

Deployed at laundry.iot.jozefcipa.com.

See the docs.

OrangePi

This is where the main logic resides. It is an OrangePi Zero single-board computer running the Node.js app that communicates with the A/D converter, controls the status LED and sends push notifications to the web app.

Deployed at local network IP (e.g. 192.168.0.100:80) behind the NGINX proxy.

See the docs.

Seeduino (A/D converter)

Seeeduino XIAO SAMD21 is used here to perform a simple analog to digital conversion when reading the values from the photoresistor. This data is then processed by the Control unit.

See the docs.

Running locally

  • Install dependencies - make deps
  • Start the web - make web
  • Start the API - make api/dev (Note: the API must be configured first)
  • Deploy the code to Seeduino (via Arduino IDE)

Makefile

  • deps - Download production + development NPM dependencies
  • deps/prod - Download production NPM dependencies
  • api/prod - Start the API with NODE_ENV=production
  • api/register-launcher - Register pm2 startup launcher so the API will start automatically after reboot
  • api/dev - Run API locally
  • api/init-db - Initialize SQLite database
  • web - Serve web client application locally
  • deploy - Copy the files from the local computer to OrangePi
  • ssl/certificate-manager - Saves the next SSL certificate renewal date and generates the certificate if needed
  • nginx/setup - Configure NGINX server (needs to be run with sudo)
  • gpio/test - Test whether GPIO works by blinking the LED

Configuration

OrangePi Configuration

Connecting to the unit

You can connect to OrangePi via SSH (password orangepi)

$ ssh orangepi@192.168.0.100

Prerequisites

Make sure to have mkcert downloaded locally on your computer and generate the root CA authority first! (mkcert -install)

Installation

  • Install Node.js
  • Install Nginx
  • Install WiringOP GPIO library
  • Generate VAPID keys (See API configuration)
  • Copy code from the computer - make deploy
  • Install NPM dependencies (sudo make deps/prod, use sudo in order to install pm2 globally). It might take a while, just be patient 😅
  • Copy .env.example to .env in ./api/src and configure the values
  • Initialize the database - make api/init-db
  • Start the API - make api/prod
  • Register the API to start after booting - make api/register-launcher
    • Run the command provided in the output
  • Generate SSL certificates - make ssl/certificate-manager
  • Run cat .crontab | crontab - to make sure ssl/certificate-manager is run automatically after reboot
  • Configure Nginx - sudo make nginx/setup
  • Open 192.168.0.100 in your browser. If everything went well you should see a response from the API.

GPIO

GPIO stands for General Purpose Input Output bus and it's used to communicate with other devices.
This project uses two pins - one for controlling the LED (16) and one for reading information from the A/D converter (6).

GPIO Pinout

Note: Use the wPi column ($ gpio readall) to refer to the correct pin number!

We can test whether the library is installed and working properly by trying to turn the LED on and off.

$ gpio readall       # show the GPIO configuration map
$ gpio mode 16 out   # set the GPIO pin 16 (LED) as OUTPUT
$ gpio write 16 1    # turn on the LED
$ gpio write 16 0    # turn off the LED

There is also a Makefile command make gpio/test that does the same.

Running on the microcomputer

  • (local-computer)$ make deploy - Deploy the code
  • connect to OrangePi
  • (orange-pi)$ make api/prod - Start the program manually

HTTPS and iOS

As the app is using a self-managed SSL certificate for the API, we need to register it in our iOS (Android) device to allow connections.
In order to do so, we need to add the SSL root authority certificate to our phone.
Read more here to see how to configure it.

Some photos

In Progress Case Debugging

About

A small IoT project that monitors your washing machine and sends a push notification when the washing cycle ends

Topics

Resources

License

Stars

Watchers

Forks