Igor Fonseca Albuquerque
Published © CC BY-NC-SA

IoT Cat Litter Box (with ESP32, Arduino IDE and ThingSpeak)

This device can measure the weight of its users (the cats), check cleaning conditions, save the data online and send reminder and alerts!

IntermediateFull instructions provided6 hours7,563
IoT Cat Litter Box (with ESP32, Arduino IDE and ThingSpeak)

Things used in this project

Hardware components

FireBeetle ESP32 IOT Microcontroller (Supports Wi-Fi & Bluetooth)
DFRobot FireBeetle ESP32 IOT Microcontroller (Supports Wi-Fi & Bluetooth)
×1
SparkFun Load Cell Amplifier - HX711
SparkFun Load Cell Amplifier - HX711
×1
Load Cell, Low Profile
Load Cell, Low Profile
×4

Software apps and online services

Arduino IDE
Arduino IDE
Fusion 360
Autodesk Fusion 360
Maker service
IFTTT Maker service
MATLAB
MATLAB
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Thingiverse

https://www.thingiverse.com/thing:3737074

Schematics

Schematics

Code

iot-litter-box-thingspeak-v0.ino

Arduino
No preview (download only).

calibration.ino

Arduino
No preview (download only).

Code snippet #1

Plain text
% Read the channel data from the past Day.
% Send an email via the IFTTT service to report the user about the measurements

% Store the channel ID for the IoT Litter Box.
channelID = XXXXX;

% Enter the trigger url from IFTTT.  It will have the form:
iftttURL = 'https://maker.ifttt.com/trigger/LitterBox/with/key/XXXXX';

% Channel Read API Key (if you are using your own moisture channel)
% If your channel is private, then enter the read API Key between the '' below:
readAPIKey = 'XXXXX';

% Read the last day data from ThingSpeak
cat1weightData = thingSpeakRead(channelID,'NumDays',1,'Fields',1,'ReadKey',readAPIKey);
cat2weightData = thingSpeakRead(channelID,'NumDays',1,'Fields',2,'ReadKey',readAPIKey);
cat1usesData = thingSpeakRead(channelID,'NumDays',1,'Fields',5,'ReadKey',readAPIKey);
cat2usesData = thingSpeakRead(channelID,'NumDays',1,'Fields',6,'ReadKey',readAPIKey);
sandData = thingSpeakRead(channelID,'NumDays',1,'Fields',4,'ReadKey',readAPIKey);

% Calculate average daily values
avgcat1 = (max(cat1weightData) + min(cat1weightData))/2;
avgcat2 = (max(cat2weightData) + min(cat2weightData))/2;
avgsand = (max(sandData) + min(sandData))/2;

% Calculate number of uses of the box
usescat1 = max(cat1usesData);
usescat2 = max(cat2usesData);

% Create message
message = "<b>Daily report:</b><br> <b>- Cat #1:</b><br>- Average weight: " + ....
num2str(avgcat1,2) + " kg<br>" + "- Used the litter box " + num2str(usescat1) + ...
" times today<br><br>" + "<b>- Cat #2:</b><br>- Average weight: " + ...
num2str(avgcat1,2) + " kg<br>" + " - Used the litter box " + num2str(usescat2) + ...
" times today<br>" + "<br><b>- Sandbox status:</b><br>- Sand weight: " + ...
num2str(avgsand,2) + " kg<br>" + "- Total uses: " +  num2str(usescat1 + usescat2);

% Send message to IFTTT
webwrite(iftttURL,'value1',message);

Github

https://github.com/mathworks/thingspeak-arduino

Github

https://github.com/bogde/HX711

Credits

Igor Fonseca Albuquerque

Igor Fonseca Albuquerque

18 projects • 380 followers
Electrical and Mechanical engineer, master in automation and control. specialist in industrial instrumentation. Mad scientist and inventor.

Comments