The objective of this project is to monitor water consumption of a pet, send an alert when a pet is not consuming enough water and have its water bowl filled automatically when it is low. The water can also be refilled remotely by the caregiver from a dashboard. The water consumption status is indicated by detecting if a pet is drinking using a motion sensor and measuring the water level before and after drinking using an ultrasonic sensor. When drinking motion is detected, the ultrasonic sensor stops sensing until the drink is complete. The water consumption data is sent to ThingsBoard through MQTT. This includes the consumption amount of each drink, total consumption for the day, and the number of drinks taken that day. After 24 hours, the total daily consumption is sent to ThingsBoard through MQTT. If it is below a threshold, showing that a pet has not had much to drink, an email is sent to the caregiver. The collected data can then be analyzed by a machine learning algorithm to detect more complex anomalous drinking behaviours and indicate the health status of pets. A servo motor is used to control a water dispenser to fill water automatically. The servo motor can also be controlled through a dashboard. This ensures a pet always has access to water.
The project uses Arduino Cloud and ThingsBoard. Arduino Cloud is used as an IDE where we write code and upload code to MKR1000. ThingsBoard is used for data collection, actuator control, and sending notification to users. To implement MQTT communication between MKR1000 and ThingsBoard, we must first specify the broker, port, topics and username. To send data to the dashboard, we first create several charts to visualize and store the collected data. To control the actuator, we create an RPC widget in ThingsBoard.
In addition to collect data and control actuator, ThingsBoard is used to setup email notifications to users when their pets don’t consume enough water. Email notifications are sent by following this tutorial: https://thingsboard.io/docs/user-guide/rule-engine-2-0/tutorials/send-email/
The code flow is illustrated in the chart below.
The following video show the device detecting drinking, calculating consumption and automatically refilling the water bowl.
Below shows the ThingsBoard dashboard that collects and displays data from the automatic water dispenser. The blue button turns the water pump on and off to manually fill the water bowl. The three gauges display the current total consumption, drink count and fill count for that day. The subsequent charts contain alarms, consumption data, water distance data, daily consumption, and a table of the real-time data being sent from the Arduino board.
This video shows the consumption data being calculated and published through MQTT to the ThingsBoard dashboard.
Zooming in on the dashboard data, the distance and consumption charts were collected for almost two days. In the distance chart, shown below, the larger the distance, the emptier the water bowl. It can be seen how it is filled automatically before 12:00. The water level continued to go down throughout the day as the pet drank water. Around 11:00 pm it was manually filled before going to bed. The water level stayed steady overnight and then began to increase in the morning as the pet drank.
The chart below shows consumption data. Each blue bar shows how much the pet drank at a specific time. The first bar was captured in testing, when the bowl was manually emptied.
ThingsBoard is also used to manually control the water pump. This is shown in the following video.
An alarm was configured to send an email notification if daily consumption was below 500mL. The dailyconsumption is only published after every 24 hours. Our tests successful ran for 24 hours and published the daily consumption to Thingsboard, but it was not below the threshold. To test the threshold and email functionality, MQTTBox was used to publish a daily consumption below threshold.
This was received by ThingsBoard:
An alarm was updated on the dashboard:
Finally, an email was recieved by the caregiver and notified of the daily water consumption amount.
The following tutorials were useful in the development of this project:
Getting Started with ThingsBoard:
https://thingsboard.io/docs/getting-started-guides/helloworld/
Setup ThingsBoard RPC widget:
https://thingsboard.io/docs/user-guide/ui/widget-library/#rpc-control-widget
Sending Notifications:
https://thingsboard.io/docs/user-guide/rule-engine-2-0/tutorials/send-email/
Comments