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(sensorValue0.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(sensorValue0.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);
}
}