Introduction: IDC2018IOT Connected Pet Food, Water and Monitor System

Introduction

Whether you are a student under pressure, an hard working person, or simply away from home for more than few hours a day. As a caring pet owners, we want to make sure our beloved ones remain healthy, fed and of course NOT lying down on the sofa (you bastard!). It is time to stop asking for favors, or even paying for such services.

With this cool project we aim to provide you the ability to do-it-yourself (I heard it's a thing now). We will build a solution for monitoring our pets better, and even take action while at the office, school or just hanging out with our friends or significant other.

This system will enable you to feed your pet remotely while controlling the amount of food you pour from the container, fill the water bowl whenever it runs empty. In addition, we can now monitor the bowl water levels in real time, measure food container content and most importantly watch the pet live by using a simple camera module.

About us

Tomer Maimon, Gilad Ram and Alon Shprung.
Three passionate Computer-Science students of the IDC Herzeliya. This is our first Instructables project as part of an IoT workshop - we hope you will find it interesting and fun to build!

Step 1: Understanding the Architecture:

We can divide this system into Two main parts:

  1. Incoming Data Channels:
    • Water sensor - sampling the water levels inside the pet bowl, data is transmitted from the Node-MCU unit to the Blynk server and finally is presented via the Pet Dashboard.
    • Sonar sensor - sampling the food container content, data is transmitted from the Arduino unit (with Ethernet shield extension) to the Blynk server and finally is presented via the Pet Dashboard.
    • Pi Camera Module - constantly samples frames of the pet area, the Pi is hosting its own server which provides the live feed to the pet Dashboard.
  2. Command Flow:
    • Feed Button (Dashboard) - updating a virtual pin value through Blynk, the relevant function is triggered on the Arduino board, the Servo is then moving in order to allow food to pass through the lid.
    • Give Water (Dashboard) - actively updates a virtual pin value through Blynk, the relevant function is triggered on the Node-MCU board, the relay is switched to ON, water pump will start streaming water to the pet's bowl.
    • Pet Live Feed (Dashboard) - embedded within the dashboard, and presenting live data via the flask server which runs on the Pi device.

Step 2: List of Parts

To begin working on this system, you will need the following (or similar) parts:

  1. Physical:
    • Food Container: We used an industrial 45cm two-sided pipe, which we bought in an home department store. It's important to have 2 exits. One for the measuring the content, and second exit for the open/close mechanism.
    • Duct Tape: To keep things together ;)
    • Jumper Wires: The more the merrier, always good to have some extra if something goes wrong.
    • Ethernet Cable: For connecting our Arduino (with ethernet shield) to the internet.
    • Gardening Can: Used as a container for water and the water pump.
    • Short Water Tube: Connected to the pump and pours water to the pet's bowl.
  2. Sensors:
    • WINGONEER Water Level Sensor: Measure the water levels inside the pet's bowl.
    • Sonar Sensor - Measure the distance of food level from the upper lid inside the container.
    • TONGLING Relay: Allows us to turn on/off the water pump which streams water.
    • Pi Camera Module: Connected to a raspberry Pi device, and streams images of the pet area.
    • Generic Servo: Locks and Unlocks the food container.
  3. Electronic Devices / Boards:
    • Arduino Uno: Controls the food container unit implementation.
    • Arduino Ethernet Shield: Provides internet connection to our board.
    • NodeMCU(ESP-8266): Controls water unit, both for measuring and pouring water. This board has the ability to connect via WiFi.
    • Raspberry Pi 3 - hosting the camera server and provides live feed to the pet dashboard.
    • VicTsing 80 GPH Submersible Water Pump: Streams water from the gardening can to the bowl, along with the water tube.

Step 3: Wiring and Placing Things Together

Wiring

Before we begin, it is recommended to place the Arduino / Node-MCU on a breadboard to make it easier for putting all the wires together and placing it on any physical location. In addition, it is recommended to use long wires to prevent errors deriving from cable detachment. We provided you with a wiring diagram for the Node-MCU (Water Unit) and the Arduino (Food Unit).

  1. Food Unit (Arduino):
    • Sonar Sensor:
      • GND (Black) = GND
      • VCC (Red) = 5V
      • Trig (Purple) = 3
      • Echo (Blue) = 4
    • Servo:
      • GND (Black) = GND
      • VCC (Red) = 5V
      • Signal (Yellow) = 9
  2. Water Unit (Node):
    • Water Level Sensor:
      • S (Blue) = A0
      • + (Red) = 3v3
      • - (Black) = GND
    • Relay (electrically wired to the water pump):
      • IN (Yellow) = D1
      • VCC (Red) = Vin
      • GND (Black) = GND
  3. Camera Unit (Pi):
    • Camera Sensor:
      • Connect to the Pi's single camera port (flux cable)
      • If you seek to learn more about Pi with camera module - Link


Assembling Parts Together

In this part, you are welcome to customize and modify this project in order to "make it yours". But we will provide you with images and description to reconstruct our version of the product.

  1. Food Unit (Arduino): The container is pretty straight forward, we will focus on crafting the two lids.

    • Upper lid: Cut 2 holes in the lid for the Sonar sensor to fit in (see attached image).
    • Lower lid + Mechanism: Begin with taking one of the plastic attachments (provided with the servo sensor) and construct a "Sledge Hammer" shape using duct tape / wooden sticks (we used tape only). Next, attach it the servo. Now, we need 2 holes on the lid itself. The first one should allow the servo to fit in s.t the mechanism we constructed in placed on the "inner side" of the lid. Cut another hole based on the side of the "hammer head" you crafted. This way, whenever the servo opens, the tail of the hammer will sweep food towards the exit and prevent from large pieces to get stuck together.
  2. Water Unit (Node-MCU): Simply connect the water tube to the water pump, now place it within the gardening can (make sure you DON'T place the wrong part with the relay and electric wires inside the water).
  3. Camera Unit: All you need to do is place the Pi with camera module in a location of your choice.

Step 4: Setup Blynk

All of the remote capabilities in this project are based on Blynk. This service basically provides us with a free Web-Server and RESTful API for communicating with our Arduino/Node-MCU devices over the internet using HTTP protocol. Blynk allows us to define virtual pins, which will be used as an address for executing specific functions related to pouring water, feeding and sampling the different sensors (we did that part for you, all you need to do is get your own application token, which will be explained next).

How to Get My Blynk Authentication Token

  1. Download the Blynk app via AppStore / PlayStore for your mobile device.
  2. Sign up for this service (it is free to use).
  3. Start a new project, make sure to select the correct device (in our case ESP8266).
  4. After creation, an email with AUTHENTICATION TOKEN will be sent - Save the token for next steps.

Note: Blynk can be fully used via the app, but we decided to implement our own customized dashboard.

Finally, in order to proceed to next step, you should download & install Blynk library - Link (skip to part 3)

Step 5: Configure Food Container, Water Pump & Live Camera

At this point, we finished assembling all the parts together and got our blynkAuthAppToken(see step 3).

We provided you with all the code you need to run this project, all you have to do is changing few variables in the code, which will make it "your own" private system.

First of all, begin with downloading the Arduino IDE (if you havn't done it yet) - Link

Arduino Food Container

  1. Setup the IDE to the Arduino board: Tools -> Board -> Arduino/Genuino Uno
  2. Make sure you have these libraries installed: Sketch -> Include Library -> Manage Libraries
    • Relay (By Rafael)
  3. Open PetFeeder.ino sketch file, configure the following params (see attached image for help):
    • auth[] = "REPLACE_WITH_YOUR_BLYNK_TOKEN";

  4. Compile & Upload the sketch to your Arduino device.

Node-MCU Water Unit

  1. Setup the IDE to the Node-MCU board:
    • See this instructable's first part for detailed explanation.
  2. Make sure you have these libraries installed: Sketch -> Include Library -> Manage Libraries
    • WiFi Manager (By tzapu)
  3. Open PetFeeder.ino sketch file, configure the following params (see attached image for help):
    • auth[] = "REPLACE_WITH_YOUR_BLYNK_TOKEN";
    • ssid[] = "YOUR_WIFI_SSID"; // Basically it's the name of your WiFi network

    • pass[] = "YOUR_WIFI_PASSWORD"; // if you have no password, use empty string ""

  4. Compile & Upload the sketch to your Node-MCU device.

Pi Live Camera Module

  1. Connect pi camera module
  2. Run "sudo raspi-config" and set the "camera" option enable.
  3. Test the camera using the "raspistill" command to capture a picture
    • raspistill -o image.jpg
  4. Set Flask web camera server:
    • Install all requirements using pip install -r requirements.txt
    • Use python to run camera_server.py
    • Check it out on 127.0.0.1:5000/video_feed
  5. Set Flask web server to run on boot:
    • Add the following following line to /etc/rc.local (before exit line):
      • python /camera_server.py

Step 6: How to Use the Control Panel

Setup

This part is fairly simple, all you have to do is to insert the "blynk app token" to "index.js" file as follows:

  • const blynkToken = "YOUR_BLYNK_APP_TOKEN" // use the same token from previous steps.

Usage

  1. Open the dashboard by double clicking on "index.html" file.
  2. The dashboard will sample the system automatically every 10 minutes.
  3. Water & Food Container measures can be taken manually.
  4. "Give Water" and "Feed" buttons are used to actively supply your pet with food & water.
  5. The bottom part of the dashboard, will present the live feed from the camera module if you followed the previous step instructions carefully.

Note: If you want to customize the number of times the food container opens when you feed, open up "index.js" file and change the "value" on the next line from "3" to any number of your choice:

fetch(baseURL + '/update/V1?value=3');

Step 7: Challenges, Limits and Future Plans

Challenges

The main challenges for us in this project, were related to designing the food container's open/close mechanism and creating a stable concurrent code for controlling and measuring the food unit. I believe we tried at least 4 different versions until we were satisfied. The main concern was food blocking the exit. In order to prevent that, we chose a Sledge-Hammer design, this way whenever we open the container, the tail of "the hammer" is sweeping food towards the exit. Moreover, using a two-side tube made our life much simpler while building the food container. Such object is perfect for placing the exit mechanism on one side, and a distance sensor on the other side for measuring its content.

Limits

At this phase of project, there are few limitations to the system:

  1. It's not fully automated, meaning that feeding and pouring water is done manually via the monitoring dashboard without any smart schedulers (which could be added in the future, or implemented by you!).
  2. The dashboard is running locally from your own laptop, in order to make more accessible it can be hosted on popular platforms such as "Heroku".
  3. We used a very simple camera module, which can be replaced with a much more complicated module to enable better image quality and possible the addition of communication channel with your pet (using a speaker).

Future Plans

If we had the time and budget to continue developing this system, we had some few ideas and possible schedule in mind:

  1. Adding automatic scheduling system for pet feeding - 2~3 daysof work.
  2. Building a website to enable users of our system to create customized dashboard which are hosted online and accessible from any connected device - 1-2 months of work.
  3. Work on an industrial version for this system, enabling more pet owners to better control and communicate with their pets online, we had a lot of interest from friends who saw the outcome of this Instructable. So, if you have the time passion to take project to the next level - you have are full support!


We hope you enjoyed reading (and hopefully building!) this project :)

Tomer, Gilad, Alon.