Page 1 of 1

Freezer alarm with buzzer!

Posted: 24 Oct 2018, 20:24
by Naesstrom
This might be a stupid question but I'm building a freezer alarm with a wemos d1 mini and a buzzer shield, I'm getting the temp from 2 ds18b20's... I've never written a rule before but after some reading I've come up with the following

Code: Select all

on temp#Temperature do 
  if [temp#Temperature] > -15 // temp warmer then -15ºC
    tone,14,1000,700
  endif
endon
Havn't tried it yet but will it loop? And how can I add a pause so the sound is beeping and not just a continous tone?

Re: Freezer alarm with buzzer!

Posted: 24 Oct 2018, 20:30
by grovkillen
Rtttl is another command but it will block the loop during the playing. But to stop it after a while you need to use timer and possibly dummy devices to store the state (creating a kind of hysteresis).

Re: Freezer alarm with buzzer!

Posted: 24 Oct 2018, 21:26
by Naesstrom
grovkillen wrote: 24 Oct 2018, 20:30 Rtttl is another command but it will block the loop during the playing. But to stop it after a while you need to use timer and possibly dummy devices to store the state (creating a kind of hysteresis).
Yeah I was thinking of making it play the imperial march but since it's going to be at my office I wasn't sure how the other teachers would react :D

I was looking at the tutorial rules and was thinking about this one

Code: Select all

 //start the warning signal when we receive a start_warning event:
 On start_warning do 
   timerSet,1,2
 endon
 
 //stop the warning signal when we receive a stop_warning event:
 On stop_warning do
   timerSet,1,0
 endon
 
 //create an actual warning signal, every time timer 1 expires:
 On Rules#Timer=1 do 
   //repeat after 2 seconds 
   timerSet,1,2

   //produce a short 1000hz beep via a piezo element on pin 14
   tone,14,1000,700
 
 endon
is that a better way, and then create a rule that sends a

Code: Select all

cmd=event,start_warning
when the temperature is -15 or warmer and a

Code: Select all

cmd=event,stop_warning
when the temperature is colder then -15?

Re: Freezer alarm with buzzer!

Posted: 24 Oct 2018, 21:39
by Naesstrom
Actually I tried my first try of the code and it worked super... set it to this:

Code: Select all

on FRYS#Temperature do 
  if [FRYS#Temperature] > 30 // temp warmer then -15ºC
    tone,14,1000,700
  endif
endon
And when warming it up over 30 it starts beeping and when it cools down it stops! Just as I wanted it! :D hmm... maybe I should do something more fun like a rtttl :D

Can I add another rule in the same set for the fridge?

Re: Freezer alarm with buzzer!

Posted: 24 Oct 2018, 22:47
by grovkillen
Yeah it shouldn't be a problem.