anrieff is right, the power consumption is still high. Some things to look at:
DTR interrupt is really edge triggered or the Thing wakes up many times as long as DTR is low?
It seems that the highest consumption is at wake up, you might make some delay to disable door open detection for a specified time after the last one. I don't think that an alarm each 5 seconds is needed.
How to figure out the power consumption without cutting wires:
- Take off the battery and measure the voltage, better with a higher precision voltmeter.
- Connect the voltmeter to the Thing power
- Connect the battery and write down the voltage at various stages until the deep sleep. You can also see how long it takes to go to deep sleep.
- take off the battery and load-it with resistor of various values until you get the values in the previous step
- From the resistor values you can get the current consumption.
It's not very accurate but you can get a clue where your battery is used and if the consumption is in the range you expect to be.
Update because I didn't answered to questions 1 and 2
In my opinion not but the fast development comes with a cost. I would use something else like a wireless ring bell to bring the signal to a wall adapter powered Thing.
Yes but to complicated for such simple task
Update following the comment
- Depends on the meaning of "such thing"
1a. Such thing = quick fix using what you have handy. Answer = yes.
1b. Such thing = professional wireless door opening sensor. Answer = no , Friendly advice, don't look at a toy store like Sparkfun for such things. Neither their products or tutorials have nothing to do with the development of reliable professional products.
Yes, see here an article about low power wireless technologies used today, you can find links to products and development boards and compare the power requirements for each solution. As you see using the home AP is the worse from the lifespan point of view.
Edit to add some more strategies:
If the switch closed is long enough then power your board through the switch, on power on send the ping then goto deep sleep.
If the deep sleep is still consuming to much or the event is to short then use a hardware monostable triggered by the switch to get a fixed powered time for the Thing.
You can also set in hardware a "dead window" where the switch is ignored after a trigger to avoid multiple events in a short time.
Using interrupts is a good way, tough i see the pin you're using has something to do with the hardware reset, using long reset is not good since many devices are still consuming much while kept in reset.
Still, for high reliability products you cannot use only wake-up on interrupt. At some point an EM glitch might bring the microcontroller in a state where to disable the interrupts or ignore them. From this point your device is dead and only a hardware reset can help.
For that the watchdog was invented, if you not take action to reset the watchdog by software he will wakeup/reset the device after a specified time. The time is usually set in the flash memory and protected from software errors and EM glitches. That way even something went wrong you can allways have your program running again and, eventually report the error and take action.
It's allways a good practice to send an "alive" signal from time to time from the same reason.
Going further than your project if the sensor isn't as friendly as a door switch and requires power for himself than you can either set a timer interrupt to wake up , power the sensor and get the data, or use a hardware pulse generator that powers both from time to time. Here is where a good device will let you play with the system clock to minimise the power consumption when processing power is not needed. Not the case of the Thing.