Attiny13 mailbox notifier

I would use an attiny13 to send a sms every time the postman shake the mailbox, it will be in sleep mode all time until the vibration switch wake up it. What's could be the algorithm for send the SMS only once per day, excluding the other accidental trigger possible during day?

When you send the SMS save the timestamp:

SMSsendTimestamp = millis();

Then when a shake is detected you will compare millis() to the timestamp value and only send another SMS if it's been long enough since the last one was sent:

if(millis() - SMSsendTimestamp  >= minimumSMSinterval) {

But is millis function available in sleep mode?

You're right. millis() won't increment while sleeping. I skimmed over that part of your question. You can track how long the ATtiny13 slept by waking it up with the watchdog timer, incrementing a variable, then going back to sleep. Then you can calculate the amount of time it was asleep by watchdogWakeCount * watchdogTimerDuration. It looks like the longest watchdog timer duration on ATtiny13 is two seconds (WDTO_2S). I think the watchdog timer is not super precise, from Smart | Connected | Secure | Microchip Technology

Since the watchdog timer is based on a free-running RC oscillator, the times are approximate only and apply to a supply voltage of 5 V. At lower supply voltages, the times will increase. For older devices, the times will be as large as three times when operating at Vcc = 3 V, while the newer devices (e. g. ATmega128, ATmega8) only experience a negligible change.

but it should be sufficient for your purposes if you calibrate it. If you need more precision you could consider using an RTC.

pert:
You're right. millis() won't increment while sleeping. I skimmed over that part of your question. You can track how long the ATtiny13 slept by waking it up with the watchdog timer, incrementing a variable, then going back to sleep. Then you can calculate the amount of time it was asleep by watchdogWakeCount * watchdogTimerDuration. It looks like the longest watchdog timer duration on ATtiny13 is two seconds (WDTO_2S). I think the watchdog timer is not super precise, from Smart | Connected | Secure | Microchip Technology it should be sufficient for your purposes if you calibrate it. If you need more precision you could consider using an RTC.

It is nowhere near three times out at any voltage on the t13. Maybe 20% ?

Uhm, how do you plan to send an SMS from a tiny13?

Do you have that part working (SMS being sent from tiny13)?

As I understand it, the cell modules you'd need in order to connect to the cellular wireless use serial, so you'd have to cram a software serial implementation, plus your sketch, into just 1k of flash; IIRC software serial will take up most of that, and you lose another chunk of it to the arduino overhead itself...

I just don't see it happening. Plus - serial requires a reasonably accurate clock (it's timing dependent). The internal oscillator is not one of those - it can be tuned, but even after tuning it, it will vary by temperature and voltage. So if you had it located in a location that experienced significant temperature swings (like a mailbox) powered by something with a non-constant voltage (like a battery), you're likely to have problems using the internal oscillator for serial.

You need a bigger chip, and I think you're going to need a crystal on it if you're going to be talking over serial with it (be sure to get ones spec'ed for the full temperature range expected - the bargain basement ones don't work at low temperatures)....

DrAzzy:
As I understand it, the cell modules you'd need in order to connect to the cellular wireless use serial, so you'd have to cram a software serial implementation, plus your sketch, into just 1k of flash; IIRC software serial will take up most of that, and you lose another chunk of it to the arduino overhead itself...

Tx only bitbang serial implementations can be pretty small.