Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Prepare a constructive performance appraisal.

Answered: 1 week ago

Question

List the advantages of correct report formatting.

Answered: 1 week ago