I use the following code in a project. I would like to add the temperature in de tekst from "char txtSMS_AlarmTemp" to send it in the SMS. How to do this?
I have also a question about the memory. I get a message of low memory on my UNO that is almost full. What to can i do to solve this problem.
//librarys
#include <GSM.h>
#include <OneWire.h>
#include <DallasTemperature.h>
////Telefoon
// PIN SIM
#define PINNUMBER ""
// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;
////Temperature
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
//Hardware adres DS18B20 PIN 4
DeviceAddress Thermometer = { 0x28, 0xBF, 0x64, 0xA3, 0x06, 0x00, 0x00, 0xC3 };
//Variable
float TEMPAlarm = 10.00;
//Telefoon nummers
char tel1[20]= "+3165********";
//Global files
byte ALARM_FLAG = 0;
//meldingenen
char txtSMS_Online[200]="<> Status Online";
char txtSMS_AlarmTemp[200]="ALARM de temperatuur is gezakt onder de ingestelde waarde";
char txtSMS_AlarmSensor[200]="ALARM temperatuur sensor niet gedetecteerd";
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("<> Aan");
// Start library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(Thermometer, 10);
//SIMmodule
// connection state
boolean notConnected = true;
// Start GSM shield
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
//SMS Online
Serial.println("GSM initialized");
sendSMSOnline();
}
// Temperatuur sensor
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC < -100.00) {
Serial.print("Sensor is niet verbonden 1e controle");
sendSMSAlarmSensor();
}
else if (tempC <= (float) TEMPAlarm) {
Serial.print("C: ");
Serial.print(tempC);
ALARM_FLAG = 1;
}
else {
Serial.print("Het is niet kouder dan de ingestelde waarde, het is nu *C ");
Serial.print(tempC);
}
}
void loop(void)
{
Serial.print("Meten...\n\r");
sensors.requestTemperatures();
Serial.print("Temperature ");
printTemperature(Thermometer);
Serial.print("\n\r");
if ( ALARM_FLAG == 1 ) {
Serial.println("Alarm Activated");
sendSMSTempAlarm();
}
else if ( ALARM_FLAG == 3 ) {
Serial.println("Alarm Activated ");
sendSMSTempAlarm();
}
delay (59000);
}
void sendSMSOnline(){
Serial.print("Message to mobile number: ");
Serial.println(tel1);
// sms text
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtSMS_Online);
// send the message
sms.beginSMS(tel1);
sms.print(txtSMS_Online);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
}
void sendSMSTempAlarm(){
Serial.print("Message to mobile number: ");
Serial.println(tel1);
// sms text
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtSMS_AlarmTemp);
Serial.println(txtSMS_AlarmTemp);
// send the message
sms.beginSMS(tel1);
sms.print(txtSMS_AlarmTemp);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
ALARM_FLAG = 2;
delay (120000); // 2 min
}
void sendSMSAlarmSensor(){
Serial.print("Message to mobile number: ");
Serial.println(tel1);
// sms text
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtSMS_AlarmSensor);
// send the message
sms.beginSMS(tel1);
sms.print(txtSMS_AlarmSensor);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
ALARM_FLAG = 3;
delay (120000); // 2 min
}