I2C LCD Troubles | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 4 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
I2C LCD Troubles
August 15, 2015
11:33 pm
Avatar
RTSLVU
Member
Forum Posts: 18
Member Since:
March 20, 2015
sp_UserOfflineSmall Offline

I have built my own I2C interface for an LCD using the PCF8574 chip that is used on the Sainsmart LCD.

My PCF8547 is on address 0X20 as can be seen in the Arduino I2C scanner sketch output below

Image Enlarger

So I changed the example code to fit my circuit as seen below.

Image Enlarger

But when I run the example all I get is two rows of blocks.

Image Enlarger

I have checked and checked my circuit, tried different LCD's and another PCF8574 chip but nothign helps.

August 15, 2015
11:57 pm
Avatar
filipealtoe
Admin
Forum Posts: 89
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Hello;

Have you tried running an Arduino IDE example setting the I2C address to the one you show above to see if it works on the Arduino IDE? 

Filipe

Cheers Filipe
August 16, 2015
12:58 am
Avatar
RTSLVU
Member
Forum Posts: 18
Member Since:
March 20, 2015
sp_UserOfflineSmall Offline

Yes running this test sketch:


/*
** Example Arduino sketch for SainSmart I2C LCD Screen 16x2
** based on https://bitbucket.org/celem/sainsmart-i2c-lcd/src/3adf8e0d2443/sainlcdtest.ino
** by
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)

** This example uses F Malpartida's NewLiquidCrystal library. Obtain from:
** https://bitbucket.org/fmalpartida/new-liquidcrystal 

** Modified - Ian Brennan ianbren at hotmail.com 23-10-2012 to support Tutorial posted to Arduino.cc

** Written for and tested with Arduino 1.0
**
** NOTE: Tested on Arduino Uno whose I2C pins are A4==SDA, A5==SCL

*/
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x3F // <<----- Add your address here.  Find it from I2C Scanner
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

int n = 1;

LiquidCrystal_I2C	lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
  lcd.begin (16,2); //  <<----- My LCD was 16x2

  
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home

  lcd.print("SainSmartI2C16x2");  
}

void loop()
{
  // Backlight on/off every 3 seconds
  lcd.setCursor (0,1);        // go to start of 2nd line
  lcd.print(n++,DEC);
  lcd.setBacklight(LOW);      // Backlight off
  delay(3000);
  lcd.setBacklight(HIGH);     // Backlight on
  delay(3000);
}


It runs fine 

Image Enlarger
August 16, 2015
3:13 am
Avatar
RTSLVU
Member
Forum Posts: 18
Member Since:
March 20, 2015
sp_UserOfflineSmall Offline

Interesting to note if I run the Arduino Compiler example after running the test sketch. The LCD is not cleared and remains showing the last count the Sketch was at. Even after pressing the reset.

August 16, 2015
3:38 am
Avatar
Steffan
Admin
Forum Posts: 305
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

I think your problem is your I2C address.  Looks like you are using decimal 20, not hex 20.  You should be using decimal 32 instead.

This post was something similar:

http://www.geverywhere.com/for.....t-working/

Also, it is expected that the LCD would not be cleared after resetting the Arduino if the newly downloaded code did not have the correct I2C address.  The LCD module will retain and refresh the LCD with the old data since it would not be receiving any new commands because of the I2C address mismatch.

August 16, 2015
3:40 am
Avatar
Steffan
Admin
Forum Posts: 305
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Also, if your test code above worked, that's using I2C address 0x3F, not 0x20.  So you would want to use address (decimal) 63 in that case.

August 16, 2015
3:57 am
Avatar
RTSLVU
Member
Forum Posts: 18
Member Since:
March 20, 2015
sp_UserOfflineSmall Offline

Steffan said
Also, if your test code above worked, that's using I2C address 0x3F, not 0x20.  So you would want to use address (decimal) 63 in that case.

I uploaded the wrong sketch not the one where I change the address to 0x20

But you were right I was confusing the number bases and setting the address to 20 decimal instead of 20 hex

I set the display properties to hex and show radix then set it to 20 hex and it works

Image Enlarger

 

Image Enlarger

August 16, 2015
4:21 am
Avatar
Steffan
Admin
Forum Posts: 305
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Ok, good to hear.

August 16, 2015
8:49 pm
Avatar
RTSLVU
Member
Forum Posts: 18
Member Since:
March 20, 2015
sp_UserOfflineSmall Offline

Just a note, I have noticed that some of the examples have I2C address in Decimal and some have it in Hex.

You should decide on and use only one numbering system in the examples.

Also you should turn on the radix in all of the examples where it makes a difference like I2C address.

August 16, 2015
10:14 pm
Avatar
Steffan
Admin
Forum Posts: 305
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

All 3 I2C LCD examples have the I2C address in decimal on the block diagrams, and the front panels of the examples lists the I2C Address in hex and decimal.  Can you tell me where you see an inconsistency and we can correct it?

example.pngImage Enlarger

Attachments
Forum Timezone: UTC 0

Most Users Ever Online: 33

Currently Online:
1 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

John: 18

RTSLVU: 15

Dan6077: 11

Member Stats:

Guest Posters: 0

Members: 80

Moderators: 0

Admins: 3

Forum Stats:

Groups: 1

Forums: 2

Topics: 58

Posts: 289

Newest Members: Travlissah, viktorIcera, HowardClouG, Dianecet, Produktnaodchudzaniex

Administrators: geadmin: 5, filipealtoe: 35, Steffan: 89