A small IoT project that monitors your washing machine and sends a push notification when the washing cycle ends
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.
- 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)
deps
- Download production + development NPM dependenciesdeps/prod
- Download production NPM dependenciesapi/prod
- Start the API withNODE_ENV=production
api/register-launcher
- Register pm2 startup launcher so the API will start automatically after rebootapi/dev
- Run API locallyapi/init-db
- Initialize SQLite databaseweb
- Serve web client application locallydeploy
- Copy the files from the local computer to OrangePissl/certificate-manager
- Saves the next SSL certificate renewal date and generates the certificate if needednginx/setup
- Configure NGINX server (needs to be run withsudo
)gpio/test
- Test whether GPIO works by blinking the LED
You can connect to OrangePi via SSH (password orangepi
)
$ ssh orangepi@192.168.0.100
Make sure to have mkcert
downloaded locally on your computer and generate the root CA authority first! (mkcert -install
)
- 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
, usesudo
in order to installpm2
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 suressl/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 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).
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.
(local-computer)$ make deploy
- Deploy the code- connect to OrangePi
(orange-pi)$ make api/prod
- Start the program manually
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.