Friday, 29 January 2016

The Astounding Canine Torch

It started as a joke over the dinner table. My sister and her partner mentioned that they were trying to do a jigsaw puzzle, which was made more difficult by the poor lighting at their house. At the time, I happened to be finding my way around an Arduino Lilypad light sensor that I'd bought ages ago but hadn't used yet. Since I'm already working on fitting their cat Georgie with a DIY GPS tracker, I joked that I could attach a light sensor and a few LEDs to their dog Cleo, turning her into a night light that would activate when the light levels in a room got too low.

I should say at this point that I usually disapprove of putting animals in costumes. They look so unhappy and uncomfortable, and I just feel sorry for them. This random Internet cat is a case in point:




On the other hand, wearables for animals are super-cute, and provide some fascinating logistical challenges. Plus, Cleo wears jackets and harnesses all the time, and doesn't seem to mind. She even sleeps in "pyjamas" in winter, because her short fur doesn't give her much insulation.



So. The scene was set, the challenge thrown down.

I would have liked to mount this arrangement to a sturdy fabric harness, but the only ones I could find were far too expensive for a quick novelty project like this one. In the end I opted for a cheap doggie t-shirt from Target. It didn't sit very well in place, and if you're looking to make something for more permanent use, I'd definitely recommend investing in a harness, jacket or other appropriately strong and durable dog apparel that can still be sewn onto. As for the electrical components, I used some bits and pieces I already had in my box of tricks:

DFRobot Beetle microcontroller
Battery holder (3 x AAA) with built-in on/of switch
Lilypad light sensor
4 x sewable white LEDs
Conductive thread

I sewed a felt pocket to the top edge of the shirt to hold the battery pack. It's important when working with animals that you use stable, protected batteries that can be safely knocked around, batted, rolled on, etc. etc. without rupturing or causing any other damage. I would NEVER use lithium polymer (LiPo) batteries on fur babies, as I feel this would most likely end in pain for the animal in question, and vet fees (or at least a healthy amount of guilt) for his or her human.

So, here's the final arrangement:



The LEDs are wired in sequence so they're all controlled from the same pin on the microcontroller, and all light up simultaneously. You'll see I insulated the conductive thread with cloth tape, partly to hold it in place, and partly to stop it from coming into contact with Cleo's body. I also completely taped over the circuit on the inside of the shirt. Conductive thread is basically uninsulated wire, and while the voltage involved isn't high enough to hurt an animal, contact with fur could potentially cause a short circuit, which is never pleasant.

The software I used is nothing too fancy - just the code provided by Sparkfun for a connection between microcontroller, sensor and LED, pretty much unaltered. This code allows the sensor to take an analog read, which produces a stream of numbers in the Arduino IDE's Serial Monitor, reflecting the ambient light levels around the sensor. A "darklevel" is defined, which determines the reading at which the room is considered dark. The code uses the darklevel to trigger the LEDs on when the sensor readings dip below a certain number.



I changed the pins to reflect the way I'd connected the sensor to the Beetle (the code is written with a Lilypad Simple in mind), and I also changed the darklevel value to reflect the house this ridiculous device would operate in. Every space has different "normal" ambient light levels, so any project using a light sensor has to be specifically calibrated to its environment.

And here's the very patient Cleo, lighting up the room even more than she usually does with her adorable presence:



Overall, the doggie night light worked OK, but as I said earlier, it would work much better on a sturdier base than the t-shirt. Conductive thread circuits behave inconsistently when they bend in unpredictable ways. If I hadn't been in such a hurry, I would also have attached the battery pack much more securely, so it couldn't jiggle around so much. Ultimately though, I'd count this as a pretty successful initial prototype. If you could securely connect it to your dog's harness it could be a nice accessory for evening walkies - although in that case I'd recommend adding a clear, waterproof covering over the components.


I'd like to take this opportunity to thank Lisa and Andrew for kindly allowing me to experiment on their animals - in a way that I'm certain would be approved by any reasonable ethics committee.