Go Down

Topic: PCF8574A not working with I2C Library (Read 322 times) previous topic - next topic

jzl

I have removed my previous post, due to me being a noob and not counting the pins according to the datasheet.

I have in the meantime managed to get the LCD working.

I have read this post: https://alselectro.wordpress.com/2016/05/12/serial-lcd-i2c-module-pcf8574/

The post explains in detail what each pin does and where it's connected to etc.

I used my multimeter in continuity mode to trace the pins from the chip to where they are connected to the LCD, as per bperrybap.

I have found one exception with using the PCF8574A:

I have to specify the backlight pin.

Code: [Select]

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

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7);  // Set the LCD I2C address
#define BACKLIGHT_PIN 3


void setup()

  Serial.begin(9600);
  emon1.voltage(A0, VOLT_CAL, 1.7);
  emon1.current(A1, 6.5);
  lcd.begin(16,2); 
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  pinMode(8, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(2), IntTrig, CHANGE);

}



I have also noticed that my text on the LCD seemed to be chopped off - it turns out it was a dry joint on the pin to the LCD.

Thanks to all for the advice. SOLVED.


bperrybap

A couple of things.

If you are going to use that library, I would recommend using the full constructor. i.e.
Code: [Select]
lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, HIGH);
While you may have seen setBackLight(pin, level) in examples you found out on the internet, it is an obsolete method and has been for many years.
The preferred way to configure backlight control with that library is by using the full constructor.
When done that way, the backlight will be on when begin() returns.

setbacklight(dimlevel) doe not take a HIGH or LOW as an argument.
It takes a dimlevel value 0-255 to set brightness. Using HIGH (dimvalue of 1) happens to work with the LiquidCrystal_I2C i/o class as i2c backpack h/w does not support dimming so any dimvalue over 0 will turn the backlight on with full intensity.
If you did that with some other i/o class and h/w you could end up with a very dim backlight.

I'm still curious why you decided not to use the hd44780 library.

--- b ill

jzl

#17
Sep 11, 2019, 04:52 pm Last Edit: Sep 11, 2019, 04:53 pm by jzl
I'm still curious why you decided not to use the hd44780 library.

--- b ill
Two reasons:

1. I've used the previous library before.
2. The examples on the recommended library seemed too much to navigate through (menus within menus) and I'm too lazy to read haha

I will use it for my next project.

Thanks for all the advice.

bperrybap

#18
Sep 11, 2019, 07:19 pm Last Edit: Sep 11, 2019, 08:26 pm by bperrybap
2. The examples on the recommended library seemed too much to navigate through (menus within menus) and I'm too lazy to read haha
Likely, you spent more time reading that web page and probing the backpack than the few minutes it would have taken to read about the hd44780 library and the hd44780_I2Cexp i/o class which auto detects everything for you....  ;)

--- bill

Go Up