Fork me on GitHub

Project Notes

#528 ATtiny IxpandO

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

Build

Notes

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

Construction

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
5 SDA USCK/SCL/ADC1/T0/INT0/PCINT2
7 SCK MOSI/DI/AIN0/OC0A/OC1A/AREF/PCINT0

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.

Breadboard

Schematic

Testing things out on a breadboard:

ATtinyController_bb_build

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.

adapter_board

Build

Credits and References

About LEAP#528 BoldportPort ExpanderAVR

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

Project Source on GitHub Return to the LEAP Catalog
About LEAP

LEAP is my personal collection of electronics projects - 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.

Projects are often inspired by things found wild on the net, or ideas from the many great electronics podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know or send a pull-request.

NOTE: For a while I included various scale modelling projects here too, but I've now split them off into a new repository: check out LittleModelArt if you are looking for these projects.

Project Gallery view the projects as an image gallery Notebook reference materials and other notes Follow the Blog follow projects and notes as they are published in your favourite feed reader