Difference between revisions of "PCF8574"
(→Input) |
(→Input) |
||
Line 38: | Line 38: | ||
! A1: | ! A1: | ||
! A2: | ! A2: | ||
+ | ! Address: | ||
! Port range: | ! Port range: | ||
|- | |- | ||
Line 43: | Line 44: | ||
| ''0'' | | ''0'' | ||
| ''0'' | | ''0'' | ||
+ | | 0x20 | ||
| 1 - 8 | | 1 - 8 | ||
|- | |- | ||
Line 48: | Line 50: | ||
| ''0'' | | ''0'' | ||
| ''0'' | | ''0'' | ||
+ | | 0x21 | ||
| 9 - 16 | | 9 - 16 | ||
|- | |- | ||
Line 53: | Line 56: | ||
| ''1'' | | ''1'' | ||
| ''0'' | | ''0'' | ||
+ | | 0x22 | ||
| 17 - 24 | | 17 - 24 | ||
|- | |- | ||
Line 58: | Line 62: | ||
| ''1'' | | ''1'' | ||
| ''0'' | | ''0'' | ||
+ | | 0x23 | ||
| 25 - 32 | | 25 - 32 | ||
|- | |- | ||
Line 63: | Line 68: | ||
| ''0'' | | ''0'' | ||
| ''1'' | | ''1'' | ||
+ | | 0x24 | ||
| 33 - 40 | | 33 - 40 | ||
|- | |- | ||
Line 68: | Line 74: | ||
| ''0'' | | ''0'' | ||
| ''1'' | | ''1'' | ||
+ | | 0x25 | ||
| 41 - 48 | | 41 - 48 | ||
|- | |- | ||
Line 73: | Line 80: | ||
| ''1'' | | ''1'' | ||
| ''1'' | | ''1'' | ||
+ | | 0x26 | ||
| 49 - 56 | | 49 - 56 | ||
|- | |- | ||
Line 78: | Line 86: | ||
| ''1'' | | ''1'' | ||
| ''1'' | | ''1'' | ||
+ | | 0x27 | ||
| 57 - 64 | | 57 - 64 | ||
|} | |} | ||
Line 86: | Line 95: | ||
! A1: | ! A1: | ||
! A2: | ! A2: | ||
+ | ! Address: | ||
! Port range: | ! Port range: | ||
|- | |- | ||
Line 91: | Line 101: | ||
| ''0'' | | ''0'' | ||
| ''0'' | | ''0'' | ||
+ | | 0x38 | ||
| 65 - 72 | | 65 - 72 | ||
|- | |- | ||
Line 96: | Line 107: | ||
| ''0'' | | ''0'' | ||
| ''0'' | | ''0'' | ||
+ | | 0x39 | ||
| 73 - 80 | | 73 - 80 | ||
|- | |- | ||
Line 101: | Line 113: | ||
| ''1'' | | ''1'' | ||
| ''0'' | | ''0'' | ||
+ | | 0x3A | ||
| 81 - 88 | | 81 - 88 | ||
|- | |- | ||
Line 106: | Line 119: | ||
| ''1'' | | ''1'' | ||
| ''0'' | | ''0'' | ||
+ | | 0x3B | ||
| 89 - 96 | | 89 - 96 | ||
|- | |- | ||
Line 111: | Line 125: | ||
| ''0'' | | ''0'' | ||
| ''1'' | | ''1'' | ||
+ | | 0x3C | ||
| 97 - 104 | | 97 - 104 | ||
|- | |- | ||
Line 116: | Line 131: | ||
| ''0'' | | ''0'' | ||
| ''1'' | | ''1'' | ||
+ | | 0x3D | ||
| 105 - 112 | | 105 - 112 | ||
|- | |- | ||
Line 121: | Line 137: | ||
| ''1'' | | ''1'' | ||
| ''1'' | | ''1'' | ||
+ | | 0x3E | ||
| 113 - 120 | | 113 - 120 | ||
|- | |- | ||
Line 126: | Line 143: | ||
| ''1'' | | ''1'' | ||
| ''1'' | | ''1'' | ||
+ | | 0x3F | ||
| 121 - 128 | | 121 - 128 | ||
|} | |} |
Revision as of 11:19, 6 February 2016
Contents
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
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.
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: | Address: | Port range: |
---|---|---|---|---|
0 | 0 | 0 | 0x20 | 1 - 8 |
1 | 0 | 0 | 0x21 | 9 - 16 |
0 | 1 | 0 | 0x22 | 17 - 24 |
1 | 1 | 0 | 0x23 | 25 - 32 |
0 | 0 | 1 | 0x24 | 33 - 40 |
1 | 0 | 1 | 0x25 | 41 - 48 |
0 | 1 | 1 | 0x26 | 49 - 56 |
1 | 1 | 1 | 0x27 | 57 - 64 |
For the PCF8574A:
A0: | A1: | A2: | Address: | Port range: |
---|---|---|---|---|
0 | 0 | 0 | 0x38 | 65 - 72 |
1 | 0 | 0 | 0x39 | 73 - 80 |
0 | 1 | 0 | 0x3A | 81 - 88 |
1 | 1 | 0 | 0x3B | 89 - 96 |
0 | 0 | 1 | 0x3C | 97 - 104 |
1 | 0 | 1 | 0x3D | 105 - 112 |
0 | 1 | 1 | 0x3E | 113 - 120 |
1 | 1 | 1 | 0x3F | 121 - 128 |
Optional settings
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