Data request using GSM shield

Hello. I'm trying to request data from some sensors by phone message using a gsm shield.
A phone message should trigger the data transmission, but the data is transmitted non-stop without me sending a "request message".
There's the code.
What should i do?
Thanks!

#include <SoftwareSerial.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include "DHT.h"

SoftwareSerial mySerial(7, 8);
#define ONE_WIRE_BUS 6
#define DHTPIN 4
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp_ex;
float umiditate;
float temp_in;

void setup()

{

mySerial.begin(9600);
Serial.begin(9600);
Serial.println("Initializing...");
delay(100);
dht.begin();
DS18B20.begin();
mySerial.println("AT+CNMI=1,2,0,0,0");
delay(1000);
}

void loop()

{
readData();
if (RecieveMessage()){
delay(100);
SendMessage();
}

}

void SendMessage()

{

mySerial.println("AT+CMGF=1");

delay(1000);
String dataMessage = ("Temp_in: " + String(temp_in) + " C " +"Temp_ex: "+ String(temp_ex) + " C "+ " Umiditate: " + String(umiditate) + " %");
mySerial.println("AT+CMGS="+xxxxxxxx"\r");

delay(1000);

mySerial.println(dataMessage);

delay(100);

mySerial.println((char)26);

delay(1000);

}

boolean RecieveMessage()

{
if(mySerial.available() >0) {
char incoming_char;
incoming_char=mySerial.read();
Serial.print(incoming_char);
if(incoming_char = "Test"){
return 1;
}
return 0;
}
}
boolean readData()
{
DS18B20.requestTemperatures();
temp_ex=DS18B20.getTempCByIndex(0);
umiditate = dht.readHumidity();
temp_in = dht.readTemperature();

 if (isnan(umiditate) || isnan(temp_in)||isnan(temp_ex)) {
  Serial.println(F("Failed to read from sensors!"));
  return false;
 }
   Serial.print(F("% Temp int: "));
    Serial.print(temp_in);
    Serial.print(F(" C "));
    Serial.print(F("% Temp ext: "));
    Serial.print(temp_ex);
    Serial.println(F(" C"));
    Serial.print(F("% Umiditate: "));
    Serial.print(umiditate);
    delay (5000);
}

Use code tags

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.