Cannot send the SMS after combining with the LCD

Hi everyone, my project is to detect the overcurrent. I set certain value in my code. When the value is over limit, then the GSM will send a warning message to the cell phone. Before I interface with the LCD, the program went well (I can send the SMS). But, after I connect the LCD to the circuit, the value can be displayed at the LCD but the SMS cannot be sent. Hopefully anyone can help. Thanks.

First code : Before interface with LCD

#include <SoftwareSerial.h>
#include <EmonLib.h>
#include "SIM900.h"
#include "sms.h"
EnergyMonitor emon1;
SMSGSM sms;

int CT = A0;
int Tx = 1;
int sensorValue;
int outputValue;

void setup()
{
pinMode(CT,INPUT);
pinMode(Tx, OUTPUT);

Serial.begin(9600);
Serial.println("Electrical Appliances Usage Report for Group 6 House");

emon1.current(A0, 7.41);

if (gsm.begin(9600))
{
Serial.println("\n\n Status=READY");
}

else Serial.println("\n\n Status=IDLE");
}

void loop()
{
double Irms = emon1.calcIrms(150);

sensorValue = analogRead(CT);
outputValue = map(sensorValue, 0, 1023, 0, 5);

analogWrite(Tx, outputValue);

Serial.print("\n\n Sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
Serial.print("\t Power = ");
Serial.println(Irms230.0);
Serial.print("\t voltage = " );
Serial.println(sensorValue
0.00488);
Serial.print("\t current = " );
Serial.println(Irms);

if (Irms > 8.00)
{
Serial.println("#Overcurrent!!! Attention required.#");
(sms.SendSMS("+60164113534", "Overcurrent!!! Attention required."));
Serial.println("#SMS sent OK#");
delay(60000);
}

else
{
Serial.println("#Safe situation#");
delay(2000);
}
}

Second code : after connect with LCD

#include <EmonLib.h>

#include "SIM900.h"
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include "sms.h"
#include "Emonlib.h"
SMSGSM sms;
EnergyMonitor emon1;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int CT = A0;
int Tx = 1;
int sensorValue;
int outputValue;

void setup() {
pinMode(CT,INPUT);
pinMode(Tx, OUTPUT);

Serial.begin(9600);
Serial.println("Electrical Appliances Usage Report for Group 6 House");
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("Voltage");
lcd.print(" ");
lcd.print("Current");

emon1.current(A0, 7.41);

if (gsm.begin(9600)){
Serial.println("\n\n Status=READY");
}

else Serial.println("\n\n Status=IDLE");

}

void loop()
{
double Irms = emon1.calcIrms(150);

sensorValue = analogRead(CT);
outputValue = map(sensorValue, 0, 1023, 0, 5);

analogWrite(Tx, outputValue);

Serial.print("\n\n Sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
Serial.print("\t Power = ");
Serial.println(Irms230.0);
Serial.print("\t voltage = " );
Serial.println(sensorValue
0.00488);
Serial.print("\t current = " );
Serial.println(Irms);

lcd.setCursor(0,1);

lcd.print(sensorValue*0.00488);
lcd.print("V");
lcd.print(" ");
lcd.print(Irms);
lcd.print("A");

if (Irms > 8.00)
{
Serial.println("#Overcurrent!!! Attention required.#");
(sms.SendSMS("+60164113534", "Overcurrent!!! Attention required."));
Serial.println("#SMS sent OK#");
delay(60000);
}

else
{
Serial.println("#Safe situation#");
delay(2000);
}
}

Please read this post.

Which pins do you use to communicate with the GSM shield?

Thanks for the reminder :slight_smile:
I just connect the sim900 and arduino this way..

I just connect the sim900 and arduino like this

400px-Plug_GPRS_to_arduino.jpg

Hopefully anyone can help. Thanks.

How? Nothing in the code you posted has anything to do with an LCD. In response to a question about which pins you are using to talk to the GSM device, you posted a picture.

You are going to have to do better than that.

Post the code that tries to use an LCD, so we can see which pins it uses. Post a link to the GSM shield you are using, so we can see what pins it uses. If the shield has jumpers, tell us where the hell they are positioned.