Author Topic: Adafruit I2C LCD Backpack - just black boxes top row, no coms  (Read 14311 times)

holtt

  • Newbie
  • *
  • Posts: 6
I soldered up an Adafruit LCD I2C backpack (http://www.adafruit.com/products/292) that's hooked onto a 16x2 LCD (HD44780) from Microtivity.  Hooking it up to my Digispark like this...


5v    ->  5v
Gnd ->  Gnd
DAT  -> P0 (with 3.3k pullup & 5v)
CLK  -> P2 (with 3.3k pullup & 5v)


I'm running the stock LCD "BasicUsage" script for the Digispark, and I get just a row of boxes across the top row - no message.


From what I've read, that means I'm getting power to the LCD, but just no signal telling it to do something.

I am suspicious that I need to change the GPIO_ADDR value to something else, but I'm not clear exactly what.  The backpack board has 3 jumpers A0-A2, none of which are set.  The comment line in the code example isn't very self explanatory for me...

// (PCA8574A A0-A2 @5V) typ. A0-A3 Gnd 0x20 / 0x38 for A - 0x27 is the address of the Digispark LCD modules.

On a hunch (given the Digispark board has A0-2 jumped, meaning 111 binary meaning 7 (hence 0x27), I wondered if mine being not jumpered (meaning 0) means I should use 0x20 as my address.  Tried that, same result.

Any suggestions?
« Last Edit: March 01, 2013, 01:27:15 am by holtt »

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #1 on: March 01, 2013, 05:46:44 am »
The adafruit backpack uses a MCP23008 I2C expander (there are other used on these I2C add-ons).

The datasheet shows pins 3,4,5 are the address and need external bias (ie pullup  or pulldown)
From what I work out, if they are low then its address x020, if they are pulled high, then its x027 (as per the Basic Useage Example address)

I presume you have tried the contrast pot on the rear to see if it makes any difference.?
Normally you adjust until the top line is just there, which should start you off.

You'll also need to heed this warning under assembly
http://digistump.com/wiki/digispark/tutorials/lcd

If you need to cut the LED, I posted a picture of a cut trace here
http://digistump.com/board/index.php/topic,522.msg2234.html#msg2234

bjh had issues that was related to connection.
http://digistump.com/board/index.php/topic,365.msg1980.html#msg1980

If you're using stackable headers, you might want to twist them ...
http://digistump.com/board/index.php/topic,346.msg2064.html#msg2064

Try these, and post back if you've had any success.

mark




digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #2 on: March 01, 2013, 09:48:47 am »

The included I2C LCD examples are very specific to the LCDs we ship - in fact they are specific to those because we couldn't find any other library that worked with them!


Getting the adafruit one to work should just be a matter of taking whatever library Adafruit recommends for it


https://github.com/adafruit/LiquidCrystal


and replace Wire.send and Wire.write with TinyWireM.send and TinyWireM.write


then use their example and include TinyWireM.h as well


You'll have to figure out the address from their tutorial as well.

holtt

  • Newbie
  • *
  • Posts: 6
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #3 on: March 01, 2013, 01:32:16 pm »
@Mark

It's a rev A so LED cut not an issue.

RE: bjh's issue.  From what I see, I believe I have zero I2C communications happening as I just get the top row of blocks displayed and no backlight of any kind - meaning the code is never talking to the board.

No stackable headers used either.  Just jumpers plugged into headers on the digispark.

@digistump

Good tip RE: trying the Adafruit stack & changing the Wire calls.

Also, and I don't know why I did think of this earlier..., but I should hook it up to my Uno and get it to work there (with Wire instead of TinyWireM).  Then when it's working there I know it's not a wiring or address issue.  And then port it over to the Digispark.

« Last Edit: March 01, 2013, 01:34:44 pm by holtt »

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #4 on: March 01, 2013, 01:53:56 pm »
The PCM23008 I2C chip uses different pins.

The supplied library worked with displays I used from Yourduino.com
These have a PCF8574 I2C Chip.

Its possible that someone could change the library to match the new pins, however you may want to look at High speed library done by FalconFour, the speed increase is impressive.

Since you have an arduino, I'd prove it using the Adafruit library, then try it in the DS.

Mark
« Last Edit: March 01, 2013, 01:55:50 pm by Mark »

holtt

  • Newbie
  • *
  • Posts: 6
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #5 on: March 01, 2013, 06:48:05 pm »
The PCM23008 I2C chip uses different pins.
Right - I'm connecting explicltly labeled connections by name, not by pin.  That is ,"DAT" on the Adafruit backpack board goes to what is "SDA" in (ATTiny pin5 / P0 on Digispark), etc.  I'm not using any kind of direct ribbon cable that forces certain pin to pin mappings - just individual jumpers.


Quote
Since you have an arduino, I'd prove it using the Adafruit library, then try it in the DS.


Definitely the way to show that it is (or is not) an address, wiring or other inherent issue separate from the Arduino board!


All help much appreciated.  It's the weekend and time to mess about and figure this out :)

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #6 on: March 01, 2013, 08:48:30 pm »

@holtt
Quote
That is ,"DAT" on the Adafruit backpack board goes to what is "SDA"

Yep those pins are the same, its the IC 'legs' that connect to the LCD pins that are different.
The library handles the change, so you don't have to.

Continue trying with the Arduino.

We might be able to convince someone to look at the really fast library that has been done for the PCM and change it to suit the PCF chips.
Hint hint ...


mark

holtt

  • Newbie
  • *
  • Posts: 6
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #7 on: March 02, 2013, 12:14:57 am »
Same setup works fine on an Uno with a stock library, so it's not wiring or bad components.  This is with the "HelloWorld_i2c" example, using...
Code: [Select]
* 5V to Arduino 5V pin
* GND to Arduino GND pin
* CLK to Analog #5
* DAT to Analog #4


Channel for i2c is zero per this code...
Code: [Select]
// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidCrystal lcd(0);


It seems to really come down to either the address is not right, or I'm not plugged into the right ports. 


Going over it again (for my self as much as others), I've got the following 3 wires going to the Digispark...
Code: [Select]
* 5V (5V on backpack) plugged into 5V on Digispark
* Ground on backpack plugged into Ground on Digispark
* Data (DAT on backpack) plugged into P0 (labeled SDA on Digispark)
* Clock (CLK on backpack) plugged into P2 (labeled SCK on Digispark)



Also I'm plugging the whole thing into a USB port to power it.


I know the contrast is OK because it's visible w/o adjustment using Uno stack.


Also, I've tried channel values of 0x0 and 0x20.


digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #8 on: March 02, 2013, 12:45:47 am »
I'm thinking it is because you need to add the I2C pullups the board you are using must not have them - try a 2-10k resistor between 5v and SDA and another between 5v and SCL and your other connections as you have them.

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #9 on: March 02, 2013, 01:35:39 am »
Holt

When you say 'stock library' ... what is the library name.
(You didn't include the '# include xyz' at the top)

The Digispark comes with LiquidCrystal_I2C, but the standard flavour Arduino comes with just LiquidCrystal.
Have you downloaded the Adafruit library?

Is it possible that the Adafruit version is not under the Digispark libraries.?
I have my three Arduino versions in separate directories....

I think you mentioned you had 3k3 pullups to 5v at the start.

Mark


holtt

  • Newbie
  • *
  • Posts: 6
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #10 on: March 02, 2013, 01:59:11 am »
Success!

I shifted over to using the LiquidTWI2 library from https://github.com/lincomatic/LiquidTWI2, changing all the various Wire.* calls to TinyWriteM, and it works like a charm. 

I did a bit of hackery with some defines so it's a wee bit off, but let me clean it up and use proper defines, etc. so it will work with the Digispark, then I'll share the code.

Here's the test sketch code that runs on the Digispark now with the Wire.* -> TinyWireM.* modified code...
Code: [Select]
// include the library code:
#include <TinyWireM.h>
#include <LiquidTWI2.h>


// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidTWI2 lcd(0);


void setup() {
  // set the LCD type
  lcd.setMCPType(LTI_TYPE_MCP23008);
//  lcd.setMCPType(LTI_TYPE_MCP23017);
  // set up the LCD's number of rows and columns:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}


void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);


  lcd.setBacklight(HIGH);
  delay(500);
  lcd.setBacklight(LOW);
  delay(500);
}


RE: library for running on the Uno - I was using the Adafruit one.

Thanks all for the help - it was useful to verify a few things by talking it out, and the lead on LiquidTWI was quite handy.

spikec

  • Newbie
  • *
  • Posts: 1
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #11 on: October 07, 2013, 06:33:03 pm »
Just thought I'd throw this out to others that are trying to use an Adafruit i2c/SPI backpack with the Digispark. Adafruit recently came out with a new library that works like a champ with this board:


https://github.com/adafruit/TinyLiquidCrystal

Axel87

  • Newbie
  • *
  • Posts: 2
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #12 on: October 27, 2013, 12:03:44 pm »

Think I am trying to use the same LCD as you, but with a PICAXE.
Do you have any ideas as how to get me started with this?
I only get black boxes with a backlight

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Adafruit I2C LCD Backpack - just black boxes top row, no coms
« Reply #13 on: October 27, 2013, 01:29:49 pm »
Axel87 - in your other thread you said you are using a Digispark LCD - this thread is about an adafruit LCD which is substantially different - please clarify which you are using.