Start Date: 10/9/2024
A few months ago at bed time, our dog was in the living room, sleeping on the couch. I wanted him in bed with us, but I didn't want to shout for him and bother my wife.
I wished I had a way to just send him a quite signal to give him commands.
I remembered yesterday (10/9/24) and decided that it is time I actually made it.
This page chronicles the project.
I changed the case design to include a light channel for the LED. It is printed from clear PETG.
I also decided that the standard red light was not visible enough, so i changed it to blue. To avoid skewing the battery life data, I only plugged it in long enough for the code to update. This was less than 30 seconds.
So far, the device has yet to lose power since it was disconnected on 10/29.
Doing the math about how your device Should work and actually Seeing it work are two entirely different things. I unplugged the device from the charger on 10/29 at 8PM. It is still working! It is a very satisfying feeling to overcome obstacles like this. Initially, it was only lasting 5-6 hours. Then I got it to 13-14 hours. To make the leap from that to this feels extraordinary.
Having unplugged the device from power on the 29th, it is still going strong!
Training continues to progress well.
Finally figured out how to get the current down!
After doing research over several days, I finally found the answer on a forum regarding the nRF52840 and power management that provided an actually solution..
A delay of 1 second in the main loop.
That is all it needed.
Once I added that, the current went way down. Before I modified the code, I was getting a current draw of roughly 7.8mA. After a few adjustments, I was getting around 6.6mA.
after adding "delay(1000);" at the beginning of the main loop, my current while connected was only 0.25mA! When the device was creating a tone, it measured at less than 6mA. When it was only advertising at 1 second off and 1 second on, it oscillated between 0.04mA and 0.11mA!
I was extremely pleased with these results!
The dev board I was using had incurred some minor damage, primarily to the on-board LED, during rough handling. Because of that, I migrated the physical components to another of the same kind of board. my PCB Holder was instrumental to this process. The result was a much cleaner looking and fully functional device.
Murphy is also continuing to improve in training. I have begun using the device periodically, instead of relying on compressed training sessions. During training sessions, he realizes that he can get more treats if he goes to his crate often, even if he isn't supposed to, because I have to give him a treat to come out.
Training and research.
Using the low-power sleep function on the Seeed Studio Xiao nRF52840 proved to be much more of a challenge than it should have been. I spent a little bit of free time looking into various forums to find a solution.
Using two 60mAh batteries and some minor programming adjustments, I managed to get roughly 12 to 14 hours of battery life, depending on how much I was using it. The current draw was still averaging at 7.8mA without being connected. This was much higher than it should be.
Periodic training went well and Murphy is showing continuous improvement following the "Come" and "Go Home" commands. "Go Home" is how we tell him to go to his crate.
The easiest way to double the battery life is simply to double the batteries. As I pulled the first battery from a pair of wireless earbuds, I had a second battery to work with. I was able to squeeze it in there.
I also printed the new cap design.
Testing showed that the battery lasted about 5 hours.
I charged it overnight and unplugged it at 8am. It lasted until roughly 1PM before the bluetooth signal was lost. There are a few options that I would like to try to increase battery life.
The battery that I am currently using is a 3.7v 60mAh LiPoly battery. A standard C2032 button cell battery could provide 200mAh, but I would like to find a way to keep it rechargeable. I am looking into other rechargeable batteries, as well.
Battery life can also be further improved through code by further altering the advertising interval and possibly through other means.
The whole concept of this project is not dissimilar to key-finding devices like Tile. Those operate on C2032 batteries and last for months. Their circuitry does not include advanced microcontrollers with the wide range of capabilities seen in development boards such as the Seeed Studio Xiao. It would be interesting to explore making my own basic circuit from scratch. Most of the components on the Tile's board are unmarked, however, so that adds another level of challenge to that possible venture.
I am also adding texture to the cap to make it easier to put on and take off without risking accidently breaking the keychain off.
I made some modifications to the current design.
Added o-ring
Reinforced the keychain hole
improved the mech retention ring
I also updated the code to conserve battery power.
These changes should provide roughly 3 to 4 times longer battery life.
Changed the advertising interval to 4 seconds
Device disconnects if it does not receive any commands within 20 seconds
Changed the tones
Now, its time to start training Murphy!
I worked through some of Android app development tutorials at https://developer.android.com/courses.
I designed and new case to go with the smaller electronics profile.
The new case design is much simpler. While I liked the dog bone shape, it wasn't really practical, so I made improvements.
This design is much smaller, tougher, and easier to assemble.
The electronics snap into place and are held securely.
Downloaded and installed Android Studio. Started looking through some tutorials.
The electronics I used to begin with were just parts that I happened to have laying around.
The battery and battery case were somewhat large, so I replaced it with a LiPo battery from the headphones. It is a small battery, but it lasts 3-5 hours. I will upgrade it later. The Seeed Studio Xiao series comes with a built in LiPo charger, so all I needed to do was solder it on.
The speaker from the earbud was a little too quiet, so I bought a buzzer to replace it with. The volume with the buzzer is perfect now.
This setup is has a much smaller profile, so I will design a new case to go with it.
Case design improvement
After printing the original case in PLA, I found that there were some things that needed to be changed.
Latch arms were too long and flexible
Changes the design.
Switch mount was too thin and brittle
The Indicator light window was on bottom. It should be on the top
I loaded three different tone sequence options.
Initial case design.
The first thought I had for a case design was a bone shape, because it's dog related. Of course, this is not the optimally efficient geometry for such a device, but it gave me an opportunity for some creative problem solving.
The speaker from the earbud was not very loud. This was good, because I did not want the system to be too loud. Only Murphy needs to be able to hear it. It was a little bit too quiet, though. My idea was to use the shape of the the case boost the sound a little bit. I designed it so that the speaker mounts in the back side of the case and the front side has a tube that connects to the output of the speaker and widens towards the front.
The acoustic tube would end in a cap with holes and backed with a hydrophobic, acoustically transparent mesh, such as gthe material that I used when developing the IAM. This piece needed to be printed with a 0.25mm nozzle, but my printers are currently set up with 0.4mm and 0.8mm nozzles. The intent was to print this piece once the design was finalized.
I began working on this by looking though all my myriad parts to see what I had to work with. I ended up using these, because I happened to have them on-hand:
Seeed Studio Xiao nRF52840 (Sense)
An old pair of JBuds Air True Wireless Earbuds
I removed a speaker from one of them
a CN 2032 battery and holder
Murphy tried to help, but he is not very useful. Actually, he tried to climb on me while I was working at the computer, but he is adorable, so it's ok.
Once I had my parts, I began to develop the code in Arduino IDE.
To start, I followed the simple Demo 1 tutorial on the Seeeduino Wikki.
The Demo 1 program walks you through setting up Bluetooth between your phone, using nRF Connect on Android, and the microcontroller.
The demo code allows you to send either 1 or 0 to the device, which will turn the on-board LED on and off. Once that was done, All I needed do was modify the code to accept different numerical inputs and to play tones through an analog output pin.