Arduboy FX + I2C serial device?

Here’s a quick question, I haven’t done much with my Arduboy recently (sorry :sob:), but I was wondering, If I were to connect a device to my Arduboys SDA/SCL pins, would I risk damaging my mod chip?

Went ahead ant tried it anyway. It seems the wire lib doesn’t like something about arduboy, any attempt to use it to communicate with my i2c device just freezes everything up.

The use of i2c with the mod chip attached will basically activate the external flash memory chip every time data is being sent over it… which will basically like, totally mess with the entire SPI channel, so the screen comes out of sync and you may risk corrupting the data on the flash chip (but not as likely but theoretically possible if the screen data just happened to be the same as some commands for the chip).

It will work fine without the mod chip though.

I feel sad for walking myself into a corner defining the SDA pin for the CS signal for the flash chip, it was done so that you can solder it on without having to remove the battery.

Womp womp womp

but this…

bool checkI2C() {
  arduboy.println("Check i2c"); arduboy.display();
  arduboy.println("Wire.begin();"); arduboy.display();
  byte error, address;
  int nDevices;
  arduboy.println("I2C bus Scanning..."); arduboy.display();
  nDevices = 0;
  char tempText[20];
  for(address = 8; address < 127; address++ ) {
    arduboy.setCursor(0, 24);
    arduboy.println(tempText); arduboy.display();
    error = Wire.endTransmission();
    if (error == 0) {
      arduboy.print("\nI2C device found at address 0x"); arduboy.display();
      if (address<16) {
        arduboy.print("0"); arduboy.display();
      arduboy.println(address,HEX); arduboy.display();
    else if (error==4) {
      arduboy.print("\nUnknow error at address 0x"); arduboy.display();
      if (address<16) {
        arduboy.print("0"); arduboy.display();
      arduboy.println(address,HEX); arduboy.display();
  if (nDevices == 0) {
    arduboy.println("No I2C devices found\n"); arduboy.display();
    return false;
  else {
    arduboy.println("done\n"); arduboy.display();
    return true;

shouldn’t cause the whole arduboy to freeze though should it?

Does it work on an original non-FX Arduboy, where the SDA line isn’t being used for any other purpose?

I don’'t have a non-FX Arduboy :frowning:

If you can provide a complete sketch that exhibits the symptoms, I can try it for you.

Github seems to be failing me, here’s a pastebin… Arduboy I2C -

A single file, just checks for I2C devices. Doesn’t get past

    error = Wire.endTransmission();
    arduboy.println("end.Transmission"); arduboy.display();

for me.

Sorry for the delay in responding. I got interrupted by a bunch of stuff.

With a real non-FX Arduboy, with nothing connected to the I2C lines, after the logo sequence the display clears then shows:

Check i2c
I2C bus Sanning...

The Arduboy doesn’t respond to any button presses (before or) after that.

So, as suspected, something between the arduboy library and wire library might be getting in each others way, it works fine on a pro micro without any arduboy stuff.

Thanks for checking :slight_smile:

F.Y.I. I tried your sketch modified to use the Arduboy2 library and got the same results.

Try skipping the Arduboy library and upload to it as a leonardo?

No. but when using I2C there may be no SPI transfer in progress otherwise ‘random’ data is written to the flash chip.

It will probably fine as the Cathy3K bootloader puts the flash chip in power down mode before running a sketch so the chip would only respond to the wakeup command.

But I can’t guarantee that there won’t be unexpected behaviour.

And it also freed Rx for hardware serial.

The lockup is probably due to this ( in bootPowerSaving ):


@mr.blinky is the smartest floating ghost shaped person here.


To enable I2C In your example add the following line in setup after .begin():

PRR0 &= ~_BV(PRTWI);

Hmm. I think I need to add an I2C header to my mod chip prototype now. I’ve got this DS3221 module I once bought for it’s CR2032 socket…


Excellent, thanks @Mr.Blinky now to figure out why the device doesn’t work properly :stuck_out_tongue: (works perfectly well on my pokitto), must be a library thing.

1 Like

I had a look at the wire library and it mainly uses the ISR (interrupt service routine) to handle transfers. This could be a problem in some cases like a (multiple) write only to I2C device followed shortly with a flash access or Arduboy being an I2C slave.

I’ve hooked up my Ds3231 and play with some non ISR I2C code a bit later.