The Bindicator

So I made this project for my dad for Fathers Day a couple of years ago, and thought i'd share it. The one shown is the Rev-1 design which is far from perfect, in fact it has several major issues I will discuss below, however it definitely works, and works reliably.

The project started with a few straight-forward objectives:

  1. Needs to indicate which bins need to go out on bin day
  2. Needs to warn you at least the day before which bins are needed
  3. Simple and compact design
  4. Runs on a single 9V battery
  5. ~12 months on a battery

Let's just say, in Revision 1, mistakes were made...

Firstly, the choice of a 9V batter was definitely a mistake. I'd not realised until then just how little energy is available in a 9V battery. On average ~550mAh is all that is available, compared to the likes of a 18650 cell, which can hold between 1500 and 3500mAh depending on the type. Additionally, upon further investigation, the choice of the ATTiny84 proved problematic to the design, as while perfect for the task, it had limitations i'd not really known about as usually projects I made were designed to run either on DC or USB power sources. I had never developed for an MCU to run in sleep mode and in order to achieve this the most efficiently possible, I needed to include things in my design which I had not considered. This included:

  • At the brightness I wanted, the LEDs I had chosen draw around 5-10mA
  • Using the Real-time clock alarm interrupt as a wakeup trigger
  • Running the CPU at a much lower voltage when asleep
  • Running the system clock a lot slower than the default 12Mhz, and
  • Latching the LEDs in their on/off state without the CPU being on
  • A self-contained front panel PCB should NOT use through-hole parts (LOL)

Without these considerations, the first prototype was what I would consider a failure. Although I was able to give the first unit to my dad for Fathers' day, it couldn't run on batteries for more than a few days. I ended up hard-wiring a USB power cable directly to the output of the 9v-5v converter IC and used that to power the unit. It wasn't as pretty as I'd liked, but it worked.

And one thing that I was somewhat expecting, but still never ceases to amaze me, is just how well the DS3231 Real-time Clock is able to keep time, even without power. One thing I did get right, and that the design of the DS3231 makes rather simple, is the provisioning of a backup battery to maintain the clock even without main power.

The software, although not taking advantage of the alarm interrupt triggering, and sleep capabilities of the ATTiny84, worked exactly as I had intended. Without fail it would slow blink the LEDs corresponding to the bins in question the day before, and fast-blink the LEDs on the day the bin was supposed to be out. From 8am to 6pm without fail, they blinked perfectly. That was definitely a win.

The String arrays for the Serial Menu system used to configure the unit

While some of the code is quite involved, especially around having to manually calculate the day of the week, the week, and the day of the year (the DS3231 doesn't provide this information), the logic controlling the triggers is actually super simple.

What are my takeaways for Rev 2?

Firstly, I need to get the MCU sleeping when it's not needed. In theory, that should be almost all the time. When it's sleeping, it's current draw is in the order of microamps (not milliamps).

Next, I need to have the micro, once woken up by the DS3231 (which can still generate triggers when sleeping using the backup battery) have the Micro trigger some passive circuitry (potentially some sort of latching circuit and a 555 timer or even an RC oscillator to blink the LEDs by selectively pulling the common cathode LEDs to ground. And when it's ready to stop, have the micro power up, unlatch the passive LED controls, and then shut down again.

The power switch is completely pointless, and won't be included in the Rev 2.

Then the circuitry needs to be adjusted to to reduce the brightness of the LEDs based on the light in the room. It doesn't need to be blaring if the lights are off in the room, and then when they are, I don't think they need to be as bright as they are. So I'll mess around with different current-limiting resistor values to reduce the current draw. I am guessing 1K should do the trick.

Additionally, the next iteration needs to be entirely SMD components. Originally I had thought about making it a kit and through hole kits are the easiest to build, and great introductions for beginners; however the through-hole finish ruins the aesthetic of the panel. They have to do.

I need to modify the fuses in the MCU to get the CPU to run slower. It doesn't need to run at 12MHz when it's operating. 1MHz is more than ample. I will keep the internal oscillator for this, as CPU timing accuracy isn't required. The DS3231 has all the precision the project requires. The MCU is basically just a smart switch.

Finally, I need to introduce a USB port with USB serial interface into the design. Currently the only way to set the clock and/or change the bin days is to use the In-Circuit Serial Programmer (ICSP) header pins connected directly to an ICSP programmer. This isn't suitable for the average user. I messed around with using DIP switches for the control and setting, but it proved impractical as I worked out I'd need about 14 switches in order to be able to intelligently change the settings requried. The software already has the terminal menus all ready to go, and it could easily be driven by a small app on the PC to simplify management. Another option might be to introduce Low Energy Bluetooth (BLE), but that may be a Rev 3 option.

I'm also putting in an optional pin header (for the uber extreme version) to include a GPS module which will allow the DS3231 to get the current time from GPS. Certainly doesn't need this but it's an excellent and easy to implement premium feature. It would only need to poll once a month as the DS3231 at most loses about 1 second a day (in practice the one I run has been operating for about 18 months, and is still only about a second out.

As I work through Revision 2, to date I've switched the Microcontroller from the ATTiny to the ATMega16U4 which is the smallest Atmel micro with native USB support. It increased the MCU price, but I don't need any additional active circuitry to provide a USB port on the design. Winning!

I've also updated the battery monitoring circuitry to allow it to periodically check the battery voltages to provide a low batt warning, without unnecessary draw on the batteries. All more optimisations to improve battery life.

I haven't designed the circuitry to handle the 18650 power input and/or the USB charging circuitry for those cells; those are still mulling around in my head as to how best implement those. I will likely opt for a single-IC battery management charging IC. It can also offload the Low Battery monitoring and alerting, which is excellent. Less for the MCU to waste energy on.

As you can see below, the design is still using through-hole LEDs, and I may later on decide to switch to reverse-mount SMD LEDs, but I think the through-hole 5MM LEDs look better.

Messing around with layout options on the Rev2 Design. Even the Pin Headers are SMD. 

Conclusion

Rev B still has a long way to go, but when it gets there, it's going to be fantastic. Loving this little project. Really enjoying getting my hands dirty on the low-power stuff. Will keep you posted. Stay tuned.