Question: the codes here does not work properly by sending the message to a dedicated phone number , how can i make them to work properly

the codes here does not work properly by sending the message to a dedicated phone number , how can i make them to work properly ? by instantly sedn a message when specified conditions are met
#include
SoftwareSerial mySerial("TX","RX");
int msensor = A1;
int mvalue =0;
int relay=11;
int LED1=5;
int LED2=6;
void wait(){
delay(500);
}
void SendInformation(){
Serial.begin(9600);
Serial.println("AT");
wait();
Serial.println("AT+CMGF=1\r");//configure SIM to TEXT mode
wait();
Serial.println("AT+CMGS=\"0627410551\"");
wait();
Serial.println("Habari, Shamba lako linamwagiliwa lipo salama.");
wait();
Serial.println((char)26); // End AT command with a ^Z, ASCII code 26
Serial.flush();
}
void SendMessage()
{
Serial.begin(9600);
Serial.println("AT");
wait();
Serial.println("AT+CMGF=1\r");//configure SIM to TEXT mode
wait();
Serial.print("AT+CMGS=");
Serial.println("+255627410551");
wait();
Serial.println("Habari, shamba lako lishamwagiliwa lipo salama kuwa na
Amani.");
wait();
Serial.println((char)26); // End AT command with a ^Z, ASCII code 26
Serial.flush();
}
void setup()
{
Serial.begin(9600);
Serial.println("Karibu Drip Irrigation"); //Test the serial monitor
pinMode(msensor, INPUT);
pinMode(relay, OUTPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
}
void loop(){
mvalue = analogRead(msensor);
Serial.println(mvalue);
Serial.print("Unyevu(Moisture):");
if (mvalue>=400)
{
digitalWrite(relay, LOW);
digitalWrite(LED1, HIGH);
digitalWrite(LED2, LOW);
SendInformation();
}
else
{
SendMessage();
digitalWrite(relay, HIGH);
digitalWrite(LED1, LOW);
digitalWrite(LED2, HIGH);
delay(1000);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!