PCF8574 I2C LCD backpack driver

This driver works with PCF8574 IO expanders. You can see an guide on modifying them and connecting them to LCD screens & I2C here.

"output":
   [{
     "driver":"pcf8574",
     "kwargs":
      {
       "addr":"0x3f"
      }
   }]

Note

If you provide backpack’s I2C address as a kwarg, you should pass it as a string (as shown above).

To test your screen, you can just run python output/driver/pcf8574.py while your screen is connected to I2C bus (you might want to adjust parameters in driver’s if __name__ == "__main__" section). It will initialize the screen and show some text on it.

class output.drivers.pcf8574.Screen(bus=1, addr=39, debug=False, **kwargs)[source]

A driver for PCF8574-based I2C LCD backpacks.

__init__(bus=1, addr=39, debug=False, **kwargs)[source]

Initialises the Screen object.

Kwargs:

  • bus: I2C bus number.
  • addr: I2C address of the board.
  • debug: enables printing out LCD commands.
  • **kwargs: all the other arguments, get passed further to HD44780 constructor
write_byte(data, char_mode=False)[source]

Takes a byte and sends the high nibble, then the low nibble (as per HD44780 doc). Passes char_mode to self.write4bits.

write4bits(value, char_mode=False)[source]

Writes a nibble to the display. If char_mode is set, holds the RS line high.

expanderWrite(data)[source]

Sends data to PCF8574.