Localize your cat at home with BLE beacon, ESP32s, and Machine Learning
github.com
github.com
It would be nice to get a response like, "She's in the litter box" so I know to use a different bathroom to wash my hands.
It's worth acknowledging that setups like this exist in most workplaces, shopping centres, stadiums and other public spaces in many developed countries. 'Free wifi' is not there for your benefit. There are useful experiences enabled by this which may make your life simpler in some contexts, but also worth being cognisant of how common this is. If the benefit provided to you does not balance the privacy loss, you may be interested in https://account.meraki.com/optout and https://optout.smart-places.org/ (you may need to pop a few addresses in here if you use private addresses on iOS).
[1]: https://www.nordicsemi.com/Products/Low-power-short-range-wi...
[2]: https://www.cisco.com/c/en/us/td/docs/solutions/Enterprise/M...
I have a hard time describing it but the write up above triggered something.
I am interested in setting up wifi-valves on my home radiators - this would be really useful in a three storey house as getting balance right otherwise is impossible. But turning on lights and closing curtains just seems to be a foolish trade if complexity for convenience (ie we bought a big second hand car that had electric doors - they were great - till they stop working and you realise there are electric motors, sensors, relays and god knows what else where there used to be a lever.)
Anyway pretty much anyone can see that trade off (even if they do get excited by the electric doors and buy the darn thing anyway).
No the issue is the motion sensor and the lights. I have found myself in offices with those devices - it's a good idea saves electricity- and I understand how it works without any difficulty - and the solution is easy too - a motion sensor has timed out, therefore wave my arms around.
The interface is simple.
But when we add "smart" to it - when we write some algorithm to work out if a person is still in the room - either by direct sensing or cunning working out if they were in room A and now are in B, we end up in failure edge cases quite quickly.
And the problem is it is it simple or intuitive to work out how to "wave our arms" to fix it. If the room assistant is counting people in and out, what happens if I carry my daughter in, but she walks out - how many people are left in the room? How do I deregister ?
A similar thing happened with those electric doors - I let my kids jump out to go see Gran, parked too close to a tree. The electric door wanted to roll back to its full open position before coming forward to shut. But the tree won't let it go fully back. Ok the the engine back on and drive two feet - oh, I can't drive cos the door is open. Shut the door, but the door wants to go back first and hits the tree ... it took two grown men fifteen minutes to work that one out.
The problem is that software engineers like us have tried to make sensible defaults and decision trees - but we fail to cover everything.
Now FOSS is a partial solution to this - but for any appliance, for any IoT, for any thing that I am not paid professionally to understand, if I have to read the code to workout how to get around it, something is seriously wrong.
I am not sure where this leads - it's just ... user friendly usually is not. Simplicity is not just hard but sometimes orthogonal to sales and growth and, frankly I dont think most of our lives need more automation - i think we need help, actual assistance, advice and good curation.
I think I just wrote the opening paragraph on my chapter in MOOP.
It's not the solution, but that ... ok - automation is great if you are a service provider. If you are a taxi firm driving me around automate as much as you like, and you get to own the edge cases. And presumably can deal with them as it's your job. Similarly self driving car - that's a service to me.
But if you are not a service provider, if you are just "helping me but not replacing me" then that's when things fail - as a service provider you can do it your way and Indont really care how. But if you are just helping some but not all of the solution then you have to do it my way, or i have to (re)learn your way - and that means access to reading your code (maybe lessons and training for me)
really i don't want lessons on how your light bulb works, or need to watch a video on my hotel rooms AI.
We are seeeing this in self driving cars - half automated is not enough and often far worse.
I like the idea of not letting someone drive off with the doors open. It seems sensible. But we could not work out how to override it.
Have never had a chance to try it as, of course, our cat refuses to say anything if a phone is pointed at him :-|
A couple months ago my friend found his cat dead after her collar caught while jumping over the fence. Poor little baby beast. :/ I look at my fun-loving critter basking in the sun as I write this and it breaks my heart to imagine her suffering like my friend's poor cat did.
Example of a collar with elastic segment: https://amazon.com/dp/B07P8V374M
Ultimately, how cats deal with being harnessed even after being acclimated is extremely individual personality-dependent. I've seen some happily walk like dogs. Mine don't particularly want to walk alongside people and very quickly want to go off under plants or other places where they can hide and stalk, and where people can't easily go. We take them out for as long as both they and we can stand, and don't jerk them around.
The Kitty Holster type harness is significantly less escape-prone than say the PetSafe style of nylon straps, and probably less uncomfortable as well.
edit -- but of course danging by something other than a neck might be preferable...
Or the cat might be OK with the breakaway collar now, due to "learned helplessness".
So idk if this helps, but maybe try different colors and configurations and find what your cat likes. Also tightness has a lot to do with it.
Turned out to be a coyote trap and there was a plastic link on the chain that attached it to the tree or whatever, that he had chewed through then limped home on three legs. If not for that link, he'd probably have died out there since the person who set it was clearly not checking it every 24 hours as required by law.
Luckily he was big enough that the trap couldn't close tightly enough to damage his leg and he was running around fine by the next day.
And if they are indoor make sure they have areas to run around, be sure to play with them (they are a pet! They are your responsibility!), and watch their diet (often people let them get too fat and it takes awhile for cats to lose weight).
Given the crap that barely passes for industry pet "food" it's hard to keep an indoor animal slim (it's easier for dogs though since us can openers take them out for walks regularly). Pet foods are made to look and smell appealing primary to us can opener humans, not the pets. And dry foods are even worse for cats and dogs - they are used to stuff like grain as small part of the mice and other rodents they naturally eat, not as filler material.
PSA: Get your pets high quality food that is similar in composition to what they'd eat in nature and not highly processed crap. You don't diet on frozen pizza, burgers and full sugar soda all year, so please don't feed your pets the equivalent.
And you are encouraged to take your cats on walks. My friend runs a line across his backyard and attaches the cat's harness to it. She gets to run around and the bell makes birds very aware of her presence. Telling people to keep them inside doesn't mean you don't play with them (I explicitly said the opposite). I should refine that you shouldn't let them roam outside. On a leash is fine.
People don't realize this, but you can in fact train cats. My cat does tricks.
From warm to cold:
Hall floor
Livingroom floor
Hall box
Livingroom box
Livingroom couch
Bedroom bed
Bedroom bed under the sheets
catnip might introduce jitter.
Case in point: The vet. Our cat somehow knows from our behaviour that the visit is today, and disappears off the face off the earth. We had to cancel a visit because we spent more than two hours searching and were late.
So new appointment a day or 2 later, and we watch every step of the beastie like hawks. She disappears behind a cabinet, does not come out, and can be found neither behind or inside. Huh? It turns out the back of the cabinet is open, and there is a really tiny space between drawer and back. If I open a drawer, she goes up/down a layer.
I knew all the time she was less than 50cm from me, and it still took me 15 minutes to figure this out. I've been thinking about creating a tracker, but then , the cat healed enough to lower the frequency of vet visits.
The idea is to periodically send a list of WiFi SSIDs along with RSSI's so I can triangulate the cat's location using the signal strengths of each network. Similar to how the first iPhone would find your location without needing GPS.
But my first thought was: Input: "meow" Output: "miau"
So I’m wondering whether a timer that inflates a big red balloon after 4hrs wouldn’t be the best choice.
It works without cellular. It has two modules, gps on a dog which emits some data RF signal and a receiver in your pocket. They claim 3km range. I can confirm 1.5km. Didn’t test further. Quite magical actually
Looks like a classic case of the famous Jurissac Park quote: "Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should."
Triangulation works accurately in open space, however this use case is inside a home with signals being blocked, bouncing, or attenuated by walls, mirrors, appliances, etc. On top of that, the goal is to use as few BLE rx'ers as possible (meaning not one per room). Given those constraints, a trained ML model actually does make sense.
"ML" is just a very overstated word for: "I have a handful of example data and a library that does basic math things"
The main difference between stats and ml is (i) community, (ii) stress on the details of compute and the focus on prediction accuracy rather than accurate recovery of parameters. A scheme that ensures good prediction even if the parameter is not recovered, for ML that's still a success.
https://www.darkreading.com/vulnerabilities---threats/resear...
This way you can tell when your Cat has left the building without getting cancer.
One of my favorites was a color scan taken in multiple passes with filters. The cat was not stationary through the whole process
https://thecatscan.tumblr.com/
http://www.cat-scan.com/cat-scan/ (put up your sunglasses..)
I know that people have done various forms of radar with wifi signals; I wonder if I could have a few sensors throughout the house and use ML to determine if various doors are open or closed.
Works well for some outdoor critters
$ cat -L "en/us" /tmp/french-file.txt
[0] - https://en.wikipedia.org/wiki/Simultaneous_localization_and_...
Edit to add: But I can see how in a specialized field, where methods for locating an object are frequently discussed, using localization over location would be useful for describing the process of finding something, since location is also a noun referring to the place itself.
'Locate' implies that you're predominately interested in the object being sought but 'localize' suggests you're more interested in the place where it is/was. I think localize can also be less-than-exact if it rules out some plausible locations, but it seems odd to partially 'locate' something.
It's used a lot in neurology/neuroscience for the process of identifying where (e.g.) a tumor is or the brain structures on which a particular behavior or process depend.
"Localize" has various meanings, but in a physical location sense is to restrict something to a particular area, e.g. "We successfully localized the fire to the Johnson farm so no other farms were damaged.".
I can't see a definition that is equivalent to "locate" or "find".
Locate your cat at home using...
Or
Domestic Feline location using...
Depending on the level of techno-mumbo-jumbo the author is looking for.
https://dictionary.cambridge.org/dictionary/english/localize
Maybe it's British vs American English?
"Locate" would lead to less confusion among readers. It unanimously has the right definition, and is a simpler word.
$ LANG=ca_ES.UTF-8 cat asldkj
cat: asldkj: El fitxer o directori no existeix
$ LANG=ca_ES.UTF-8 cat --help
Forma d’ús: cat [OPCIÓ]… [FITXER]…
Escriu la concatenació de tots els FITXERs a la sortida estàndard.
Sense cap FITXER, o quan FITXER és «-», llegeix l’entrada estàndard.
[...]It’s not wrong, and I would encourage the author to leave it as it is.
The way I implemented it was to have each beacon transmit on I think 1s (might have been 5s to save power) intervals, and some python code on an RPI that listens for them, with a timeout for each. If the listener gets a ping it immediately forwards it to mqtt as a "home" ping, using the beacon id to set the topic. If it doesn't get a ping within the timeout then the rpi generates and sends an "away" mqtt message for that beacon. My expectation was to have it alert me within ~2-3 minutes of a vehicle going from "home" to "away". In practice:
- BLE beacons aren't very popular really, most of them are made by small foreign companies who don't sell them in places like Amazon. The ones Amazon does sell are kind of crappy. Setting them up usually involves downloading a vaguely-sketchy app to your phone (I haven't figured out how to configure them from the rpi). They all seem kind of janky honestly.
- Bluetooth and Wifi use the same (some) hardware on an rpi, meaning if you start rapidly scanning for BLE tokens your wifi performance will drop to the point of the rpi being unusable (ssh sessions timing out). I fixed this by buying a separate USB bluetooth dongle, although even that was a pain to get working in the pybluez module - in general bluetooth under linux along with the python bindings are finicky and crap out easily, it seems.
- I have my dmesg and syslog spammed with "Bluetooth: hci0: advertising data len corrected" when using bluetooth scanning, I managed to find a couple bug references to it and other people complaining about it but no fixes over multiple system updates.
- It's just... Not reliable. I don't know why. I've tried really hard to make it reliable, and maybe the problem is the RPI-as-bluetooth (maybe if I used a microcontroller as the receiver it would work better?), but I've tried all variations of scanning windows and such and dug down into the code for Bluez without figuring out either what I'm doing wrong or where the issue is. Beacons will supposedly not ping for minutes at a time despite being on a 5s interval no matter what I do, and this is for beacons maybe 6 feet from the receiver (although ones further away do timeout more).
The last thing is what finally killed the project for me. I had it (still have it) all setup in HA with notifications and schedules and such, but I just turned off all the automation for it until I get a chance to tear it down. Failed experiment.
There's a cat in our neighbourhood with one of those, it's funny to walk out there in the middle of the night (we violate curfew and walk the dog close to midnight) and see a cat with a collar with some blinking lights staring at us from the bushes.
Kinda wish one of our cats had one of those when he went missing, but it's likely he would've lost the collar at some point anyway (he looked like he squeezed himself through a tiny hole and couldn't get out again until he lost a ton of weight two+ weeks later when he came back)
Why?
Why not? Curfews are ridiculous, authoritarian measures taken to curb "improper" activities not associated with walking a dog.
Who cares why, and what business is it of yours?
But my cat really doesn't like collars, so the real utility seems to be in locating where he managed to remove it...