Adafruit 7 Segment Backpack with Electric Imp

I’m creating a project that requires an omp to power a 7 segment display. I have bought this and with the help of this code I have got this far:

`function writeToDisplay(){
// Clear the display
hardware.i2c12.write(0x71,“v”);
server.log("LED i2c write during clear was: ");

local digit1 = 1;
local digit2 = 2;
local digit3 = 3;
local digit4 = 4;
local data = format("%c%c%c%c", digit1, digit2, digit3, digit4);

hardware.i2c12.write(0x71, data);
server.log(hardware.i2c12.write(0x71, data));

}

imp.configure(“7Seg”, [], []);
hardware.i2c12.configure(CLOCK_SPEED_100_KHZ);
writeToDisplay();
`

The clock pin of the display is in pin 1 o f the imp and the data is in pin 2.

Nothing is displayed on the display and the two server.logs display this:

Tue Sep 24 2013 12:06:48 GMT+0100 (BST): LED i2c write during clear was: Tue Sep 24 2013 12:06:48 GMT+0100 (BST): -2

I have tried the work arounds suggesting in the example with the exception of the capacitor to no effect. Everything remains the same.

Am I missing something? Any suggestions greatly appreciated.

Jack.

If you’re using a sparkfun april then maybe pin 1 isn’t working. Try another i2c port on the imp.

@Hugo Thanks for the response. Just tried that and no change. Any other thoughts?

So first thing is that the i2c address needs to be correct, and shifted up one place. Replace 0x70 with 0x70<<1, if none of the address lines are strapped high (ie no connection between the pairs of pads labelled A0, A1, A2.

The second thing is this display is a 5v device. It pulls the i2c lines up to 5v which (as it’s through a resistor) isn’t too awful. Are you powering it at 5v or 3.3v?

@Hugo I’m powering the imp off 5v (USB). I have successfully powered the display at 3.3v on an Arduino. I’ll try the i2c addresses now.

Thanks again.

@Hugo ok so looking at this the default i2c address is 0x70. I have tried all the other possibilities and still no sign of life!

Code now looks like this:
`local sevenSegAddr = 0x70;

function writeToDisplay(){
// Clear the display
hardware.i2c89.write(sevenSegAddr,“v”);

local digit1 = 1;
local digit2 = 2;
local digit3 = 3;
local digit4 = 4;
local data = format("%c%c%c%c", digit1, digit2, digit3, digit4); 
hardware.i2c89.write(sevenSegAddr, data);

}

imp.configure(“7Seg”, [], []);
hardware.i2c89.configure(CLOCK_SPEED_100_KHZ);
writeToDisplay();`

Did you try 0x70<<1 ? We use 8 bit addresses (bottom bit zero). The arduino uses 7 bits, hence the shift left 1.

@Hugo Yes I have. Still not working when powered by 3v or 5v.
`local sevenSegAddr = 0x70<<1;
local sevenSegPort = hardware.i2c89;

function writeToDisplay(){

sevenSegPort.write(sevenSegAddr, "v");

local digit1 = 1;
local digit2 = 2;
local digit3 = 3;
local digit4 = 4;
local data = format("%1d%1d%1d%1d", digit1, digit2, digit3, digit4); 
sevenSegPort.write(sevenSegAddr, data);
server.log(data);

}

imp.configure(“7Seg”, [], []);
sevenSegPort.configure(CLOCK_SPEED_100_KHZ);
writeToDisplay();`

@hugo My current thinking is that the 3v i2c communication from the Imp is not enough to power the display (even with a 5v supply). But the example linked in the first post disproves that.

Yes, this is possible. I don’t know what the logic thresholds are on the display, but 3.3v may not be enough to register a logic 1.

Usually a threshold is at 0.7xVDD, or 3.5v for a 5v device and 3.3v will generally work, but it’s NOT in the guaranteed range and hence performance will vary device to device.

However, looking at your code this is not what is required to talk to that display at all. You need to initialize it, etc.

I just realized that we use a similar display in our meeting minder hackathon project. You probably want to copy the sevenseg class from here:

https://github.com/electricimp/examples/blob/master/meeting_minder/meeting_minder.device.nut

…as it does the right things, like initialize the display etc.

I’m late to this discussion because I just saw this. Your Electric Imp is fine.

I also had a lot of problems driving the HOLTEK HT16K33 chip used on the Adafruit 7-segment displays using the Imp. What I found is that Adafruit has installed 10K-ohm pull-ups on the I2C bus which are too weak when using a single backpack. Try installing your own additional 10K pull-ups to +3.3V on the SCL and SDA lines which (in parallel) effectively makes them 5K pull-ups, and everything starts working properly.