Using an I2C / SPI LCD on the Spark Core

@BDub - no worries mate, I’ll keep looking into it as I get more familiar with the platform.

Ken

Guys,
I may have had a similar problem with implementing the BMP085 pressure / temp sensor. It uses I2C and when I used the basic library floating round the net I would get a few samples out of the device and my code would lock up on the I2C read. I studied the code and found that each time in my loop of getting & displaying the pressure, temp, altitude, it sampled the BMP 7 times quickly as fast as possible. I have since changed the code to only sample the BMP once every 1.5s. Now the code runs overnight, before it only ran for 6-15mins. I suspect the I2C library can’t handle heavy usage at this time. Forgive me @BDub :wink:

Yes, introducing at least a 15ms delay between a Wire.endTransmission and begin event will greatly improve the stability of I2C.

Keep in mind, on the Core’s I2C implementation transmission doesn’t take place until you call end, so if it goes into the next begin statement too quickly the buffer is getting overwritten.

Try adding a delay and see if that helps.

Thanks, I will add a delay after the Wire.endTransmission to allow for the data to get written out and report back.

I did ad a little bit of delay, and it helped… but eventually it locked up anyway.

:frowning:

Ken

So I checked this today - given that we have new firmware. It is somewhat more stable, but eventually it does still lock up and die.

https://gist.github.com/soulhuntre/8674179

Ken

Cannot get it work with this backplane…

and have no idea how to fix it… Does not depend on pull-up resistors…

:frowning:

SPI addres is 0x27…

Arduino-Code from http://arduino-info.wikispaces.com/LCD-Blue-I2C#v1 runs perfect on my nano.

Can anybody help?

@Frido how are you including the LCD library into your project?

This time I used spark.io/build

compiles and flashes ota but shows no output on the display.

@Frido can you post your code and wiring scheme. I’m guessing you meant I2C, not SPI right? Have you added pull-up resistors on both SDA and SCL? Not sure what you meant by does not depend on pull-up resistors, but without them the Spark Core won’t send a high output. Arduino doesn’t need them, for low capacitance buses, because they turn on the weak pullups.

Code is copied from @Soulhuntre’s recent post, changed to

#define MCP23008_ADDRESS 0x27

wiring scheme is simple

brown = GND
red = VCC
orange = SDA / D0
yellow= SCL / D1

pullup resistors on 3V3

LCD flickers for a moment now…

Pullups should go to VIN if that’s what’s powering your LCD. Are those 1k? Probably fine if so. If they are 10k, might wanna also try lowering them to at least 4.7k in addition to the supply voltage change. Keep in mind the LiquidCrystal_I2C code is a work in progress port of Adafruit’s I2C LCD backpack. I need to order one of everything we’re working on so I can help out more effectively.

EDIT: Just ordered an LCD I2C/SPI backpack and a 4-channel I2C safe level shifter from adafruit (just in case). @Soulhuntre what kind of driver chip does your LCD have? Or if you can point me to the datasheet that would be best. Just want to make sure I grab a comparable LCD out of my drawer full of them.

So I have a different i2c backpack from Adafruit that appears to use a slightly different chip. I tried loading the sketch Bdubs posted and it doesn’t seem to work. The backlight turns on but the first line is all block characters.

It’s this one: http://www.adafruit.com/products/714

It has a MCP23017 instead of the MCP23008. So how difficult would it be to adapt the library for the MCP23017. It seems to be similar. Adafruit also has an RGBLCDshield library as well that’s need for the backpack I have. I’m guessing it mostly handles the button controls though.

Not too difficult I’d say, but time consuming nontheless. Let me get the MCP23008 working reliably first and then we can turn to the MCP23017 after that’s done. Meanwhile you can try to duplicate my efforts with the MCP23008 just by looking at the original library and the files I’ve created. Or, if you want to send me a http://www.adafruit.com/products/714 I’d definitely be more than happy to do the testing to get it working reliably.

I was thinking of just going through it later and seeing if I can duplicate what you did with the MCP23008

Yours look similar to my cheap eBay LCD, so this code could work:

I think this is the version that is originally from @Iv4n. I stripped of some his custom stuff to make it more clean on my taste. I just build it this from online IDE to make sure addresses are like they should be.

The only resistor is one I soldered in place of that led jumper to make backlight a bit dimmer. Electronics aren’t my expertise, so I’m not sure if should add more of them in long run.

2 Likes

I managed to duplicate what BDub did to this Library. Here’s their Hello World sketch example with all the code. I didn’t understand fully what I was doing so it may not work well, I just copied the modifications to make it compatible.

Github gist link

PS how do you do those fancy code boxes.

Edit: it does work but then the screen freaks out after about 30 seconds or so.

\o/ “This is how we do it!!!” \o/

It works!!! Thanks a lot!!!

Nice idea to solder a resistor instead of the jumper!

So this is a solution for LCD with backboard “LCM1602 IIC V1”. Could be copied to “Libraries”…

Happy now,

Frido.

Update: Pullup resistors to 3V3 work as well. I like this because the wiring looks cleaner :wink:

Update: On my open WiFi uptime was two times over 17.000 seconds…

1 Like

@gin that sounds like the same problem we were having with my port of the MCP23008. Gotta be something simple in there that I missed… I’m hoping.

Yeah maybe. Bascially a bunch of Cs and Ss started appearing scrolling across and it kind of went from there.

I did notice that on the RGBLCD shield library there were some 16bit exchanges where the MCP23008 seemed to only have 8bit ones.