I suspected my Automatic cat feader occassionally failed to dispense scheduled meals. In order to try to prove my suspicions I first set up a motion activated web cam, but found the motion detect wasn't always reliable.
A webcam wasn't the way - I needed to measure actual meal dispensing, there must be a better way. I thought of a few ways...
- Adding a scale to the machine and logging weight changes (still a very reliable method IMO).
- Adding a motion sensor to the front of the machine (not a great method at all)
- Adding a sensor to the motor which dispenses the meals (Bingo!)
That last option seemed like a winner - the motor has a few criteria which made it a good candidate:
- It has a measurable current change
- It only activates when a meal is being dispensed
The solution is an automatic monitoring system using nothing more than a $15 Smartthings sensor and a super cheap photo coupler. It sends email and text notifications if a meal is missed. I purchased a Visonic MCT-343 E, I have already worked with these before so I knew I could simply solder wires to the points A & B.
Note: Simply slide the battery cover off and pry the top cover off with your thumb (this can be done safely) in order to access the circuit board
Having tested and measured the voltage running to the motor when activated, I knew it was operating around 5 volts. Thanks to the kindly help of internet strangers (exibit A) I was able to get a photo coupler working.
That almost felt too easy! To round things out I added a 2xAA battery pack to my MCT-343 E to keep it going longer.
Next up was the logic. I used a IFTTT recipe to log all events from the MCT-343 E on Smartthings to a Google Sheet with a timestamp. Again, feels too easy.Okay, so I'm logging dispensed meals - I could check multiple times every day but that's stupid. Now I need some logic. Thankfully Google makes this ridiculously easy with their "App Scripts".
In the Google Sheet which my IFTTT recipe created I added a second sheet titled "Errors". The following code will automatically insert missed meal entries in "Errors" and send email / text notifications.
In order to accomplish this I created a script on the Google Sheet generated by IFTTT, the full script is included here (make sure to customize "yourEmail" and "yourTextEmail"). To use this you're going to have to add a Trigger, more specifically, a "Time Interval" (you can learn more about that here).
If you would like more information on how to create Google App Scripts in Google Sheets, you can find a walkthrough here.
I know my script is going to draw some ire; it's not beautiful some may say. Others may point out how it's not efficient, and could be done another way. Well... it's easy to read and easy to follow for someone who is relatively new to coding so I think it's pretty darn nice. And most importantly - it got the job done!