Fork me on GitHub

Project Notes

#528 ATtiny IxpandO

Using an ATtiny85 to drive the Boldport IxpandO MCP23017-based I²C IO expansion board.



I like Arduino - mainly because it is always surprising to find how much can be done with such a constrained microprocessor. But sometimes even an ATmega328 is overkill, in which case it is fun to try and squeeze a project into an ATtiny instead.

One of the challenges with the ATtiny is that the Arduino Wire library is not supported, so there’s no direct support for I²C.

A leading alternative is the Adafruit TinyWireM I²C for the ATtiny, so I wanted to test it out. The library already comes with examples for how to use it with temperature sensors, LCDs and RTCs, so I though I’d try something different - the MCP23017 port expander, which could be a useful tool in cases where the ATtiny has all the processing power and memory required, but it just needs more I/O.

To test this, I’m using the Boldport IxpandO - an input/output expansion board based on Microchip’s MCP23017 (BoldportClub Project #16).

Code Modifications

I’m using the ATtinyController.ino sketch for the demo, which is a modified version of the demo sketch I used with an Arduino when I first built the Boldport IxpandO.

Key modifications:

  • a different library name, although I’ve obfusticated this with a #define Wire TinyWireM
  • the extended form of requestFrom is not supported, so readRegister needed to be re-written with more fundamental commands.
  • the hardware I²C SDA pin is shared with INT0, so I couldn’t directly use the MCP23017 interrupt. While I think I could switch to pin change interrupts, for now I’ve just replaced the interrupt-driven input with polling


It’s pretty simple! On the ATtiny85 PDIP/SOIC/TSSOP package, hardware I²C is enabled on pins 5 and 7:

Pin Function Other functions

I programmed the ATtiny85 with my DiY programmer shield for an Arduino Uno running the Arduino ISP sketch. Because of the use of pins 5 and 7 during programming, it means the ATtiny can’t run the sketch successfully while still on the programming board.



Testing things out on a breadboard:


Building an Adapter Board

To clean things up a bit, I made a small mounting board for the ATtiny in a DIP8 adapter, with a micro USB adapter for 5V supply. The 8-pin header allows the IxpandO to be connected with press fit.



Credits and References

Project Source on GitHub Project Gallery Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is just my personal collection of projects. Two main themes have emerged in recent years, sometimes combined:

  • electronics - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting
  • scale modelling - I caught the bug after deciding to build a Harrier during covid to demonstrate an electronic jet engine simulation. Let the fun begin..
To be honest, I haven't quite figured out if these two interests belong in the same GitHub repo or not. But for now - they are all here!

Projects are often inspired by things found wild on the net, or ideas from the many great electronics and scale modelling podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know (or send a PR!). See the individual projects for credits where due.