Go Down

Topic: MKR1000 and i2c 16x2 Display (Read 3468 times) previous topic - next topic

Nikka93

Hi i would like to use a 16x2 LCD display without using 6 Digital pin, and i was looking for the i2c 16x2 displays.

I'm using it without problem on the Arduino UNO but when i use it on MKR1000 it doesn't show anything.

This is the i2c interface:



This is the sketch for the MKR1000:

Code: [Select]

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F,16,2);  // set the LCD address to 0X3F for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Hello, world!");
}


void loop()
{
}



Those are the connection:

DISPLAY------------MKR1000
VCC-----------------5V
GND-----------------GND
SCL------------------D12
SDA-----------------D11


Nikka93

Obviously i've scanned to see the different i2c address and i've choose the right one

Nikka93


bperrybap

#3
Jun 21, 2017, 03:45 pm Last Edit: Jun 21, 2017, 03:46 pm by bperrybap
I2c backpacks are not all made the same way.
Different manufacturers wire the PCF8574 output port pins to the LCD in different ways.
This means that the library must know how the PCF8574 pins are wired up to be able to work.
Complicating matters is that there are multiple libraries that use a LiquidCrystal_I2C.h header file.
Not all of them use the same pin mappings and they all don't work the same.
If the pin mappings in the library do not match the actual pin mappings on the backpacks, you may or may not see backlight that is on or flickering or some garbage text on the display but it will not work.

I would suggest that switch to using my hd44780 library.
It can quickly and easily be installed using the IDE library manager.
It can auto detect everything for you, including the i2c address, pin mappings, and backlight control circuitry.
You can read more about it here: https://github.com/duinoWitchery/hd44780
The repo page includes information about the library and how to install it. (use the IDE library manager for installation)
The library is faster than other libraries and also includes some capabilities not available in other libraries.

The i/o class for that backpack, which uses a PCF8574 i2c i/o expander chip,  is hd44780_I2Cexp
It includes a diagnostic sketch (I2CexpDiag) that will test your i2c signals and the internal memory of the LCD module. This will verify that the library is able to communicate with the LCD.

See the hd44780_I2cexp HelloWorld sketch for which headers to include, how to declare the lcd object and how to initialize the lcd/library.

-- bill

david_prentice

The MKR1000 is a 3.3V device.

Some I2C backpacks have onboard pullups to 5V.   These will upset the substrate diodes on your 3.3V SAM chip.

If you use pullups to 3.3V,   I would expect your MKR1000 to be perfectly happy.
The PCF8574 should accept 3.3V as a "HIGH" logic level.

As Bill has suggested,  his diagnostics should detect your I2C address and PCF8574 wiring.

Try it and see for yourself.

David.

bperrybap

#5
Jun 21, 2017, 05:34 pm Last Edit: Jun 21, 2017, 10:07 pm by bperrybap
READ CAREFULLY before further testing:

I missed the MKR1000 3v in my first reading.
That will complicate things as david said since many if not most do have pullups on the backpack.
I have used 5v backpacks and LCDs with 3v Aduino type devices. I have done this with ESP8266 devices.
It requires playing some games with the supply voltages and the pullups.

If the backpack has pullups on it (which yours does) then it is possible that it has blown the pins on the 3v device if they are not 5v tolerant.
The backpack uses 4.7k pullups  which limits the input current so hopefully this isn't the case, but it is possible.

When doing mixed voltage i2c, the simplest way is to use a voltage converter.
But if you use a converter, you have to make sure to use the proper type or modify it for your use case.
Many are meant to interface 5v devices to 3v devices so they have a 3v voltage regulator on the low side.
In your case it is reversed in that the master has its own 3v power and you do not need or want this voltage regulator since it can cause a "short" with the 3v power already on your 3v Arduino.

To use the backpack at 5v without a voltage converter you have to play some games with the wiring
and voltages.
It is isn't difficult but it isn't as simple as directly using the 4 pin header.

In some cases you can get away running everything at 3v. That is the simplest case since you simply
hook the 3v supply to the vcc line on the 4 pin header instead of using 5 v.
That doesn't always work, and the backlight is often dim.
In some cases the backlight will draw more current than the 3v supply on the Arduino board can supply so be very careful if you go this route.

In most cases you have do as david mentioned and use pullups to 3v while running the backpack and LCD at 5v.
This is not difficult if the backpack does not have pullups on it as you simply
hook up the 4 pins (vcc to 5v, gnd, sda, and scl) and then add your pullups from sda and scl to 3v)
However, the photo of the backpack you have shown has pullups on it so you can't do that.
You will have to remove the i2c pullups on the backpack.
The pullups are on the left side of the backpack.

You will see a row of parts with: led, and 3 resistors labled 102, 472, 472
The pullups are the two resistors labled 472.
Those resistors are wired from the sda and scl pins to the vcc signal on the backpack.
If using 5v vcc on the backpack 4 pin header they will go to 5v and if interfacing to 3v they need to go to 3v.

Using a pullup to a voltage that is higher than the devices voltage (5v would be higher than the mkr1000 3v) can potentially damage the part if the pins are not 5v tolerant. (which it sounds like the pins on the mkr1000 are not)
In this case there is is a current limiting resistor of 4.7k
so the worst case current is about 1ma  (I=V/R or 5/4700) = 1.06ma
That seems to be within the 7ma pin current so hopefully it is ok.

I have never understood why the arduino boys make boards with 3v only processors
especially since arduino is geared at less technical folks and "tinkering" is encouraged.
Both of which can create a situation of accidentally blowing up a board.

--- bill


ikunovic

This worked for me, I have connected display to MKR on 3V Vcc , but in the beginning only backlight worked so i just resoldered pins on display connecting the backpack and it worked.

SOLUTIONS:

http://www.instructables.com/id/Using-PCF8574-backpacks-with-LCD-modules-and-Ardui/
2. ver: http://tronixstuff.com/2014/09/24/tutorial-serial-pcf8574-backpacks-hd44780-compatible-lcd-modules-arduino/

Go Up