Author Topic: Digispark with BareConductive library MPR121.  (Read 188 times)


  • Newbie
  • *
  • Posts: 1
Digispark with BareConductive library MPR121.
« on: January 11, 2017, 07:41:57 am »
I've just got the blink sketch running on my Digispark Attiny85 board and was excited to discover that this little setup could do i2c. I've been working on a capacitive touch project using the MPR121 chip and an Arduino Pro Mini (Atmega328P), I use the BareConductive MPR121 library :

This is all good and working and I would now like to port this over to the Attiny85. I have connected everything up as I did with the Pro Mini board using pins 0 & 2 for SDA & SCL and pin 4 for interrupt.

The problem is that the library uses Wire and Serial includes and I'm not sure which parts of these .h and .cpp files to alter. I guess the Wire include is needed to i2c communication, and the Serial include is for talking to Processing.

I know things are quite different with this chip, but please could anyone give me pointers to get things working with the Digispark board? I've read about SoftSerial and TinyWireM but don't know how to implement these.


  • Hero Member
  • *****
  • Posts: 753
Re: Digispark with BareConductive library MPR121.
« Reply #1 on: January 11, 2017, 11:37:17 pm »
AFAIK (and exeng/et al will either back me up or call me out on it ;) ), you won't need to worry about the TinyWireM I2C, as a renamed copy was included as Wire, so it *should* be as near as a drop in substitute for that used on the Nanos/Unos etc.

Since the MPR121 uses I2C, any code referencing Serial is either using it for debugging / output / linking to Processing. So the question here is are you using some example code that uses Processing (which you can do away with), or are you developing something that needs to be able to talk to processing via Serial?

For the soft-serial stuff, have a look at the example provided with the Digispark Arduino IDE package - File -> Examples -> DigisparkSoftSerial -> SoftSerialExaample

But basically you'd include the libraries
Code: [Select]
#include <SoftSerial.h>   
#include <TinyPinChange.h> 

Create a soft serial object declaring which pins you'll be using (maybe 1 & 3 in your case?)
Code: [Select]
SoftSerial mySerial(1, 3); // RX, TX
In the setup function, initialize the soft serial, specifying baud rate (just like normal serial)
Code: [Select]
And then use it normally in the main loop... i.e
Code: [Select]
if (mySerial.available())
newInput =;