Problem with PCF8574 on Wake

Moderators: Voyager, BertB, rtenklooster, Stuntteam, Martinus, grovkillen, TD-er

Post Reply
Message
Author
Vic20
Normal user
Posts: 16
Joined: 29 May 2018, 11:51

Problem with PCF8574 on Wake

#1 Post by Vic20 » 10 Sep 2018, 17:00

I'm in the final stages of my solar powered Tipping bucket rain gauge project but have come up with a problem after deepsleep.

The basic function of the unit uses a CMOS 8 bit binary counter chip clocked by the reed of a Maplin Tipping bucket unit.

Each 'Bit' of the counter feeds one input of a PCF8574 I/O expander. The count is then summed in a Dummy variable using a rule (my first attempt at a rule!).

Here's the Devices:-

Image

'Raincount' is the number of tips of the bucket multiplied by it's volume in mm of rain (0.2974 per tip). This will be despatched to Thingspeak at a predetermined interval

The Rule

Code: Select all

On System#Wake do    //When the ESP Wakes, do
 GPIO,12,0  //GPIO12 gives 0V to PCF8574 pin 8 to activate it.
 timerSet,1,3        //Set Timer 1 for the next event in 3 seconds
 TaskRun,2    //to try and force a read of the PCF8574 ..don't work :(
 TaskRun,3
 TaskRun,4
 TaskRun,5
 TaskRun,6
 TaskRun,7
 TaskRun,8
 TaskRun, 11
endon  //bucket volume is 0.2794
On Rules#Timer=1 do
 TaskValueSet,10,1,([Sixteen#Switch]*16*0.2794)+([Thrtytwo#Switch]*32*0.2794)+([Sixtyfour#Switch]*64*0.2794)+([Eights#Switch]*8*0.2794)+([Fours#Switch]*4*0.2794)+([Twos#Switch]*0.2794*2)+([Ones#Switch]*0.2794)
 timerSet,1,10
endon
The unit works great when permanently powered, here's the count up from Binary 63 to 64 for example as seen on the Com Port...

Code: Select all

704683 : ACT  : TaskValueSet,10,1,(1*16*0.2794)+(1*32*0.2794)+(0*64*0.2794)+(1*8*0.2794)+(1*4*0.2794)+(1*0.2794*2)+(1*0.2794)
704704 : ACT  : timerSet,1,10
704737 : Command: taskvalueset
704740 : Command: timerset
706447 : PCF  : State 0
706452 : EVENT: Ones#Switch=0.00
706470 : PCF  : State 0
706474 : EVENT: Twos#Switch=0.00
706493 : PCF  : State 0
706497 : EVENT: Fours#Switch=0.00
706515 : PCF  : State 0
706519 : EVENT: Eights#Switch=0.00
706537 : PCF  : State 0
706541 : EVENT: Sixteen#Switch=0.00
706560 : PCF  : State 0
706565 : EVENT: Thrtytwo#Switch=0.00
706583 : PCF  : State 0
706587 : EVENT: Sixtyfour#Switch=1.00
The idea is that the CMOS counter is kept constantly powered (2.5uA drain) and carries on counting while the ESP sleeps. On Wake up, the ESP powers the PCF by driving its GND pin low and then reads the new count. (though I've also tried it with the PCF constantly powered). Once a count is succesfully received and sent to Thingspeak, I will add an 'On System sleep' rule to pulse the CMOS counter chips reset lines to zero the count.

The issue I'm having is that the PCF8574/ESP EASY is not seeing the count increment on wakeup. i.e it's not reading any of the changes that have happened to the PCF9574's pins' inputs, preferring to keep the values that were there before it went to sleep.

ESP Easy is only seeing changes on an actual state toggle whilst it is awake.

Is this a bug or do I have to, by means of a rule, somehow kick the PCF into reading the new values? I've tried, (as in the rule above shown) prompting a read by a 'Taskrun' command and also toggling the use of the PCF pins (PCFGPIO,x,0 then PCFGPIO,x,1) to no avail.

Thanking all in advance for any help, I've been stuck on this for days!

User avatar
grovkillen
Normal user
Posts: 1897
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Problem with PCF8574 on Wake

#2 Post by grovkillen » 10 Sep 2018, 17:53

I think the way we currently are doing things within rules are not quite ready yet. Not all commands are using the scheduler for example. The idea you have should work but we're not checking input states before the wake event (I think). Open an issue on the GitHub page please.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Vic20
Normal user
Posts: 16
Joined: 29 May 2018, 11:51

Re: Problem with PCF8574 on Wake

#3 Post by Vic20 » 12 Sep 2018, 00:23


Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests