Good day.
First off, please believe me, I have spent the last month reading books, checking related forms and web sites to look for a complete sketch that I could use, with No-Joy. I started out with the simple concept of having a Unu3/Fona, send a SMS when a certain Temp Val was reached. I then got side tracked by trying to get it to network up with Ubidots, but could not get it to connect. Currently, I am now back scowering the internet, and all my notes, to see if I can Frankenstein something together that will work. The one problem I have, besides my lack of programming knowledge, is time. This project was started for my brother, who needs a way to be alerted when a large bait freezer that is on a $2+mil sport fishing boat gets to warm, it can ruin thousands of dollars' worth of bait. And fishing season has started in C.R.
I have been going at this nonstop for weeks, and my brain has turned to mush. I will keep trying, and once the Freezer Alarm is working and sent off to my brother in Costa Rica, I plan to start learning programming, starting at square one, as the possibilities in this field are endless. But for now, I am just running out of time.
If you have read this far into my ramble, perhaps you would be someone that would look at what I am going and write a sketch for me, and to share with others on this forum.
My objectives are for this sketch are:
- Have Uno take a temp reading from a One-Wire DS18B20 Digital temperature sensor about every 30 minutes.
- Compare incoming temp, with Alarm (SMS) trigger temp, around 25f or -4c // I can adjust the temp values later.
- When Alarm is triggered send predefined SMS to predefined phone number. // In this instants, my brothers cell.
- Have the FONA, send out only one alarm SMS until the freezer problem is corrected, and the Uno/Fona have had a hard reset. Do not wanted it spamming my brother`s cell.
Any help or suggestions would be so greatly appreciated.
May the compiler gods be good to you all. Thanx. Jack
jkhammer58@hotmail.com
Speed_Monkey Posts: 13Joined: Tue Dec 01, 2015 1:18 am
This code checks the temperature sensor continuously, but only sends one message. It will not send a message if the reset button is pressed but the temperature remains too high. That is - the reset button does nothing until the temperature is lowered. I have added an alarm LED so that you know that the unit needs to be reset.
boolean message_sent = false;
const int reset_button = 3;
const int alarm_led = 4;
void loop() {
boolean temp_too_high = is_temp_too_high();
boolean reset_button_down = (digitalRead(reset_button) == HIGH);
if(!temp_too_high && message_sent && reset_button_down) {
message_sent = false;
digitalWrite(alarm_led, LOW);
}
else if(temp_too_high && !message_sent && !reset_button_down) {
// temp is too high. Send a message
message_sent = true;
digitalWrite(alarm_led, HIGH);
send_the_sms_message();
}
else {
// do nothing.
}
}
boolean is_temp_too_high() {
// read temperature sensor, return true if temp is too high
}
void send_sms_message() {
// send message via SMS
// we don't need the temperature, because the message is only sent once
// when the temp starts to exceed the threshold, which is a fixed number
}
Maybe this is not what you want. Maybe when the temperature is too high, you come in, reset the alarm, and do stuff to lower the temperature. This takes time, so you want the button to "latch" so that the alarm becomes active again once the temperature has remained low for a period of time. If you want the message sent every hour until the temp drops, that's also do-able.
So maybe the logic should be: when the temp goes high, send a message. Don't send another until it has lowered for five minutes.
Or: send the alarm when temp exceeds 4.5, cancel when if has lower to 4 for 5 minutes.
Or: when the temp goes high, send a message. Send another half an hour later if the temp remains high. If the temp goes low and stays low for 10 minutes, then send another message indicating that the temp is now ok - emergency over. But if a reset button gets pressed, them don't bother sending that second 'ok' message.
What I'm saying is, first you decide what you want the code to do. Then you start coding.
Thank you PaulMurrayCbr.
You read my mind, just what I was looking for. I just hope reading my mind did not lower your IQ. 
Thanx again. Jack