Hello there, my first time on this forum which I have used for a long time (read only!)
I really am stuck and would like some help with this problem please.
The program looks for a minus sign, this is the beginning of the incoming
temperatures from Sim800 module (i.e.)" -9 -22 " or, " -10 -25 " or, " -23 -32 ". The temperature always starts with a minus sign.
I am trying to get two values from this that I can use to set the temperature on a Dallas DS1820 sensor. Please can someone show me how? I need to end up with two values (i.e) val1 = -9 and val2 = -22 which I can set by receiving a text with the values as above.
"Store_temperature() is my function to do this but I have no idea
how to go about this...
void Get_Temp(){
sensors.setResolution(tempSensor, 9);
sensors.requestTemperatures(); // Set up Dallas thermometer
int T=(sensors.getTempCByIndex(0)); // Read the Dallas sensor
Temperature = (T);
char buffer[5];
}
void recSms(){
number="";
ESP.wdtFeed();
if(Serial.available())
{
char data = Serial.read();
if(data == '+'){RcvdCheck = 1;}
if((data == 'C') && (RcvdCheck == 1)){RcvdCheck = 2;}
if((data == 'M') && (RcvdCheck == 2)){RcvdCheck = 3;}
if((data == 'T') && (RcvdCheck == 3)){RcvdCheck = 4;}
if(RcvdCheck == 4){RcvdConf = 1; RcvdCheck = 0;}
if(RcvdConf == 1)
{
if(data == '\n'){RcvdEnd++;}
if(RcvdEnd == 3){RcvdEnd = 0;}
RcvdMsg[mydex] = data;
mydex++;
if(RcvdEnd == 2){RcvdConf = 0;MsgLength = mydex-2;mydex = 0;}
if(RcvdConf == 0)
{
for(int x = 4;x < 16;x++)
{
number+=RcvdMsg[x];
MsgMob[x-4] = RcvdMsg[x];
}
Serial.println();
for(int x = 45; x < MsgLength; x++){
MsgTxt[x-45] = RcvdMsg[x];
inchar=MsgTxt[x-45];
}
Serial.println();
RcvdCheck = 0;
RcvdConf = 0;
mydex = 0;
RcvdEnd = 0;
MsgMob[15];
MsgTxt[50];
MsgLength = 0;
Serial.flush();
Serial.println(inchar);
if(inchar == '#'){ // If "#" is received at any time then reply with current temperature
sendInfo(); // do it !
}else{
if(inchar == '*'){
store_number();
}else{
/*-----------------------------------------------------------------------------------------------
* The program looks for a minus sign, this is the beginning of the temperatures(i.e.)" -9 -22 "
* or " -10 -25 " or " -23 -32 ". The temperature always starts with a minus sign
* I am trying to get two values from this that I can use to set the temperature
* on a Dallas DS1820 sensor. Please can someone show me how? I need to end up with two
* values (i.e) val1 = -9 and val2 = -22 which I can set by sending a text with these
* values as above. "Store_temperature() is my function to do this but I have no idea
* how to go about it.
*-----------------------------------------------------------------------------------------------
*/
if(inchar == '-'){
store_temperature();
Serial.println(inchar);
}
}
}
}
}
}
}
void store_temperature(){
Serial.println("Storing temperatures");
Serial.println(inchar);
// I can print the inchar data "-9 -22" but how do I separate it now into the two values for processing ?
}