How to detect that a tilt sensor has been tilted “shorted” when polling only every minute

sensor

I thought about modifying this circuit (Momentary switch power: press to turn on, microcontroller can turn itself off), but I wonder if something simpler might work (or if someone had a better idea)?

I'm using the Atmel SAM R21 Xplained to prototype a device. I want to detect if a tilt sensor has been activated, but I don't want to continuously poll its stated so I can save power. I'd like to poll, let's say once a minute, send it's state over 802.15.4 to the cloud.

Here is the idea I've come up with:

By using a digital output to charge a capacitor and the analog input to detected it's voltage, track the capacitor's voltage to see if it got shorted out within the 1 minute interval. The circuit would look something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

The algorithm would be:

  1. Initially charge the capacitor.
  2. Loop forever –
    Detect, if the voltage dropped significantly, send a message.
    Charge the capacitor.

Thanks,

Greg

Best Answer

The usual approach to this sort of problem would be not to poll, but to use an interrupt.

If you mask the interrupt but poll the interrupt request flag you will have essentially the same result as what you have suggested, with no hardware (consider filtering to establish a minimum pulse length in order to reject noise).

Related Topic