Go Down

Topic: Arduino DUE & I2C (Read 5204 times) previous topic - next topic

colibri2

Hello guys,

I'm newbie in Arduino world.
Ordered several models but DUE came first.
First attempt to use LiquidCrystal_I2C library to output some chars on 16x2 blue backlight LCD display

It states using I2C Address: 0x27 (can't be changed!), well "hello word" sketch doesn't work.
Tried I2C scanner but it shows random addresses each time.
Google and this forum shows DUE has broken I2C library, but posts refer to 2013/2014 year, and DUE was released in 2012/2013

So I'm wondering why it is still broken or may be another reason for that (my inability and wrong hands)  :o

codlink

It's still broken probably because no one has fixed it or written a better one.  Remember that most of the libraries are community written. 

But, just coming here and saying "it doesn't work" isn't going to help you either.  Why not specify why it doesn't work?
//LiNK

nickgammon

Do you have a level converter for the LCD? The Due operates at 3.3V.

Do you get a compile error, or is it compiling but not running as expected?
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

RayLivingston

There is absolutely nothing wrong with the Due I2C library - I've been using it for years with zero problems.

Regards,
Ray L.

colibri2

#4
Mar 07, 2016, 08:14 am Last Edit: Mar 07, 2016, 08:40 am by colibri2
Thank you for your answers.

But, just coming here and saying "it doesn't work" isn't going to help you either.  Why not specify why it doesn't work?
LCD shows nothing using default address 0x27, I2C scanner output random addresses each run, it seems doesn't work with DUE.

Do you have a level converter for the LCD? The Due operates at 3.3V.

Do you get a compile error, or is it compiling but not running as expected?
No, I haven't used level converter for the following reasons: there is information DUE has pull-up resistors for 3.3v logic, another reason - the same LCD screen works with Wemos D1 (Arduino like board with 3.3v logic).
But it is a good point, I will try to use level converter, just in case.

Compiling is good but LiquidCrystal_I2C library shows warning I'm using avr architecture instead of sam, so probably it won't work.

There is absolutely nothing wrong with the Due I2C library - I've been using it for years with zero problems.
Good to hear! So should be my problems only.
I was inspired by this post

MorganS

The I2C scanner must work. Fix that first.

Did you connect the grounds? Did you connect to the correct pins on the Due? It's different to the other Arduinos.

Do you have any way of verifying the voltages on the I2C pins? Check that it's not being drawn above 3.3V by the LCD.
"The problem is in the code you didn't post."

Slider

No, I haven't used level converter for the following reasons: there is information DUE has pull-up resistors for 3.3v logic, another reason - the same LCD screen works with Wemos D1 (Arduino like board with 3.3v logic).
But it is a good point, I will try to use level converter, just in case.
I have been using both Due's I2C also, but not specificly for a LCD display.
I'm using many MPC23017 port expanders (use, even all Dué I/o's are not even close to what I need :P)
since those can only be addressed from 0x20 to 0x27, I have connected my 20x4 display directly to Arduino's I/O.

But, for those I2C I did use level converters, since the MPC2017 is 5V logic.

Also, keep in mind that only SDA on pins 20 and 21 have internal pull-up resistors.
SDA1 will need external pull-ups, it has none onboard the Due.


Given your link to your display, it shows it needs 5v logic! So my guess is that the I2C on the back of the display also sends out 5V to your Due.
Why the Wemos D1 works, may be because it has better tolerances on the I/O pins, but I think it won't work very long at 5V input directly and it can be damaged on the long run.

So, still the best solution is using a level converter, you can build a very simple converter using 4 standard BC547B transistors, like this:
(note that you can leave out the 2 3v3 pullups if you use SDA from the Due)

colibri2

The I2C scanner must work. Fix that first.

Did you connect the grounds? Did you connect to the correct pins on the Due? It's different to the other Arduinos.
MorganS, YES! Thank you mate.
I powered DUE and LCD screen from different power sources, so grounds didn't connect.
Connecting grounds solves the issue!
I'm so stupid...

MorganS

I almost didn't write "connect the grounds" because it seemed like you were already beyond that.

Yes, it's a simple mistake, easy to make.
"The problem is in the code you didn't post."

Slider

MorganS, YES! Thank you mate.
I powered DUE and LCD screen from different power sources, so grounds didn't connect.
Connecting grounds solves the issue!
I'm so stupid...
Made that mistake myself also, sending serial data from Due to a Marklin 6051 interface, which could only be powered using Marklins own supply (Vac).
Took me days of frustration to finally realize the grounds were not connected.......:)

I guess your display functions even on 3v3 power I take it?

colibri2

#10
Mar 07, 2016, 12:29 pm Last Edit: Mar 07, 2016, 12:39 pm by colibri2
Slider, thank you too for trying to help a newbie, this community is great and open minded.

I almost didn't write "connect the grounds" because it seemed like you were already beyond that.

Yes, it's a simple mistake, easy to make.
Well yep, it's quite obvious (for me now when you pointed me out :-), thank you again!

I guess your display functions even on 3v3 power I take it?
I connected red wire from LCD to DUE 5V pin.

sandeepdalwaria

I have Arduino Due and i am trying to connect I2C 16X2 lcd but display not showing please help

Verify successful
done in 4.807 seconds
Set boot flash true
CPU reset.

Sandeep


MorganS

Does the I2C address scanner show the device is connected?
"The problem is in the code you didn't post."

rockwallaby

Setting up a LCD is not a complex task.
For example, for a little test I took a generic 1602 LCD of out my parts box, connected it to a little I2C backpack expander board bought cheaply online and set the software accordingly. That is, configure the correct I2C address and then write some data to the I2C port to  display and to see it.

So, in essence, know and understand the I2C interface board you are using so you can be sure you have the correct I2C address.

Look at the many very simple examples of writing to such little displays and if you have difficulties, try to develop methods to help yourself to find where the issues are.

You will go a long way if you can develop good diagnostic methodologies.

It is of no values you telling us that the code verify was successful and that it was done in 4.807 seconds.
What information do you think that would provide ?
___________
Paul VK7KPA
Paul - VK7KPA

F1_

There is a 2015 updated library I think, here is a link:

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/

Got this from this tutorial (http://arduino-tutorials.eu/arduino-two-i%C2%B2c-displays-tutorials) that features how to use two liquid crystal displays with one Arduino board
"I don't think a success factor of a novel is determined by the tools used by the writer, it can be notepad, ms word, or just pencil and paper, but CREATIVITY IS." ~DuckfaceNinja, Construct2 Forum user

Go Up