Strange i2c behavior with a Sparkfun COM-11442 7-Segment LED Display

I’ve attached a Sparkfun COM-11442 to pins 8 and 9 of an April board and have it working, but with some really strange workarounds.

I started by adapting the Sparkfun sample i2c code, which didn’t work directly, but after hooking up an oscilloscope and experiencing a random accident that caused the LED to light up (accidentally shorting data to clock), I found a strange workaround.

The below code didn’t seem to do anything at all, although the result from the clear is 0, and if I manually short the pins, suddenly 1234 gets displayed.
`
hardware.configure(I2C_89);

// Clear the display
local result = hardware.i2c89.write(I2C_ADDR,“v”);
server.log("LED i2c write during clear was: "+result);

local digit1 = 1;
local digit2 = 2;
local digit3 = 3;
local digit4 = 4;
local data = format("%c%c%c%c", digit1, digit2, digit3, digit4);
local result = hardware.i2c89.write(I2C_ADDR, data);
server.log("LED i2c write result was: "+result);
`

That got me thinking, and I added to end:

// Really weird work around, number doesn't display unless I do this hardware.configure(I2C_89); hardware.configure(I2C_89);

One configure() didn’t do the trick, but twice caused the digits to appear. If I do the 4 character write() to update the display, I again have to do the extra hardware.configure()'s twice to get them to appear.

I feel like I am doing something wrong, since sending “v” to clear the display works just fine, but it seems like there is something done in the Arduino’s Wire.endTransmission(); that doesn’t get done at the end of an imp’s write().

Any ideas what I might be doing wrong and whether there is a better way other than doing the double configure()?

The correct way to configure the I2C peripheral is:

hardware.i2c89.configure(CLOCK_SPEED_100_KHZ); // using pin 8/9 at 100 kHz

See: http://devwiki.electricimp.com/doku.php?id=electricimpapi:i2c:configure

Ok, I figured out the problem. The device seemed to be equally happy/unhappy at all i2c speeds, so configuring at all the various settings didn’t make a difference.

What did make the difference in the end is adding a really huge isolating capacitor. Although the display seems to operate fine, I noticed with the scope that when energized, it was putting out a ton of noise onto the power rails. I suspect that it tolerates but isn’t super happy about being driven at 3.3V and would be happier at 5V.

I tried various sizes and combinations of capacitors, and eventually found that a single 6800mfd cap across Vcc and GND cleaned up the signal, and once I did that, the I2C code worked exactly as it was supposed to, without the extraneous reconfigurations, at all speeds and whatever the default (unspecified) speed is.