Skip to content

Welcome to to world of IoT (Internet of Toilets 🚽). This is the code you will need to setup your very own internet connect kitty litter box!

License

Notifications You must be signed in to change notification settings

JoeKarlsson/iot-kitty-litter-box

Repository files navigation

IoT Kitty Litter Box

Welcome to to world of IoT (Internet of Toilets 🚽).

This is the code you will need to setup your very own internet connect kitty litter box!😻

deps Maintainability stars pr license twitter bch compliance first-timers-only

My favorite things in life are cats 🐈, computers πŸ–₯ and crappy ideas πŸ’©, so I decided to combine all three and make an IoT (Internet of Things) litter box using a Raspberry Pi and JavaScript! If you have ever wanted to get build your own IoT project, but didn’t know how to start, then this is the project for you.

This project will help track your feline friend's health by measuring its weight every time it sets foot on the litter tray, and monitors its urination patterns. The equipment can be connected to a companion smartphone app that displays the relevant data in an easy-to-understand graph format, so that cat parents can quickly spot symptoms of unusual weight loss.

Together, we will go through how I setup my IoT Litter Box from start to finish. Including how to setup Node.js on a Raspberry Pi and how to connect sensors to a Raspberry Pi and how to read the sensor inputs with Node.js.

Materials and Tools

  • 1 x Raspberry Pi (We used a Raspberry Pi 3 Model B for this demo)
  • 1 x Breadboard
  • 2 x Female to male wires
  • 1 x 3D printer [Optional] It was used for printing the case where the electronics are encloused.
  • 1 x PLA filament [Optional] of any color you want.
  • 1 x Solder iron and wire.
  • 1 x Screwdriver.
  • 8 x M2x6mm Bolts.
  • HX711 module This works as a load cell amplifier.
  • 4 x 50kg load cell (x4). They are used to measure the weight. Four of them were used for a maximum weight of 200kg.
  • 1 x Magnetic door sensor. Used to detect that the litter box is opened.
  • 1 x Micro USB cable.
  • 1 x Cat litter box.

Schematics

iot-kitty-litter-box_bb

Prerequisites

Setup Your Project

Sign up for MongoDB Atlas. We will be using MongoDB Atlas to save all of our IoT Sensor data.

Download and unpack IoT Kitty Litter Box. Or alternatively checkout from source:

git clone https://github.com/JoeKarlsson/iot-kitty-litter-box
cd iot-kitty-litter-box

Next, inside the project, you need to install the project's various NPM dependencies:

npm install

Next, inside the project, you need to install the project's various Python dependencies:

npm run setup

Rename src/example_config.json to src/config.json and add your MongoDB Atlas URI connection string.

You should now be ready to spin up a development build of your new project:

npm start

Navigate to http://localhost:3000.

Auto Starting IoT Kitty Litter Box

The methods below describe ways to automatically start you IoT Kitty Litter Box on boot, and even ways to keep it running in case of a failure.

Using PM2

PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks. In this case we will use it to keep a shell script running.

Install PM2

Install PM2 using NPM:

sudo npm install -g pm2

Starting PM2 on Boot

To make sure PM2 can do it's job when (re)booting your operating system, it needs to be started on boot. Luckily, PM2 has a handy helper for this.

pm2 startup

PM2 will now show you a command you need to execute.

Make a IoT Kitty Litter Box start script.

To use PM2 in combination with IoT Kitty Litter Box, we need to make a simple shell script. Preferable, we put this script outside the IoT Kitty Litter Box folder to make sure it won't give us any issues if we want to upgrade the mirror.

cd ~
nano iot-kitty-litter-box.sh

Add the following lines:

cd ~/iot-kitty-litter-box
DISPLAY=:0 npm start

Save and close, using the commands CTRL-O and CTRL-X. Now make sure the shell script is executable by performing the following command:

chmod +x iot-kitty-litter-box.sh

You are now ready to the IoT Kitty Litter Box using this script using PM2.

Starting your IoT Kitty Litter Box with PM2

Simply start your mirror with the following command:

pm2 start iot-kitty-litter-box.sh

You box should now boot up and appear on your screen after a few seconds.

Enable restarting of the IoT Kitty Litter Box script.

To make sure the IoT Kitty Litter Box restarts after rebooting, you need to save the current state of all scripts running via PM2. To do this, execute the following command

pm2 save

And that's all there is! You IoT Kitty Litter Box should now reboot after start, and restart after any failure.

Controlling you IoT Kitty Litter Box via PM2.

With your IoT Kitty Litter Box running via PM2, you have some handy tools at hand:

Restarting your IoT Kitty Litter Box
pm2 restart iot-kitty-litter-box
Stopping your IoT Kitty Litter Box
pm2 stop iot-kitty-litter-box
Show the IoT Kitty Litter Box logs
pm2 logs iot-kitty-litter-box
Show the IoT Kitty Litter Box process information
pm2 show iot-kitty-litter-box

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Contributing TLDR;

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Maintainers


Joe Karlsson

License

Related Links

Resources

About

Welcome to to world of IoT (Internet of Toilets 🚽). This is the code you will need to setup your very own internet connect kitty litter box!

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published