Pages

Tuesday, 25 July 2017

Grief with I2C library on arduino LiquidCrystal_I2C library (No display or displaying 1 character)

Oh man. I hate it when things break.

I've used a couple of these displays recently, whilst developing my next project (watch this space ... it may be Mini related!)


These are a bog-standard 1602 with a Hitachi HD44780 driver or equivalent, and mounted with a PCF8574 Remote 8-Bit I/O Expander for I2C-Bus, thus enabling a 2 wire (+ power and ground) solution. Great. 

Now when I made the GPS master clock, I used one coupled up with a 20x4 display. All was well after I tested a few libraries, I finally found one that worked.

Now something broke in the IDE. I'm not sure when, but now the library I used no longer works :(
Be very careful here, as there appear to be more than one library named LiquidCrystal_I2C ... which makes matters VERY confusing in the IDE's library manager. 

The library originally came from https://playground.arduino.cc/Code/LCDi2c ...

Now if it doesn't work , open up the LiquidCrystal_I2C.cpp file in the Libraries/LiquidCrystal_I2C folder in your Arduino's default folder...

Scroll down until you see this bit:

/*********** mid level commands, for sending data/cmds */

inline void LiquidCrystal_I2C::command(uint8_t value) {
send(value, 0);
}

inline size_t LiquidCrystal_I2C::write(uint8_t value) {
send(value, Rs);
return 0;
}


Now... change return 0; to return 1; 

Like this :

/*********** mid level commands, for sending data/cmds */

inline void LiquidCrystal_I2C::command(uint8_t value) {
send(value, 0);
}

inline size_t LiquidCrystal_I2C::write(uint8_t value) {
send(value, Rs);
return 1;
}

Save the file, and try again....

Fixed. 

Took bloody hours to find that!!!

No comments:

Post a Comment