LCD 2x10 HD44780 display on PCF8574 bundle

Hi All,

just to already warn you, I am pretty much a newbie about electronics and just started to wrap my head around the arduino platform in order to build up a terrarium controller.

What I have so far:

  • 3 x LM75A temperature sensors via I2C, all working like a charm
  • couple of LEDs controlled via digital output, working as well
  • LCD 2x10 via I2c, display is HD44780 based and is hooked off of a PCF8574 - NOT WORKING

I bought the display as a complete unit. The only thing I got with it is a piece of C code but unfortunately I do not know how the PCF8574 is connected to the HD44780.

The c code I got with it is the following:

void setup(){
  Wire.begin();
}

void loop(){
Wire.beginTransmission(39);
  Wire.send(B00000000);
  delay(15);
  // init  
  Wire.send(B00000011); // X E RW RS D7 D6 D5 D4
  delay(5);
  Wire.send(B01000011);
  delay(5);
  Wire.send(B00000011);
  delay(5);
  Wire.send(B01000011);
  delay(5);
  Wire.send(B00000011);
  delay(5);
  Wire.send(B01000011);
  delay(5);
  Wire.send(B00000011);
  delay(5);
  Wire.send(B00000010);
  delay(5);
  Wire.send(B01000010);
  delay(5);
  Wire.send(B00000010);
  delay(5);
    
  Wire.send(B00000010);
  delay(5);
  Wire.send(B01000010);
  delay(5);
  Wire.send(B00000010);
  delay(5);
  Wire.send(B00001100);
  delay(5);
  Wire.send(B01001100);
  delay(5);
  Wire.send(B00001100);
  delay(5);
  Wire.send(B00000000);
  delay(5);
  Wire.send(B01000000);
  delay(5);
  Wire.send(B00000000);
  delay(5);
  Wire.send(B00001000);
  delay(5);
  Wire.send(B01001000);
  delay(5);
  Wire.send(B00001000);
  delay(5);
  Wire.send(B00000000);
  delay(5);
  Wire.send(B01000000);
  delay(5);
  Wire.send(B00000000);
  delay(5);
  Wire.send(B00000001);
  delay(5);
  Wire.send(B01000001);
  delay(5);
  Wire.send(B00000001);
  delay(5);
Wire.endTransmission();
}

The code itself seems to be running, but the only thing I see is that the display gets initialized (gets wiped once I did Wire.send(B000000)).

Also, I do not really get what is being meant with the comment // X E RW RS D7 D6 D5 D4 up there. Is that how the 8 P ports on the PF8574 are mapping to the Display?

Thanks already for any hints or tips,

Passi

Yes, that comment tells you how the PCF8574 is wired to the LCD. The eight output pins of the PCF8574 chip (it's an eight-bit output port with I2C interface) are connected to the input pins if the LCD in a certain order. That order is, according to the comment, D7 to nothing, D6 to E, D5 to R/W, D4 to RS and so on. They're using the LCD in 4-bit mode.

edit why not doing it like this?

  | 1   2   3   4   5   6   7   8   9   10  11  12  13  14 15  16 |
  +-+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-+
    |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   GND V+  CNT  RS  RW  E   D0  D1  D2  D3  D4  D5  D6  D7  LV+ LGND
    |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   
    =   +5  |   |   =   |                   |   |   |   |
    |   +-+ |   |       |                   |   |   |   |
    |     < |   |       |                   |   |   |   |
    | 10K ><+   +------------------+        |   |   |   |
    |     <             |          |        |   |   |   |
    +-----+             |          |        |   |   |   |
                        |          |        |   |   |   |
                        |          |        |   |   |   |
                        |          |        |   |   |   |
                        |          |        |   |   |   |
           Arduino      |          |        |   |   |   |
           ^   ^        |          |        |   |   |   |
       +5  |   |       ++          |        |   |   |   |
       |   |   |   |   |   |   |   |        |   |   |   |
     +-+---+---+---+---+---+---+---+-+      |   |   |   |
     | V+ SDA SCD INT  P7  P6  P5  P4|      |   |   |   |
     |                               |      |   |   |   |
      D    PCF8574 port expander     |      |   |   |   |
     |                               |      |   |   |   |
     | A0  A1  A2  P0  P1  P2  P3 GND|      |   |   |   |
     +-+---+---+---+---+---+---+---+-+      |   |   |   |
       |   |   |   |   |   |   |   |        |   |   |   |
       +---+---+   |   |   |   +------------------------+
       |           |   |   +------------------------+
      gnd          |   +------------------------+
                   +------------------------+

?