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:-
'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
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 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!