Difference between revisions of "PCF8574"

From Let's Control It
Jump to navigation Jump to search
Line 29: Line 29:
 
  [[File:EasyConfigPCFD.png]]
 
  [[File:EasyConfigPCFD.png]]
  
You then select the portnumber (numbered from 1 - 8) and additional configuration depending on the controller type. For Domoticz, you enter the IDX that was allocated by Domoticz for this virtual switch.
+
You then select the portnumber and additional configuration depending on the controller type. For Domoticz, you enter the IDX that was allocated by Domoticz for this virtual switch.
 +
 
 +
Portnumbering depends on the I2C address used:
 +
 
 +
For the PCF8574:
 +
{| border="1" style="border-collapse:collapse; border:1px solid silver;text-align:left;width:50%;"
 +
! A0:
 +
! A1:
 +
! A2:
 +
! Port range:
 +
|-
 +
| ''0''
 +
| ''0''
 +
| ''0''
 +
| 1 t/m 8
 +
|-
 +
| ''1''
 +
| ''0''
 +
| ''0''
 +
| 9 t/m 16
 +
|-
 +
| ''0''
 +
| ''1''
 +
| ''0''
 +
| 17 t/m 24
 +
|-
 +
| ''1''
 +
| ''1''
 +
| ''0''
 +
| 25 t/m 32
 +
|-
 +
| ''0''
 +
| ''0''
 +
| ''1''
 +
| 33 t/m 40
 +
|-
 +
| ''1''
 +
| ''0''
 +
| ''1''
 +
| 41 t/m 48
 +
|-
 +
| ''0''
 +
| ''1''
 +
| ''1''
 +
| 49 t/m 56
 +
|-
 +
| ''1''
 +
| ''1''
 +
| ''1''
 +
| 57 t/m 64
 +
|}
 +
 
 +
For the PCF8574A:
 +
{| border="1" style="border-collapse:collapse; border:1px solid silver;text-align:left;width:50%;"
 +
! A0:
 +
! A1:
 +
! A2:
 +
! Port range:
 +
|-
 +
| ''0''
 +
| ''0''
 +
| ''0''
 +
| 65 t/m 72
 +
|-
 +
| ''1''
 +
| ''0''
 +
| ''0''
 +
| 73 t/m 80
 +
|-
 +
| ''0''
 +
| ''1''
 +
| ''0''
 +
| 81 t/m 88
 +
|-
 +
| ''1''
 +
| ''1''
 +
| ''0''
 +
| 89 t/m 96
 +
|-
 +
| ''0''
 +
| ''0''
 +
| ''1''
 +
| 97 t/m 104
 +
|-
 +
| ''1''
 +
| ''0''
 +
| ''1''
 +
| 105 t/m 112
 +
|-
 +
| ''0''
 +
| ''1''
 +
| ''1''
 +
| 113 t/m 120
 +
|-
 +
| ''1''
 +
| ''1''
 +
| ''1''
 +
| 121 t/m 128
 +
|}
  
 
=== Optional settings ===
 
=== Optional settings ===

Revision as of 11:07, 6 February 2016

Introduction

The number of GPIO pins on the ESP module can be expanded with a IO Expander. We will use the PCF8574 that provides 8 more pins that can be used as input or output. This way it becomes possible to control an 8 channel relay board.

Each individual pin can be used as either input or output.

Hardware

PCF8574.jpg PCF8574Module.jpg

The PCF8574 needs to be connected through the I2C interface. This chip is compatible with 3V3 and it can be connected to the ESP without levelshifters..

Connections

 PCF8574 	ESP-01
 GND 	 	GND
 VCC    	VCC
 SDA		GPIO 0
 SCL		GPIO 2

Software

ESP Easy

Configuration depends on how you want to use a certain port on this device. Ports are numbered 1 to 8 (if you have a single PCF8574 connected)

Input

To have an input port act as an input switch device (just like with the default onboard GPIO pins) you need to edit a ESP Easy task and select the "PCF8574 input" device.

EasyConfigPCFD.png

You then select the portnumber and additional configuration depending on the controller type. For Domoticz, you enter the IDX that was allocated by Domoticz for this virtual switch.

Portnumbering depends on the I2C address used:

For the PCF8574:

A0: A1: A2: Port range:
0 0 0 1 t/m 8
1 0 0 9 t/m 16
0 1 0 17 t/m 24
1 1 0 25 t/m 32
0 0 1 33 t/m 40
1 0 1 41 t/m 48
0 1 1 49 t/m 56
1 1 1 57 t/m 64

For the PCF8574A:

A0: A1: A2: Port range:
0 0 0 65 t/m 72
1 0 0 73 t/m 80
0 1 0 81 t/m 88
1 1 0 89 t/m 96
0 0 1 97 t/m 104
1 0 1 105 t/m 112
0 1 1 113 t/m 120
1 1 1 121 t/m 128

Optional settings

Use of value names

Output

You can control output pins on this chip with the following http command:

http://<ESP IP address>/control?cmd=pcfgpio,<pin>,0

http://<ESP IP address>/control?cmd=pcfgpio,<pin>,1