How to send a variable by SMS using SIM800L Module

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.
  //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
      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 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?


text = "fatura"; //text for the message.


char text[10];
sprintf(text,"%d", fatura);  // or itoa(fatura, text, 10 );

Thus way you build a string with the fatura value in ASCII

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include “SIM900.h”
#include “sms.h”
#define SIM800_TX_PIN 2
#define SIM800_RX_PIN 3

SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

int sensorPin = A0;
int sensor = A1;
int sensorValue = 0;
float volts=0.0;
float temp=0.0;
float tempF=0.0;
int led = 9;
int buzzer = 12;

void setup() {

pinMode(led, OUTPUT);


void loop()

lcd.print(“Fire Scanner ON!”);
Serial.println(“Fire Alarm System Using Arduino Uno With SMS notification”);
sensorValue = analogRead(sensorPin);
sensor = analogRead(A1);
float volts = (sensor/1024.0)5.0;
float temp = volts
float tempF = temp*9/5+32;
Serial.print("temperature= ");

if (sensorValue < 500)
if (gsm.begin(2400))
lcd.print(“Sunog Sunog!!”);
Serial.println(“Fire Detected”);
Serial.println(“in the Kitchen!”);
if (sms.SendSMS("+639169441596", “Fire Detected in the kitchen”));


hi can you pls help me im a beginner in arduino and im struggling to this continuously sending an alert message to the number i put inside the code your help will be great thank you :slight_smile:

Please use code tags

Forget the sms for the time being. Get rid also if the lcd. You’ll add those in later

Can you write a code that monitors your sensors and print an alert message to the serial console when the fire is detected ?

Decide also what needs to happen once the message has been printed - I’ve not seen any requirements there