Written by Elecia White.


I have a client project where they made a device with an Arduino UNO, datalogging shield, small display, photo interrupter, and a motor driver controlling a stepper. When a mouse takes a pellet of food, the photo interrupter’s IR beam is no longer blocked so the system wakes up, moves the motor, and logs the date and time to an SD card.

They wanted to make it lower power so it would last for 10 days on their 5V 11Ah battery. They also wanted to keep it reasonably priced (<$100 if possible), easy to use, and something a motivated high school student with limited soldering and software skills could make from off-the-shelf parts. (It is the last goal that makes this an interesting project.)

To reduce the power consumption, I swapped the Arduino UNO out for an Arduino Pro: not having to power the USB processor gives a big savings. We switched the current limiting resistor for the IR LED in the photo interrupter (220 ohms to 4.7k ohms, this limits the current much more going from 22mA to 1mA). I added control signals to turn off the motor driver. With a few more tweaks, I got sleep current to about 30mA (loosely it is 10mA for the display, 10mA for motor driver + sensor, and 10mA for the SD card). Since the mice only get about 100 pellets a day and each pellet delivery takes less than two seconds and the system is off 99.5% of the time, sleep current is all I’m worried about.

However, these reductions broke their battery. It was designed to recharge phones and couldn’t handle such a small current draw. It kept turning itself off. We switched to a 3.7V 6Ah battery with a little boost circuit. My numbers say I hit over 7 days (new goal after reducing the battery).

Software Block Diagram

Still with me? Want to watch the project as we go about finishing it? As I made the system more buildable, I suggested moving from their relatively complex-to-solder motor driver to the Arduino motor shield. It doesn’t take more power in sleep mode and is vastly simpler. We’re still working on getting that in place as well as verifying that the theoretical numbers cross over to real life.

Even with those things left to work out, I’m starting to think about phase 2: the Internet of Mice Feeders. The requirements are mostly the same here: 7-10 days on LiPo battery, easy to build, and still feeds mice, but now network connected.

I have many options. The first big decision point is the wireless mechanism: BLE, WiFi, or some other protocol. I’ve been doing a lot of BLE lately so it is very attractive to me, out of habit. However, BLE needs to talk to something; it can’t directly communicate to the internet. I would need to write a computer program to listen to BLE (probably advertisements) and log them.  This would be true of Zigbee or ANT or other local protocol.

WiFi has the advantage that there are many existing data logging systems. It is higher power but since the pellets only need to be logged every hour or two, it may be lower power than the current implementation.

The least impact option is to use a WiFi module in place of the SD card. Sparkfun has an ESP8266 module for $7 (or shield form for $15). I can use it in modem-like AT mode so it isn’t a matter of running our code on the ESP8266. It sleeps at 8mA so I could replace the datalogging shield (and that 10mA SD drain) and be done.

On the other hand, for more cost ($35), I could get the C3000 WiFi module which sleeps at 5uA (!!). With updates required so seldom, the sleep current really matters. I think the mice would prefer longer batteries to lower cost but this is tradeoff I can present to the team.

Have you read The Hitchhikers Guide to the Galaxy? In the book, the purpose of the Earth is to test theories by pan-dimensional beings whose representation in our universe takes the shape of mice. Such thoughts occur to me often as I work on mice feeders.

Other than making the system easy to build and leveraging existing code (there isn’t that much), there is no reason to stay with Arduino. I can run the whole system from the ESP8266. Using the SparkFun Shield form or their new Thing form, there are enough GPIOs to drive the display and motor driver. If I use the Arduino IDE for the ESP8266, I think it still falls under “easy enough” especially given that there is a pretty good tutorial.

I’m making some pretty big assumptions that the power consumption won’t go up by using the platform. The schematic for the Thing is straightforward. The only component that was non-obvious to me was the AT25SF041 which turns out to be a 4Mbit SPI Flash. That is actually really nice; I’d been worrying about those times the system did not have a WiFi connection and how that situation could be handled gracefully. I hope there is space there to do more than store code.

Ideally, the system would log to SparkFun’s data center (Data.SparkFun.com). Sadly, the mice don’t always have Internet access. SparkFun has a method to run their server (phant) locally so that is a big win. I may not need to set it up but it is nice to have a non-connected backup available. It would require a computer, a wifi router, and a bit of network configuration. Not trivial but not impossible.

There are other platforms to consider though. I have experience using Electric Imp, I like their system. I’ve seen robotics things done with the Imp so I expect I could drive the servo. I know their sleep current is very small (I’m consistently getting nearly 6 months of battery life from four AAs on another mostly-sleeping project). My concern with their platform is that it is a bit expensive (compared to the ESP8266) and their cloud is proprietary: the mice would have to have internet access for the system to function.

I also like the newer, cheaper Particle.io Photon with their easy-to-setup WiFi system. It sleeps deeply as well and, while preferentially able to interface to their cloud, it looks like it can be configured to work with phant as well. I’m familiar with the Photon processor (STM32F205) which is a plus. That processor can do logging to its processor flash; that’s a nice backup that Electric Imp doesn’t have. To use such logging, though, I may need to get out of the Photon easy development environment and into something more low-level. I also don’t know if it would be easier to program for than the ESP8266 Thing, though it has lower sleep power, probably (uncertain: <insert rant bemoaning the lack of platform specific sleep numbers>).

There are some other platforms. One is ack.me but they seem to be mostly selling modules. Their development boards have more built-in features than I want. Moteino is popular outside the US but I haven’t gotten my hands on any. I’m sure a custom board would be everything I want but it misses the goal of off-the-shelf parts.

Unless you have other suggestions and pending a deeper review of the ESP8266 sleep states, I think I want to get a Thing and try it out. I can combine that with a motor driver and display, possibly making the wireless version simpler, cheaper, and more power efficient than the current Arduino version.

 

Thing Architecture Sketch