Giter Club home page Giter Club logo

iot-kitty-litter-box's Introduction

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

iot-kitty-litter-box's People

Contributors

joekarlsson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

stephdamaica

iot-kitty-litter-box's Issues

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.