Giter VIP home page Giter VIP logo

laundry-alert's Introduction

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)

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

laundry-alert's People

Contributors

jozefcipa avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.