Code for Gas Sensor Alert Based on SMS

Can someone help me? Please refer the code in the attachment.
I’m using arduino uno, sim900 module, mq2 gas sensor and buzzer to create a gas sensor detector based on sms.
I have to 2 option :

  1. The mq2 gas sensor detects and send the result via sms to the number set in the code.
  2. We can send a specific string to know the surrounding gas percentage and send the result to the specific number set in the code.

But I want to change the second option to be auto reply to any incoming number. What should I do?

order_gas.ino (2.12 KB)

What is this for? Clearly you are interested in detecting some flammable gas, but why are you making this? I ask only because in your code, the way you are reading the sensor and mapping it ie:val = map(val,0,1023,0,100);, does not in any way give you results as a percentage of any flammable gas. So if you are intending to use this in any life-safety application whatsoever, what you are proposing is dangerous.

This is actually not the original code that I'm using. I'm currently doing my final project. My objective is to prevent fire incident at home or any place that can cause fire incident. So I create a project that can detect the LPG gas and send sms to the owner. The owner also can send a sms to the specific number and the arduino will calculate the gas surrounding the kitchen area by the help of the MQ2 sensor if the owner is not at home. Then the sim900 will send back to the incoming number which is the owner's number that I have set in the code. I manage to do that but I just want to know what if the owner is using other phone number to send the sms? Is it possible to create a command to make it auto reply to any incoming number?

this is the snapcode that i want to change.

//code using sms lapor. lastButtonState = st; int pos = 0; if (started) { pos = sms.IsSMSPresent(SMS_ALL); if (pos) { sms.GetSMS(pos, n, smsbuffer, 100); delay(2000); if (!strcmp(smsbuffer, "lapor")) { PString str(buffer, sizeof(buffer)); str.begin(); str.print("Rate of gas leakage currently at "); str.print(val); str.print("%"); //String a=str; sms.SendSMS("+6xxxxxxxxxx", buffer); //replace this code } delsms(); } } }

It will be great if it can be remove and replace it with a command that can make the arduino operate as an auto reply sms to any incoming number if they send the specific string to the sim900 module