1

I am doing a small project on my RPi. I already created a website that shows the temperature. The temperature is updated every minute with a cronjob and stored in a .txt file.

Now I want to be notified when the temperature rises above 30 degrees Celsius via SMS. I already set up a HSDPA USB Dongle and I am able to send SMS's via Terminal.

Can someone please help me to write a cronjob, that reads the temperature out of the .txt file and if the temperature is above 30 degrees Celsius it should send me an SMS. The command for sending SMS is this:

echo -e "To: 004917112312312\n\nTEXTMESSAGE" > /var/www/sms/outbox/testsms.txt
2
  • the .txt file looks like ths: Raspberry Pi wiringPi DHT22 reader www.lolware.net Humidity = 61.40 % Temperature = 25.00 *C
    – MrGT _
    Commented Sep 15, 2016 at 9:12
  • 1
    This info belongs in your question not in the comments. Please edit your question and add this information. Commented Dec 22, 2016 at 19:06

1 Answer 1

2

That would be

0 * * * * *  /bin/bash -c 'if [ "`cat /path/to/temp.txt`" -gt "30" ]; then echo -e "To: 004917112312312\n\nTEXTMESSAGE" > /var/www/sms/outbox/testsms.txt; fi'

Replace /path/to/temp.txt with the file containing the temperature value, and configure the alert frequency as you see fit (this one will fire every hour).

2
  • the .txt file looks like ths: Raspberry Pi wiringPi DHT22 reader www.lolware.net Humidity = 61.40 % Temperature = 25.00 *C
    – MrGT _
    Commented Sep 15, 2016 at 8:38
  • 1
    @MrGT_ and if that information was in the question, I could have written a much more useful answer, couldn't I? Commented Sep 15, 2016 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.