How to wake from SLEEP_MODE_DEEP from always HIGH input

Setup: I have a Xenon measuring a paddle wheel flow meter (3 wires: pos, neg, pulse) that sends a pulse while water is flowing. When flow stops, there is a timer that when complete, puts the Xenon into SLEEP_MODE_DEEP. I want to wake the Xenon when flow starts again, so I have the pulse wire from the flow meter into D8. The pulse signal is either LOW or HIGH. The problem is that sometimes the flow meter gets stuck in a position that stays HIGH. So when the Xenon goes into deep sleep, it just immediately wakes back up again. If the flow meter is in a LOW state, then all is good.

Any ideas on how to implement a RISING signal to D8 if the flow meter pulse signal is at an uncontrollable HIGH or LOW state? I’ve experimented with the thought of an assortment of MOSFET switches and JK flip flops. But both get me to the same conclusion. I pretty much need:
if FlowMeterSignal = HIGH or LOW, D8 = LOW until FlowMeterSignal changes state (LOW to HIGH or HIGH to LOW). The Xenon is in deep sleep when the flow meter signal is supposed to change state, so the switching will have to be external to the Xenon capabilities.

Just came across Logic Gates (new to the world of electronics). I think the solution is using two EX-OR gates in series should work. Using the flow meter as input A for both gates, and a separate Xenon digital output for input B on both gates. By reading if the flow meter is high or low, the digital outputs can be set to cause the resulting value to be LOW. Then when the flow meter rotates/status change (high to low or low to high), then this will cause a rising edge to wake the Xenon.

For Gen3 devices waking from deep sleep on different pins than D8 and other edges than just RISING is a planned feature.

However, the power saving of deep sleep over stop sleep (which already has that capability) is marginal.

It seems odd that the interrupt would fire on a HIGH level instead of a HIGH transition. @ScruffR, perhaps this is a bug. We should do a quick test to validate the potential error.

3 Likes

Agreed! I missed that part :blush: I was so preoccupied with the known non-waking issue of Gen2 devices when WKP was HIGH on sleep that I just overlooked the difference about the level trigger.

Test peding.


Update:

My Boron 0.9.0 (LiPo powered) immediately wakes after switching off on a HIGH level (not RISING edge)

SYSTEM_MODE(MANUAL)

void setup() {
  pinMode(D7, OUTPUT);
  digitalWrite(D7, HIGH);
  delay(500);
}

void loop() {
  digitalWrite(D7, LOW);
  System.sleep(SLEEP_MODE_DEEP);
  // System.sleep(SLEEP_MODE_DEEP, 30);  // this should throw an error as timed wake is NOT supported - but it doesn't
}

I filed these two issues about this


2 Likes

Hello,

I can confirm that issue on an Argon board : holding D8 high, then going into deep sleep makes the board wake up instantly, while the expected behavior is to have it stay in sleep mode until an edge event occurs.

Best regards

Hello,

Has any progress been made on this issue?

If wake-up on edge is not possible because of the hardware, could we at least have the choice to wake-up on LOW on D8 instead of HIGH? Is there a way to configure this with the current DeviceOS?

Best regards