Hi all , Long story I have a i2c lcd display which has a touch panel that make a pin high if a key is press on the touch panel .
what I want to do is connect that pin on the WKP pin to bring it out of deepsleep , but I want to monitor the state of the WKP pin with something like the DigitalRead( WKP ) , is there a pin name for it ?.
Yes, you can call it WKP
or A7
But how would you digitalRead(WKP)
while the device is in deep sleep?
I think I`m in trouble when a key gets press it goes LOW not HIGH , so need to bring it out of sleep with a high to low state.
But how would you digitalRead(WKP) while the device is in deep sleep?
It would not be in deepsleep , I was going to use the WKP pin to see if it was due to normal time out or due to the WKP. going high.
I see, but that's a tricky one since waking from sleep will possibly take a while, so once your code has reached the point where you read the pin the press-state might have changed already, consequently you won't be able to tell - unless you add a sustaining circuit (e.g. RC combo) which keeps the signal high long enough after even a short press.
But if you'd rather go with a wake-on-pin sleep mode (once they work as intended), you can set the trigger edge for the wake-pin.
If the device is put to deep sleep for a given time - say 10min, using retained variables its possible to work out if the device woke from time or WKP pin going high. then you can decide what happens when the device wakes up, you could check something and go straight back to sleep, or turn the display backlight on and go into a ready for input state.
I do this with my water monitor, it works well, but there is a long boot up time (maybe 1/2 second or so with threading enabled so you dont wait for the cloud to reconnect)
As for your falling trigger, you could use a transistor to invert the signal
I dont understand what you mean here , because as far as I know you can
t choose the trigger edge for the WKP , it`s only low to high.
That is not a problem because if you press a key it goes LOW until you use a i2c function which read what key was pressed and then it goes back HIGH.
I tried that last night with a pnp transistor out of my junk box ( 2n3702 ) probably about 20 years old .
didn`t fully work , it came out of sleep , but every time I checked it was high , I think my device has a stronger pull down when you first press the key , but does not hold it down that strongly .
I try the other method a npn and voltage drop and see if that works
is that deep sleep or just wifi off sleep ?
Neither, but the docs I linked have some insight about it.
Although there seems to be some regression with the info, since this is not true for the Photon
The code will halt at the next instruction following the sleep()
call and continue from there, once woken up.
@peter_a if the device woke up then it was either time or the pin waking it up. If the time is when you expected it to wake then it woke from time. If it’s not then it was from the wkp pin. Why do you need to check the state again? It only needs to be a fraction of a second pulse to wake the device so your npn might do the trick.
If you want to check it when the photon is running you can create an interrupt on the same wkp pin.
Thanks all , I have got my NPN transistor working as a invertor , just needed the right resistor values.
So now if a press a button , it wakes up and IF it`s high , it know there is a key entry in the keypad buffer , so it asks for the last entry in the buffer , which make the pin go low again.