PCF8574 - How does it work ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bodyfix
New user
Posts: 5
Joined: 02 May 2016, 12:38

PCF8574 - How does it work ?

#1 Post by bodyfix » 02 May 2016, 20:25

Hello,

use ESP-01 with Build 105
"Devices" Settings are SDA: GPIO-2 / SCL: GPIO-0
"Tools / I2C Scan" the return value are : 0x38

Device Setting :
Device : Switch input - PCF8578
Name: OUTPCF
Delay: 0
IDX/Var: 38
Port: 0
Value Name1: Switch

On the port "0" a LED is connected.

to control the port "0" use the command
http://<ESP IP address>/control?cmd=pcfgpio,0,1

The Return value are : { "log": "GPIO 0 Set to 1", "plugin": 19, "pin": 0, "mode": "output", "state": 1 }

But the port "0" don't worked
has an idea :idea: :idea: , do not come on :( :cry:

Can you Hellllllppppppppppp

dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

Re: PCF8574 - How does it work ?

#2 Post by dduley » 02 May 2016, 20:59

bodyfix wrote:Hello,

use ESP-01 with Build 105
"Devices" Settings are SDA: GPIO-2 / SCL: GPIO-0
"Tools / I2C Scan" the return value are : 0x38

Device Setting :
Device : Switch input - PCF8578
Name: OUTPCF
Delay: 0
IDX/Var: 38
Port: 0
Value Name1: Switch

On the port "0" a LED is connected.

to control the port "0" use the command
http://<ESP IP address>/control?cmd=pcfgpio,0,1

The Return value are : { "log": "GPIO 0 Set to 1", "plugin": 19, "pin": 0, "mode": "output", "state": 1 }

But the port "0" don't worked
has an idea :idea: :idea: , do not come on :( :cry:

Can you Hellllllppppppppppp
Hi,

PCFGPIO pin numbering does not begin with 0.
The GPIOs are numbered 1 - 8 not 0 - 7.

Try This instead:
http://<ESP IP address>/control?cmd=pcfgpio,1,1

bodyfix
New user
Posts: 5
Joined: 02 May 2016, 12:38

Re: PCF8574 - How does it work ?

#3 Post by bodyfix » 02 May 2016, 21:09

Hello dduley,

Thanks for the note, but it does not work with Port 1 :(

dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

Re: PCF8574 - How does it work ?

#4 Post by dduley » 02 May 2016, 22:34

bodyfix wrote:Hello dduley,

Thanks for the note, but it does not work with Port 1 :(
Hi Bodyfix,

How is your PCF8574 wired up? These things are really open drain output (Even though the data sheet says they are push pull). They really do best when they pull down. This requires an external pullup resistor. What about the addressing of the chip? Pins 1,2 and 3 (A0 - A3) should all be pulled to Gnd. Which version of the chip do you have: the PCF8574 or the PCF8574A?. The two parts differ in the address range they respond to.

Can you put a volt meter on various pins and try other outputs? You may have damaged output 1.

I know...a lot of questions! but I am trying to get the complete picture.

regards

Dave

bodyfix
New user
Posts: 5
Joined: 02 May 2016, 12:38

Re: PCF8574 - How does it work ?

#5 Post by bodyfix » 03 May 2016, 19:34

Hi Dave,
Thanks for your questions, have all gathered.

Cabeling : have use this cable-schema
Image

PCF8574 adress : the pin are all on A0-2 = 0

Image

By "I2C Scan" the return address is 0x38, for this reason I meen the chip is PCF8574A, on the chip the label are not readable.

have measured the port 1 and 2 voltage , it is always present 3,2VDC if I switch the port to 1 or 0.

what am I doing wrong

Regards,
Philippe

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: PCF8574 - How does it work ?

#6 Post by costo » 03 May 2016, 23:51

You use address 0x38. Maybe you should try address 0x37 by making the 3 address pins 'HIGH'.
If I look inside the WebServer.ino there are 3 addresses available for PCF8574, these are 0x20, 0x27 and 0x3F.

I am not 100% sure but it looks like ESPEasy will not work with other addresses than these 3 mentioned above for the PCF8574.

dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

Re: PCF8574 - How does it work ?

#7 Post by dduley » 04 May 2016, 07:35

bodyfix wrote:Hi Dave,
Thanks for your questions, have all gathered.

Cabeling : have use this cable-schema
Image

PCF8574 adress : the pin are all on A0-2 = 0

Image

By "I2C Scan" the return address is 0x38, for this reason I meen the chip is PCF8574A, on the chip the label are not readable.

have measured the port 1 and 2 voltage , it is always present 3,2VDC if I switch the port to 1 or 0.

what am I doing wrong

Regards,
Philippe
Hi Philippe,

I am using the PCF8574 (not the A version). It comes up on address 0x20. The only thing I noticed that's different between your schematic and mine is that I have SDA (pin 15) going to GPIO 0 and SCL (pin 14) going to GPIO 2. That shouldn't matter unless it wasn't right under the Hardware section of ESPEasy. I have to assume that you have it right because your I2C scan is returning something. I havent looked through the source code to see how the PCF8574 is handeled so I think COSTO is correct that you may be trying to use an address range that isn't recognized.

Good luck!

Dave

bodyfix
New user
Posts: 5
Joined: 02 May 2016, 12:38

Re: PCF8574 - How does it work ?

#8 Post by bodyfix » 06 May 2016, 08:13

it Works It Works :lol: :lol: :lol:
i found the bug :twisted: it's meeeee :mrgreen:

Correct Installation

i use PCF8574A by "I2C Scan" the adress return
- if PIN A0-A2 = 0 > 0x38
- if PIN A0-A2 = 1 > 0x3F

The Problem was the adressing in devices
- if use the adress 0x38 you need to use the port range 65-72
- if use the adress 0x3F you need to use the port range 121-128
both adress configuration works

The correct device configuration is: by I2C device on 0x38

Code: Select all

Device Setting :
Device : Switch input - PCF8578
Name: OUT1
Delay: 0
IDX/Var: 1
Port: 65
Value Name1: Switch
with
http://<espip>/control?cmd=pcfgpio,65,1 and http://<espip>/control?cmd=pcfgpio,65,0
it works :roll: :roll:

thanks for your Supports

Phil

bodyfix
New user
Posts: 5
Joined: 02 May 2016, 12:38

Re: PCF8574 - How does it work ?

#9 Post by bodyfix » 08 May 2016, 15:11

One question I have , how can I control the ports via MQTT ??

with http it is : http://<espip>/control?cmd=pcfgpio,65,1 and http://<espip>/control?cmd=pcfgpio,65,0
but as with MQTT : ??

ut1545
Normal user
Posts: 35
Joined: 22 Mar 2016, 20:56

Re: PCF8574 - How does it work ?

#10 Post by ut1545 » 01 Jun 2016, 12:17

Any news about how to control PCF8574 via MQTT?

Drum
Normal user
Posts: 300
Joined: 07 Feb 2016, 11:56

Re: PCF8574 - How does it work ?

#11 Post by Drum » 01 Jun 2016, 13:24

I am curious about controlling via MQTT as well. Try posting to a new topic with MQTT in the title. That might get the interest of people who are using MQTT. ;)

FranckkyDoo
Normal user
Posts: 21
Joined: 31 Oct 2016, 03:03

Re: PCF8574 - How does it work ?

#12 Post by FranckkyDoo » 10 Feb 2017, 20:27

Here a example from my config.json of my homebridge

...
}, {
"accessory": "mqttswitch",
"name": "1",
"url": "mqtt://localhost",
"username": "username",
"password": "password",
"captions": "Power Bar plug 1",
"topics": {
"statusGet":"/PBP/1sw/Sw",
"statusSet":"/PBP/PCFGPIO/65"
},
"onValue": "1",
"offValue": "0",
"integerValue": "true"
}, {

I inversed the onValue and offValue and voilà !!!

Btw, if someone know how to inserted it,let me know ...

Hope that help !!

sartam
Normal user
Posts: 43
Joined: 13 Mar 2022, 21:25

Re: PCF8574 - How does it work ?

#13 Post by sartam » 02 May 2022, 12:22

Hello. In the last release of March 2022, did something change in the work of PCF8574? I do exactly as it says here, the LED connected to port 0 does not respond. Everything is connected according to the diagram above. Firmware mega20220328_normal_ESP8266_4M1M

User avatar
Ath
Normal user
Posts: 3950
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCF8574 - How does it work ?

#14 Post by Ath » 02 May 2022, 13:16

What exact command are you using to switch the pin of the PCF ?
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: PCF8574 - How does it work ?

#15 Post by chromo23 » 02 May 2022, 13:29

he is right...
Bildschirmfoto 2022-05-02 um 13.31.55.png
Bildschirmfoto 2022-05-02 um 13.31.55.png (22.1 KiB) Viewed 16497 times
i just tested my pcf8574 as an output and it did not work at all....

edit:
just checked all ports...
with mine port 0,2,3,5,6,7 are always high and 1,4 always low
switching them leads only to a short on pulse on the always low pins and an off pulse on the always high pins
Last edited by chromo23 on 02 May 2022, 17:30, edited 1 time in total.

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: PCF8574 - How does it work ?

#16 Post by chromo23 » 02 May 2022, 13:58

i gets funky.. changing the address makes it work (the high low issue not the gpio 0 issue)
the discrepancy between the gpio in the command and the actual port still exists

sartam
Normal user
Posts: 43
Joined: 13 Mar 2022, 21:25

Re: PCF8574 - How does it work ?

#17 Post by sartam » 02 May 2022, 16:13

I use the command pcfgpio,65,1. Address pcf8574 0x38
chromo23, What address are you using?

User avatar
Ath
Normal user
Posts: 3950
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCF8574 - How does it work ?

#18 Post by Ath » 02 May 2022, 17:08

According to the documentation, the PCFGPIO pins should be addressed from 0 to 255, depending on the I2C address used, where address 0x20 or 0x38 (for the PCF8574A model) starts with pcfgpio 0.

This is apparently changed in the software since this (quite old) thread was started and last updated.
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: PCF8574 - How does it work ?

#19 Post by chromo23 » 02 May 2022, 17:13

pcfgpio,0,1 ...is bulls**t ...sorry :oops: (it starts with pcfgpio,1,1)
i was confused because while i was testing under the standard address 0x20 and got weird feedback from the leds
chromo23 wrote: 02 May 2022, 13:29 edit:
just checked all ports...
with mine port 0,2,3,5,6,7 are always high and 1,4 always low
switching them leads only to a short on pulse on the always low pins and an off pulse on the always high pins
sartam wrote: 02 May 2022, 16:13 I use the command pcfgpio,65,1. Address pcf8574 0x38
chromo23, What address are you using?
I use 0x20 which doesn’t work and only tried 0x21 which is working.
You use the pcf8574a which uses other adresses.

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: PCF8574 - How does it work ?

#20 Post by chromo23 » 02 May 2022, 17:17

Ath wrote: 02 May 2022, 17:08 According to the documentation, the PCFGPIO pins should be addressed from 0 to 255, depending on the I2C address used, where address 0x20 or 0x38 (for the PCF8574A model) starts with pcfgpio 0.

This is apparently changed in the software since this (quite old) thread was started and last updated.
Yes, i just found out :)

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: PCF8574 - How does it work ?

#21 Post by chromo23 » 02 May 2022, 17:18

sartam wrote: 02 May 2022, 12:22 Hello. In the last release of March 2022, did something change in the work of PCF8574? I do exactly as it says here, the LED connected to port 0 does not respond. Everything is connected according to the diagram above. Firmware mega20220328_normal_ESP8266_4M1M
have you tried another port and/or another address?

sartam
Normal user
Posts: 43
Joined: 13 Mar 2022, 21:25

Re: PCF8574 - How does it work ?

#22 Post by sartam » 02 May 2022, 17:52

chromo23 wrote: 02 May 2022, 17:18

have you tried another port and/or another address?
Now I will try another port, although I already did it.

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: PCF8574 - How does it work ?

#23 Post by chromo23 » 02 May 2022, 18:03

for me only another address seems to work. i would start with that...

sartam
Normal user
Posts: 43
Joined: 13 Mar 2022, 21:25

Re: PCF8574 - How does it work ?

#24 Post by sartam » 02 May 2022, 18:29

chromo23 wrote: 02 May 2022, 18:03 for me only another address seems to work. i would start with that...
Port address, or pcf8574 address?


sartam
Normal user
Posts: 43
Joined: 13 Mar 2022, 21:25

Re: PCF8574 - How does it work ?

#26 Post by sartam » 02 May 2022, 19:52

Does not work. I do not understand why. Went through all available pcf8574 addresses...

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: PCF8574 - How does it work ?

#27 Post by chromo23 » 02 May 2022, 20:47

sartam wrote: 02 May 2022, 19:52 Does not work. I do not understand why. Went through all available pcf8574 addresses...
and you changed the command according to the address?
Unfortunately i have only the pcf8574 without an a to test. Maybe the bug concerns only the base address 0x20 but maybe not.....
What is the output when you enter the command? A picture of the circuit could be also helpful.

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: PCF8574 - How does it work ?

#28 Post by chromo23 » 03 May 2022, 14:06

I testet the pcf8574 again after a factory reset. and it seems to work fine in output mode regardless which address is used (don´t know what happend yesterday)

@sartam:
what you can try for testing is to use the latest release on your device do a factory reset and only connect the pcf8574 and the led as in the picture at the beginning of the post. You don´t need R1 and R3 if you have a board like this:
Bildschirmfoto 2022-05-03 um 13.57.47.png
Bildschirmfoto 2022-05-03 um 13.57.47.png (49.14 KiB) Viewed 16361 times
Do an ic2scan to see if it is present..

Then activate rules and enter the code below to change all pins to output mode:

Code: Select all

on system#boot do
PCFmodeRange,65,72,0 // this is the range for the default address 0x38 of the pca8574
endon
Reboot! (you could enter this command into the commandfield unter /tools as well, but i had somehow issues with this)

Then enter the command under /Tools in the commandfield:

Code: Select all

pcfgpio,65,0 
(or change it to whatever pin you have the led connected to)

sartam
Normal user
Posts: 43
Joined: 13 Mar 2022, 21:25

Re: PCF8574 - How does it work ?

#29 Post by sartam » 08 May 2022, 21:30

An interesting thing. I'll try, of course. I'm not using a module, but just a microcircuit in a dip package. But this should not be an obstacle. I will definitely try.

sartam
Normal user
Posts: 43
Joined: 13 Mar 2022, 21:25

Re: PCF8574 - How does it work ?

#30 Post by sartam » 08 May 2022, 21:54

It is working! The only remark. I connected the microcircuit to 5 volts. Although the datasheet says that the power is in the range of 2.8-5.2 volts

User avatar
Ath
Normal user
Posts: 3950
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCF8574 - How does it work ?

#31 Post by Ath » 08 May 2022, 22:09

Great you have it working now!

Working with the chip at 5V may cause issues on the I2C bus, as that is 3.3V for ESP's, but the Wemos and NodeMCU units seem to be able to handle 5V signals without damage.
So if you can use it at 3.3V that is the advised route.
/Ton (PayPal.me)

sartam
Normal user
Posts: 43
Joined: 13 Mar 2022, 21:25

Re: PCF8574 - How does it work ?

#32 Post by sartam » 08 May 2022, 22:18

Yes, of course I know about this feature. But, as they say, you can't argue with facts. Also, an LSD 2004 display is connected to 5 volts, and it works fine.

TD-er
Core team member
Posts: 9266
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCF8574 - How does it work ?

#33 Post by TD-er » 09 May 2022, 13:55

The main thing to keep in mind is that when connecting several sensors/chips to the same I2C bus, you must make sure they all can handle the 5V on the SDA/SCL lines.

sartam
Normal user
Posts: 43
Joined: 13 Mar 2022, 21:25

Re: PCF8574 - How does it work ?

#34 Post by sartam » 10 May 2022, 16:59

Often, information about the capabilities of the operation of slave devices on the I2C bus from 5 volts with a general power supply of the circuit from 3.3 volts often flashes before my eyes.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests