My photon is powered by a LiPO battery. I want to wake up photon from DeepSleepmode whenever the USB power is plugged in. How to do this? I understand that I can give a 3v3 to my WKP Pin. But then i have to reduce the 4.6v Vin to 3.3v before using it on the WKP pin. There is no room for a voltage reducer circuit in my PCB. Can this be done any other way easily?
Thanks @ScruffR. But there is a problem. Let me explain.
I have a LiPO charging cicuit connected to photon’s USB IN.
Now, If I connect VIN to WKP pin , the photon will wake up whenever the USB is connected for charging. And whenever photon is charging with USB connected, then that may keep the WKP pin all time high and may also prevent the photon from entering sleep mode when the USB is connected.
Thats not desirable. Instead I want to wake up the photon whenever the USB is powered up and then the firmware runs as usual and at the end of execution goes to deepSleep. Again if I plug the USB port out and plug it in again, then it should wakeup the photon again . Not when USB is just plugged in all time.
Any thoughts on how to do this? Greatly appreciate your help
One thing to clarify. Wake only occures on an edge (in the case of WKP it’s a RISING edge), so even if you have a HIGH level sitting there on WKP the device should still go to sleep and only wake when the level changes from LOW to HIGH (which requires a preceeding HIGH to LOW transition which won’t wake the device).
But your main point to figure is how to create a RISING edge when you plug the USB supply into your charger that’s already occupying the Photons USB connector.
So having said this, it’s a hardware question only possible to answer with good enough knowledge of your external circuitry which you haven’t really disclosed. Some LiPo charging circuit does not give away much.
@manihk, the WKP pin is (rising) edge driven, not level driven. Because you have a battery powering Vin in the absence of Vusb, with WKP connected to either Vin or 3V3, plugging in the USB charger will not give you the rising edge you need on WKP.
I’m a bit confused on your power configuration. Is your LiPo charger connected to the raw Vusb or Vin? If it is on Vin and you also have the LiPo connected to Vin then you can’t differentiate the two voltages. There is a protection diode between the raw Vusb and Vin. Connecting WKP to the raw Vusb may give you the rising edge you need. You will need a pull-down resistor (10K+) on WKP to make sure it doesn’t float. You should also put a small (0.01uF) capacitor to GND on WKP. The only hassle is that the raw Vusb is not exposed as a pad on the board. The other more serious hassle is that the WKP pin is exposed to possible voltage transients on Vusb. You could put a small 200 ohm series resistor (between raw Vusb and WKP) to limit current on Vin are lower the chance of damage.
Does your charging circuit have a “power good” or other output indicating that a charging voltage is present? This might be usable as well.
Not to sound facetious, but since (I assume that) the USB is connected manually… why not just have a pushbutton next to the connector. Insert USB and press the button… “hey, wake up!”
@BulldogLowell I also thought so. The application requires water proof casing and introduction of any button increases the complexity of Ingress proofing for that additional component also. Anyway looking into other ways to do it.
@peekay123: Thanks for the clarification.
Since Vusb is not exposed, not knowing how to get this done.
I am using MCP73831 for LiPo charging. It has a STAT pin to indicate if the circuit is charging the LiPo . This gives LOW when charging is complete as well as no charging is present.
Any thoughts on using this?
@manihk, for Vusb, you would need a small pass-through adapter board which breaks out the Vusb for use on your board. Another approach is to use the Particle power shield but that may be overkill.
The STAT pin on the MCP73831 is tri-state. It will go low during the charging cycle (implying power is applied) and high when charging is complete. It floats if no battery is present or the device is in shutdown (no power). Unfortunately, even with a pull-up, that does not produce the rising edge needed by the WKP pin unless you us an inverter.
Along the lines of what @BulldogLowell suggested, you could embed a magnetic reed switch or similar “physically” decoupled switch to activate WKP.
I am going with a reed switch(normally open) to connect the RST pin on photon to GND , as well as to a GPIO. When activated, the RST will be pulled down to GND triggering the reset.
I am wondering if we need a debounce circuitry in this case or is the internal capacitance used with the RST switch by itself take care of the small spikes.
@manihk, I believe the RST pin already has an RC debounce circuit on it so no need to add one.
Can I ask why you are also driving a GPIO pin as well? When the switch goes low and Photon is in RST mode, you can’t read the GPIO. When the reed switch is released, by the time code runs, the switch will no longer be in the same state. FYI, the RC will hold the low pin value for (at most) 1ms after release of the switch.
@peekay123
I am driving the GPIO also to use that to change the mode of the photon in the firmware. So the circuit i have imagined is as follows:
RST and One GPIO is connected to GND through Reed switch.
Photon will be in deep sleep mode.
When Reed is activated, it activates reset and also pulls down the GPIO.
If we continue to hold the magnet in position, the reed is held active, and GPIO held low. I use a timer logic in the firmware to see if its held for 10secs, then reset the mode to listening mode.
I believe holding the reset switch for 10seconds will not keep reseting the photon since its a trailing edge triggered. Have i got it right?
@manihk, not quite. Reset is active LOW. Hold the reset button down and see what happens. You’ll find that it just holds the Photon in reset mode which is NOT what you want. However, you may be mistaking RESET for the WKP pin which will wake the Photon from deep sleep on a rising edge.
To make it work the way you want, you will first need to hold the WKP low with a pull-down resistor (say 10K ohms). Then your reed switch is connected between 3V3 and the WKP pin. When you activate the reed, it will wake the Photon after which your timer can reset, set the pinMode() on WKP to INPUT and start timing the HIGH on the WKP for 10 seconds.
I have done something similar where a product is in deep sleep and is considered “off”. One of the interface buttons hooked to WKP wakes the Photon and is then used as a mode button in the firmware (using the clickButton library).
@peekay123 Using the WKP sounds promising . In that setup should I consider a debounce circuit for the Reed switch, since there isn’t an internal debounce for WKP pin.
@manihk, no need for hardware debounce since:
a) WKP will wake the Photon on the first rising edged (bounce will be ignored after that)
b) If you use the clickButton library, all debouncing is done in code
@peekay123 I just noticed that there is a Solder pad (26) exposed for Setup button. So instead of using a GPIO, i can directly use this solder pad? That way I dont have to write a separate firmware code for Setup button behaviour. I am assuming the setup pad is Active HIGH.
Am I missing something?
Greatly appreciate your patience in answering all my basic questions @peekay123. You rock!
@manihk, you are correct. You can use that pad with an external button to GND to activate SETUP (your button is basically in parallel with the onboard button).