Hi guys,
I am trying to make an Energy Monitor with the consult of the values measured by GPRS.
I have developed the code below so far:
#include <Sim800l.h>
#include <SoftwareSerial.h> //is necesary for the library!!
Sim800l Sim800l; //to declare the library
char* text;
char* number;
bool error; //to catch the response of sendSms
int fatura=200;
String textSms, numberSms;
uint8_t index1;
uint8_t LED2 = 13; // use what you need
void setup() {
pinMode(LED2, OUTPUT);
digitalWrite(LED2, HIGH);
Serial.begin(9600); // only for debug the results .
Sim800l.begin(); // initializate the library.
Sim800l.reset();
//don't forget to catch the return of the function delAllSms!
error = Sim800l.delAllSms(); //clean memory of sms;
}
void loop() {
textSms = Sim800l.readSms(1); //read the first sms
if (textSms.indexOf("OK") != -1) //first we need to know if the messege is correct. NOT an ERROR
{
if (textSms.length() > 7) // optional you can avoid SMS empty
{
numberSms = Sim800l.getNumberSms(1); // Here you have the number
//for debugin
Serial.println(numberSms);
textSms.toUpperCase(); // set all char to mayus ;)
if (textSms.indexOf("Value") != -1) {
text = "fatura"; //text for the message.
number = "2926451386"; //change to a valid number.
error = Sim800l.sendSms(number, text);
}
}
else {
Serial.println("Not Compatible ...sorry.. :D");
}
Sim800l.delAllSms(); //do only if the message is not empty,in other case is not necesary
//delete all sms..so when receive a new sms always will be in first position
}
}
}
What I want to do is receive the value regarding the variable fatura declared in the top when I send a message to Arduino written "Value" from my mobile phone.
I think with this code programmed like the posted code, I will receive a message written "fatura". I dont want it. I want receive a message with the number 200, which is the value of the variable "fatura".
Does anybody can help me?