Netduino home hardware projects downloads community

Jump to content


Photo

16x2 LCD I2C Netduino Plus 2 Not Working


Best Answer sjmill01, 13 August 2016 - 11:40 PM

Finally got it working. 

 

 

I didn't need the voltage level shifter after all as it seems that the LCD will allow for 3.3V logic level.

 

The problem was compatibility of the code.

 

I found this post and its code worked for me:  http://forums.netdui...2-i2c-1602-lcd/

 

This code still has some issues, but at least I could get text to the screen.  The problem is that it has something odd going on due to scrolling.

Go to the full post


  • Please log in to reply
16 replies to this topic

#1 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 02 August 2016 - 02:21 AM

I've spent about 8 hours over the last week combing the forums and the general internet for this issue and found many have trouble with LCDs, but few posts end with a resolution.

 

I have this Arduino Compatible I2C LCD: 

http://www.ebay.com/...=STRK:MEBIDX:IT

 

I am using the microliquidecrystal library:  https://microliquidc...l.codeplex.com/

 

I aligned to 2.2K resistors to pull up the SC and SD pins of the Netduino after experimenting from 10K down to 33ohms.

 

I power the LCD until just before initialize the lcd object (I do this with a break in the debugger).  I do this to prevent the issue others have seen that result in no communication and a resulting exception thrown.

 

I changed the microliquidcrystal class to use an I2C address of 0X27 instead of the 0x20 default as instructed on the EBay page. 

 

With each I2C call, the execute routines return the correct number of bytes communicated, so I imagine it's talking correctly.

 

However, on the LCD I just get a continuous row of full blocks and the backlight flickers with each call.

 

I have played with the contract potentiometer on the back of the module to ensure its not just washing out.  It's not.

 

In the code below, I tried simply turning the backlight on and off every 1.5 seconds, but it still just flickers versus staying on.  Trying to write text does nothing but flicker the backlight.

 

What could be left to try?  I'd be happy just to turn the backlight on and off under my control.

 

Is it because I'm not using Adafruit's backpack?  If so, how do I learn to send I2C commands that will work with this backpack?


// Micro Liquid Crystal Library
// http://microliquidcrystal.codeplex.com
// Appache License Version 2.0
 
using System.Diagnostics;
using System.Threading;
using FusionWare.SPOT.Hardware;
using MicroLiquidCrystal;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
 
namespace HelloWorld_I2C
{
    public class Program
    {
        public static void Main()
        {
            // Option 1: Use I2C provider.
 
            // initialize i2c bus (only one instance is allowed)
            var bus = new I2CBus();
 
            // initialize provider (multiple devices can be attached to same bus)
            var lcdProvider = new MCP23008LcdTransferProvider(bus);
           
            // create the LCD interface
            var lcd = new Lcd(lcdProvider);
 
            // set up the LCD's number of columns and rows:
            lcd.Begin(16, 2);
 
            while (true)
            {
                lcd.Backlight = !lcd.Backlight;
                Thread.Sleep(1500);
                Debug.Print("Derp.");
            }
        }
 
    }
}

Thanks,

Sean



#2 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1070 posts
  • LocationNorth Yorkshire, UK

Posted 02 August 2016 - 04:17 AM

Few things spring to mind:

  1. Does the device have a contrast potentiometer?  I have seen displays show rectangular blocks when the contrast is turned up too high.
  2. The LCD is supplied with 5V according to the ebay page.  Is the I2C logic also 5V?  The Netduinos only supply 3.3V logic.
  3. Might be worth left shifting the I2C address 1 place left as an experiment.  I can't remember if the I2C library in .NET does tis for you or if you have to do it yourself.  For those who aren't aware, bit 0 is the read/write indicator bit and the address goes into the top 7 bits.

Regards,

Mar.


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#3 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 02 August 2016 - 11:31 AM

Few things spring to mind:

  1. Does the device have a contrast potentiometer?  I have seen displays show rectangular blocks when the contrast is turned up too high.
  2. The LCD is supplied with 5V according to the ebay page.  Is the I2C logic also 5V?  The Netduinos only supply 3.3V logic.
  3. Might be worth left shifting the I2C address 1 lace left as an experiment.  I can't remember if the I2C library in .NET does tis for you or if you have to do it yourself.  For those who aren't aware, bit 0 is the read/write indicator bit and the address goes into the top 7 bits.

Regards,

Mar.

It does have the contrast pot, but it doesn't resolve it.  I'm just trying to turn on the backlight now for 1.5 second cycles.

 

The LCD claims Arduino compatible and I'm pulling up the I2C lines to 3.3V.

 

I'll dig into left shifting tonight.  Looking through the microliquidcrystal, it looks pretty complicated in that code.

 

See ya',

Sean



#4 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1070 posts
  • LocationNorth Yorkshire, UK

Posted 02 August 2016 - 06:43 PM

Arduino compatible does not mean it will necessarily work with Netduino due to the differences in the logic levels.

 

Netduino logic levels are 0 - 3.3V for output but they will tolerate 5V on input.

 

Arduino levels are normally 0 - 5V for both input and output.

 

So, does the LCD require 5V logic levels or is it designed to work with 3.3V logic?

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#5 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 04 August 2016 - 01:22 AM

Arduino compatible does not mean it will necessarily work with Netduino due to the differences in the logic levels.

 

Netduino logic levels are 0 - 3.3V for output but they will tolerate 5V on input.

 

Arduino levels are normally 0 - 5V for both input and output.

 

So, does the LCD require 5V logic levels or is it designed to work with 3.3V logic?

 

Regards,

Mark

Thought this would be a winner, but the datasheet stated the backpack is good from 2.5V to 6V.  However, the LCD itself could be 5V.  So, I sent an email to China to find out.

 

Perhaps this explains why I get a byte count back after making the I2C execution.  Its backpack is fine with 3.3V, but the LCD is not.

 

I just tried using 3.3V to power the whole thing and it just responded the same.

 

So, we'll see.  Thanks for the advice.  I'll post what I find (while I purchase a 3.3V LCD in parallel).

 

See ya',

Sean



#6 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 04 August 2016 - 02:28 AM

I just searched for 3.3V compatible boards.  I believe Raspberry Pi is 3.3V.  I keep finding Arduino/Raspberry pi boards that are 5V powered that look like mine.  This makes me think that the one I have would work.

 

So, my new question is, can someone paste a link to an LCD they got to work on the Netduino?



#7 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1070 posts
  • LocationNorth Yorkshire, UK

Posted 04 August 2016 - 05:00 AM

I've had a closer look at the schematic and although the PCF8574T is 2.6-6V compatible it is connected to the supply voltage.  It takes a high logic level of Vcc-0.5V to Vcc as logic level 1.  So supplying with 5V means that the Netduino is unlikely to be able to drive the LCD.

 

If you only need to send data to the LCD then you could consider trying to convert the 3.3V to 5V using a transistor.  Not sure if that will work.

 

One other point, the board already has 4k7 pull-ups on the SDA and SCL lines.

 

If you are looking for other boards then search the project showcase.  Someone posted a class for a board sold by Sparkfun.  This is a serial board running at 3.3V.  It is 10x the price of the one on eBay though.

 

I would have thought that any board sold as Pi compatible should be good as the Pi is also only 3.3V output.  Purchasing from someone like Adafruit or Sparkfun should give you confidence in the claims of compatibility.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#8 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 04 August 2016 - 11:32 AM

If you only need to send data to the LCD then you could consider trying to convert the 3.3V to 5V using a transistor.  Not sure if that will work.

 

Neat concept.  Would the tranistor be on the I2C lines?  If so, would I need to use a diode to allow for two way traffic so it could get around the transistor on the way back?

 

Thanks,

Sean



#9 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1070 posts
  • LocationNorth Yorkshire, UK

Posted 04 August 2016 - 03:11 PM

Not sure if a transistor would but if you look at some of the schematics for Adafruit devices (say BME280) I'm sure they use FETs on the data lines for logic level shifting.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#10 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 04 August 2016 - 11:15 PM

Not sure if a transistor would but if you look at some of the schematics for Adafruit devices (say BME280) I'm sure they use FETs on the data lines for logic level shifting.

 

Regards,

Mark

 

I validated that the LCD does work on an Arduino.  So, I'm pretty sure its the voltage mismatch.

 

Found this great tutorial on how to achieve the logic level conversion using a MOSFET based level shifter.

 

https://learn.sparkf...evel-converter?

 

Feels like a Bethesda game with all these side quests.  :)

 

I'm determined to get this working no matter what the costs.  I don't want to waste my $2 dollars on its purchase.



#11 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1070 posts
  • LocationNorth Yorkshire, UK

Posted 05 August 2016 - 04:35 AM

I validated that the LCD does work on an Arduino.  So, I'm pretty sure its the voltage mismatch.

 

<snip>

 

I'm determined to get this working no matter what the costs.  I don't want to waste my $2 dollars on its purchase.

That's the spirit, not defeated, just learning more...

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#12 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 11 August 2016 - 01:26 AM

Well, I bought this  https://www.sparkfun.../products/12009

 

to convert my 3.3V logic to 5V logic.

 

Unfortunately, still didn't work.

 

I even bought a separate device that claimed to be Raspberry Pi compatible...but it was not.  It was similar to the first one I bought, but also works with Arduino.

 

I'm thinking it has to do with the code in microliquidcrystal.

 

How are people changing the code to change the I2C device address?  I changed it in the MCP23008Expander code.



#13 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1070 posts
  • LocationNorth Yorkshire, UK

Posted 11 August 2016 - 05:02 AM

Have you tried moving the address 1 place to the left ?

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#14 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 12 August 2016 - 04:48 PM

Have you tried moving the address 1 place to the left ?

Regards,
Mark

 

Tried shifting the address and it did not work.  (Used 0x4E instead of 0x27)

 

I found that if I don't put power to it until just before the creation of the LCD object, it does talk. 

 

The code that writes the bytes to the I2C bus returns the number of bytes written.  When I change the address, it returns 0 bytes written.  So, I'm sure its talking and has the right address (0x27).

 

I now have a voltage level shifter and each side of the level shifter are showing the correct voltage.

 

Perhaps the bytes being sent are not right in my microliquidcrystal class?  Oddly, I can't manipulate the backlight with lcd.Backlight, but when I try to write "Hello world", I see only the blocks, but the backlight turns on. 

 

Are 4 bit and 8 bit modes.  Could that be the problem?

 

Thanks,

Sean



#15 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 13 August 2016 - 11:40 PM   Best Answer

Finally got it working. 

 

 

I didn't need the voltage level shifter after all as it seems that the LCD will allow for 3.3V logic level.

 

The problem was compatibility of the code.

 

I found this post and its code worked for me:  http://forums.netdui...2-i2c-1602-lcd/

 

This code still has some issues, but at least I could get text to the screen.  The problem is that it has something odd going on due to scrolling.



#16 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1070 posts
  • LocationNorth Yorkshire, UK

Posted 14 August 2016 - 05:35 AM

Interesting, that code looks to be using 0x3f as the address.

 

Have you tried the code you found with MICROSOFTWAY defined to use the NETMF libraries or are you just using the software I2C?

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#17 sjmill01

sjmill01

    Advanced Member

  • Members
  • PipPipPip
  • 45 posts
  • LocationSouth Carolina

Posted 14 August 2016 - 12:28 PM

Interesting, that code looks to be using 0x3f as the address.
 
Have you tried the code you found with MICROSOFTWAY defined to use the NETMF libraries or are you just using the software I2C?
 
Regards,
Mark



I changed 3f to 27 to match my i2c address. Also I took out the register option so it wouldn't scroll. I'm only using the software i2c that he posted.

See ya,
Sean




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.