Using an I2C / SPI LCD on the Spark Core

I got my I2C/SPI backpack today and might get a chance to work on this tonight, we’ll see… I’ll at least get the thing soldered up to an LCD tonight so I can do testing tomorrow. :wink: Thanks for the offer @Soulhuntre

1 Like

@timb - you guys are awesome :smile:

Ken

1 Like

No I didn’t. Unfortunately my c++ fu is very limited. I mostly just referenced what BDubs did and adapted it to the other library.

So I played around with it some. I think the problem is in the example code, maybe using the millis() command causes some timing issues so the lcd starts getting confused. It may also be that the write commands to the lcd are coming too fast.

I made a few different sketches. One where pressing buttons would make the display change and that one was ok. It would only mess up when I mashed all the buttons and all it did was repeat the text. So “UP UP” instead of just “UP”

I made another one that just counted up to 255 and started over once every 100 ms and that seemed stable although it did freeze on me once after about a minute.

So I’d say that it still works but just limit the rate at which you write to the lcd. Put some delays in your sketches if you can.

I hear you - I played with the timing some - but with any reasonable timing that actually gets the LCD driven fast enough to matter there is still some important instabilities here.

I have had to move development onto an Arduino Yun at the moment (I need to get my prototype into the view of a partner this week) but when I get a chance to look at this again I will see if I can suss out a solution.

Ken

I forgot to use the pull-ups which has helped. But, if you’re designing something with a quick refresh rate I could see how it wouldn’t work. For my project it will just be a menu interface so I can live with 50ms or 100ms updates.

This works for me.
I spent lots of time to find out how to print on
my I2C 2004 LCD.

Thanks

Now I can replace this I2C LCD with SPI LCD in my weather recorder to save more pins so that I can try more ideas on my core. :slight_smile:

Did you ever get a chance to play with this thing?

Not yet, since I got the SPI part working nicely at a faster speed than the I2C, I kind of put it on hold for a bit while I’m working on other things. I know you have the I2C RGB LCD though which makes for a good case to use I2C. I was also kind of hoping @timb 's reworked I2C library would be out before I spent too much time tripping over implementation bugs.

@weakset Thanks! This is working perfectly for me. I also have a cheap ebay backpack.

1 Like

Hey @BDub I’ve been reading through this thread to try and figure out why my LCD is giving me no love whatsoever and I’m still very confused about the purpose of the LiquidCrystal_I2C library (I’m a total noob to working with Micro-controllers and peripherals by the way). I have a Microtivity IM161 LCD Module 1602, White on Blue with Backlight display with what I’ve come to undersand is an I2C or SPI backpack like the one here pre-soldered onto it. I’ve connected it to the Spark as Such: D0 to SDA, D1 to SCL, VCC to Vin (no pull up resistor), GND to GND. Since I’ve got the backpack soldered on and the Spark API already provides the Serial and Wire Libraries for communicating with SPI and I2C devices, is the LiquidCrystal_I2C library still necessary? If so, what modifications need to be made to get it to work with my LCD?

I have identically looking LCD+I2c and it requires pull-ups for SDA/SCL lines
Sample code for these LCD is here https://community.spark.io/t/i2c-pull-up-question-with-bonus-lcd-confusion/2116/69?u=ryotsuke

2 Likes

Aww yeah! You rock @ryotsuke. My LCD is giving me some love now so here’s some love for you all too.

I got it to work without the pull-ups although the LCD is a bit too bright. Here’s my current connection. Stop me now if that’s in anyway dangerous

Also, do you have a breadboard picture of how the pull-ups are connected to the SDA and SCL, I couldn’t find any good ones online. Lastly, I split the LiquidCrystal_I2C library into .h and .cpp since Sparkulator now supports that. I can post that online if anyone wants it too. Thanks guys!

4 Likes

You can adjsut brightness rotating this http://screenshots.ryotsuke.ru/scr_f137e9fe0a50.png
Pull-ups for i2c usually are 4.7KOm resistors between SDA and 5V and SCL and 5V
Found a pic for arduino http://forums.netduino.com/uploads/monthly_11_2011/post-12385-0-45058100-1322697185.png

2 Likes

I changed the topic so people can find this post easier.

Hey @ryotsuke. So the variable resistor (i think that’s what that is) on the back seems to only control the brightness of the characters on the screen, not the backlight itself. I’ll connect the 4.7kOhm resistors to the VIN as you suggested and see if that makes a difference. Thanks once again for your help!

I am happy to go SPI if needed, I can give up a few extra pins. I’ll put some time into looking for updated SPI code for it :smile:

Ken

Don’t spend too much time looking: https://github.com/technobly/SparkCore-LiquidCrystalSPI This works with the adafruit backpack. I still have debugging the I2C part of the MCP23008 library on the list of things to do. Like I said before though, I was kind of waiting for @timb to release his changes to the I2C code. Tim, will you share your changes with me prior to release so I can do some debugging sooner?

This worked on my 4 line display as well!

Can I ask what the latest status is with this I2C address issue and its workaround (shifting up one bit)? I’m having trouble porting the ST7036 LCD library from Arduino to Spark for my NHD_C0220BiZ display from NewHaven.