monicat - ESP8266-based MQTT Happy Catiot · esp8266
OK, so I wanted to play a bit with MQTT. MQTT is some kind of a machine2machine chat protocol, letting devices chat to some kind of chatrooms, whilst other devices in that chatroom are listening. Terms are not completely correct, mqtt calls it publishers, subscribers and topics. You get the point. Think of a botnet. Just with IoT Gadgets. What could possibly go wrong :)
Just playin’ a bit around with an mqtt broker (that is the chat server :) ) and some command line clients is boring. Something has to happen. And when using MQTT as a backend for all sorts of stuff like monitoring, sensors, things, a universal notification device would come in handy.
Again… a box with some lights would be boring….
Monicat, the mqtt based happy cat
So I thought it’ll be a nice idea to have something that moves. Inbetween the days at 2016 I had seen several Talks recorded at the 33c3 congress, and several of them featured a lucky cat on stage, just to show the video operations team that the recording stream is still alive ( while the lecturer might not make to many movements on stage…). Perhaps controlling such a Cat would be a funny idea.
But, rule of thumb: first check if someone else did it. Bam: https://github.com/themad/jimmykater. Funny coincidence: Based on the code and the release date, this seems to have been done on exactly that 33c3 congress.
So this could be a good starting point. Even better, they also equipped the cat with some LEDs as eyes, using some special LEDs ( Adafruit Pixel Leds) I had lying around here, too. Perfect!
Short test on a breadboard revealed several issues ( ok, at least for me …):
- Cat only reacts a short amount of time on incoming mqtt messages. I need something that lights permanently until another event kills that state.
- Waving paw uses a servo. Servos are loud. Loud things are annoying in a living room.
- No authentication. This is fun for testing, but as I will use a private broker, there’s no chance to run that thing unathenticated.
- Hey. We have cool RGB Leds, capable of dimming’n’stuff. Lets use it!
Easy. Go to ANY asian supermarket and buy such a lucky Cat. Don’t buy the Plastic Version. Buy a golden one. They’re usually made of clay. This will get you a bit in trouble when drilling the holes, but hey, it’s at least not plastic. Buy a cat which is at least 8” or 20cm in height, makes life easier.
Step 1: Opening the cat.
So you bought that cat for for around 8$/EUR. You didn’t expected screws, didn’t you?
Be careful. It’s Clay. And your Knife. And your Fingers. Btw.: The Arm can be removed by simply pulling it off.
Afterwards, it should look like this:
The original circuit is quite easy. There’s a permanent magnet on the pendulum, which swipes over the coil on the circuit board. This induces a small amount of energy driving the base of a transistor. This powers the coil in this case and generates some magnetic force to pull the pendulum. If that has moved, there’s no induction anymore generating power for the transistor base, the pendulum falls back. There’s a second transistor doing the same for the opposite direction ( with inversed polarity). So it’s some kind of self-inducing oscillating circuit with some mechanical components. The circuit needs a fair amount of time to swing in ( sometimes it takes a minute), but that’s not such a big problem in my usecase.
Could we drive that thing directly using an ESP8266’s GPIO? Let’s find out:
Ok. Easy. Some peaks at 11mA, but usually a lot less. An ESP8266 can drive 12mA on one output, and this is the minimum they guarantee.
Drilling the hole
Now comes the complicated part. I neved worked with burned clay, but I know it can disintegrate easily. So my first attempt was to use a high speed power drill ( “dremel”, “proxxon”) and use a very small drill like the ones to drill circuit boards. No Way. Did cost me 3 drills. All broken and blunted. Still no hole. What worked was this thing:
On the second eye I used some water for cooling, this worked a bit better. But keep in mind: no force, just constant grinding. Luckily, I had a grinder with 5mm diameter. Repair the edges with a black marker.
Wiring the Cat
I used a Wemos D1 Mini in that project, which comes in handy as it has an usb2uart converter onboard, while still beeing quite small. I also use that integrated USB interface for powering the whole circuit, so you can use a standard usb cable and a cheap wall charger.
I simply used hot glue for putting everything together, it’s fast and you can still undo everything (which you need to if you placed the board like in the picture above. Take a closer look at the pendulum….).
Ok, now for the wiring: As you also need the code, and the code somehow belongs to the circuit, just head over here.