Arduino UNO controls the lights which connected to relay by SMS. If you want to turn on the light no.1 just enough type SMS "1 on" then lights no.1 turns on the microcontroller read the light sensor, if the light is on, then the microcontroller reply to the SMS with "Lamp 1 ON" if it is not lit then the contents of replies "Lamp 1 OFF ". Meanwhile, to turn off the lights 1 enough with SMS "1 off" later also there SMS replies. Likewise for the other lamp controls to stay changed which lights will be in control.
Hardware Requirement
- Arduino Uno Board
- 4 Channel Relay
- SIM900A GSM Module (you can also use Wavecom)
- LCD 16*2 or 20*4 (with i2c connection is recomended)
- Power supply +5 Volt
- Jumper
SIM900A | Source
Schematic (GSM Module = Wavecom)
If using SIM900A, then no RS232 circuit, just connect to Arduino.
(Alternative) Diagram Blok B --> Wavecom(Alternative) Schematic B
Arduino - LCD 16x2
Arduino - LCD 20x4
If using 20x4 LCD and I2C connection (I Square C) then the wiring table is as follows
Learn more about I2C connections --> Project V - 14
Arduino - Relay
(Alternative) Arduino - LDR
Arduino - Wavecom GSM Module
Arduino - SIM900A
Source Code --> Wavecom
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
LiquidCrystal lcd(2,3, 4, 5, 6, 7);
const int rxpin = 8;
const int txpin = 9;
SoftwareSerial gsm(rxpin, txpin);
String inString="";
String inString2="";
String Stemp="";
String inbox="";
String noPengirim="";
String Sensor="";
String Sensor1="";
String Sensor2="";
String Sensor3="";
String Sensor4="";
char str,f;
int i,j;
void setup() {
gsm.begin(9600);
lcd.begin(16,2);
lcd.print("Kontrol 4 Lampu");
lcd.setCursor(0,1);
lcd.print(" Via SMS");
delay(2000);
lcd.clear();
lcd.print("Tes Koneksi...");
delay(1000);
gsm.println("AT");
getmodem();
getmodem();
lcd.setCursor(0, 1);
lcd.print(inString);
lcd.clear();
lcd.print(" Koneksi OK ");
delay(2000);
//--------------------------dig output Relay
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
digitalWrite(A0, 0);
digitalWrite(A1, 0);
digitalWrite(A2, 0);
digitalWrite(A3, 0);
//--------------------------dig input baca LDR
pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);
pinMode(13, INPUT);
//--------------------------pull up
digitalWrite(10, 1);
digitalWrite(11, 1);
digitalWrite(12, 1);
digitalWrite(13, 1);
}
//=============================program utama
void loop() {
lcd.begin(16,2);
lcd.print("SMS Control 4Rly");
lcd.setCursor(0,1);
lcd.print("Tunggu SMS masuk");
//----------------------data ENTER
getmodem();
lcd.begin(16,2);
lcd.print("SMS Masuk...");
//----------------------data CMTI:
getmodem2();
i=inString2.indexOf(':');
if(i>0){
Stemp=inString2.substring(0,i);
if(Stemp=="+CMTI"){
i=inString2.indexOf(',');
j=inString2.length ();
i=i+1;
inbox=inString2.substring(i,j);
gsm.print("AT+CMGR=");
gsm.println(inbox);
getmodem();
getmodem();
getmodem2();
i=inString.indexOf(',');
i=i+2;
j=inString.indexOf(',',i);
j=j-1;
noPengirim=inString.substring(i,j);
//----------------------------------------------------Relay ON
if(inString2=="1 on"){
digitalWrite(A0,1);
delay(200);
baca_sensor1();
kirim_sms();
}
else if(inString2=="2 on"){
digitalWrite(A1,1);
delay(200);
baca_sensor2();
kirim_sms();
}
else if(inString2=="3 on"){
digitalWrite(A2,1);
delay(200);
baca_sensor3();
kirim_sms();
}
else if(inString2=="4 on"){
digitalWrite(A3,1);
delay(200);
baca_sensor4();
kirim_sms();
}
//---------------------------------------------isi SMS "All on"
else if(inString2=="All on"){
digitalWrite(A0,1);
digitalWrite(A1,1);
digitalWrite(A2,1);
digitalWrite(A3,1);
delay(200);
baca_all_sensor();
kirim_all_sms();
}
//----------------------------------------------------Relay OFF
else if(inString2=="1 off"){
digitalWrite(A0,0);
delay(200);
baca_sensor1();
kirim_sms();
}
else if(inString2=="2 off"){
digitalWrite(A1,0);
delay(200);
baca_sensor2();
kirim_sms();
}
else if(inString2=="3 off"){
digitalWrite(A2,0);
delay(200);
baca_sensor3();
kirim_sms();
}
else if(inString2=="4 off"){
digitalWrite(A3,0);
delay(200);
baca_sensor4();
kirim_sms();
}
//-------------------------------------------isi SMS "All off"
else if(inString2=="All off"){
digitalWrite(A0,0);
digitalWrite(A1,0);
digitalWrite(A2,0);
digitalWrite(A3,0);
delay(200);
baca_all_sensor();
kirim_all_sms();
}
//-----------------------------------------------isi SMS "Cek"
else if(inString2=="Cek"){
baca_all_sensor();
kirim_all_sms();
}
//--------------------------------------------------other sms
else {
gsm.print("AT+CMGS=");
gsm.println(noPengirim);
delay(1000);
gsm.print("Format Salah!");
gsm.write((byte)26);
gsm.println();
lcd.clear();
lcd.print("Format Salah!");
}
delay(3000);
lcd.begin(16,2);
lcd.print("Hapus SMS:");
//-------------------------hapus inbox
getmodem();
getmodem();
gsm.print("AT+CMGD=");
gsm.println(inbox);
do{
getmodem();
}
while(inString != "OK");
lcd.print(inbox);
lcd.setCursor(0,1);
lcd.print(inString);
delay(3000);
}
}
}
//====================================baca data serial
void getmodem()
{
f=1;
inString="";
while(f)
{
if(gsm.available())
{
str=gsm.read();
switch (str)
{
case '\r': break;
case '\n':f=0; break;
default:inString+=(char)str;
}
}
}
}
//====================================
void getmodem2()
{
f=1;
inString2="";
while(f)
{
if(gsm.available()>0)
{
str=gsm.read();
switch (str)
{
case '\r': break;
case '\n':f=0; break;
default:inString2+=(char)str;
}
}
}
}
//===================================baca sensor 1
void baca_sensor1(){
if (digitalRead(10) == 0){
Sensor="Lampu 1= ON ";
}
else{
Sensor="Lampu 1= OFF";
}
}
//====================================baca sensor 2
void baca_sensor2(){
if (digitalRead(11) == 0){
Sensor="Lampu 2= ON ";
}
else{
Sensor="Lampu 2= OFF";
}
}
//====================================baca sensor 3
void baca_sensor3(){
if (digitalRead(12) == 0){
Sensor="Lampu 3= ON ";
}
else{
Sensor="Lampu 3= OFF";
}
}
//====================================baca sensor 4
void baca_sensor4(){
if (digitalRead(13) == 0){
Sensor="Lampu 4= ON ";
}
else{
Sensor="Lampu 4= OFF";
}
}
//====================================baca semua sensor
void baca_all_sensor(){
delay(1000);
if (digitalRead(11) == 0){
Sensor2="ON ";
}
else{
Sensor2="OFF";
}
if (digitalRead(12) == 0){
Sensor3="ON ";
}
else{
Sensor3="OFF";
}
if (digitalRead(13) == 0){
Sensor4="ON ";
}
else{
Sensor4="OFF";
}
if (digitalRead(10) == 0){
Sensor1="ON ";
}
else{
Sensor1="OFF";
}
}
//====================================kirim SMS
void kirim_sms(){
gsm.print("AT+CMGS=");
gsm.println(noPengirim);
delay(1000);
gsm.print(Sensor);
gsm.write((byte)26);
gsm.println();
lcd.begin(16,2);
lcd.print(Sensor);
lcd.setCursor(0,1);
lcd.print("Kirim SMS....");
}
//====================================kirim Semua SMS
void kirim_all_sms(){
gsm.print("AT+CMGS=");
gsm.println(noPengirim);
delay(1000);
gsm.print("Lampu1="); gsm.print(Sensor1); gsm.print(", ");
gsm.print("Lampu2="); gsm.print(Sensor2); gsm.print(", ");
gsm.print("Lampu3="); gsm.print(Sensor3); gsm.print(", ");
gsm.print("Lampu4="); gsm.print(Sensor4); gsm.print(".");
gsm.write((byte)26);
gsm.println();
lcd.begin(16,2);
lcd.print("Kirim SMS....");
delay(1000);
lcd.begin(16,2);
lcd.print("L1:"); lcd.print(Sensor1);
lcd.print(" L2:"); lcd.print(Sensor2);
lcd.setCursor(0, 1);
lcd.print("L3:"); lcd.print(Sensor3);
lcd.print(" L4:"); lcd.print(Sensor4);
lcd.setCursor(0,1);
}
#include <SoftwareSerial.h>
LiquidCrystal lcd(2,3, 4, 5, 6, 7);
const int rxpin = 8;
const int txpin = 9;
SoftwareSerial gsm(rxpin, txpin);
String inString="";
String inString2="";
String Stemp="";
String inbox="";
String noPengirim="";
String Sensor="";
String Sensor1="";
String Sensor2="";
String Sensor3="";
String Sensor4="";
char str,f;
int i,j;
void setup() {
gsm.begin(9600);
lcd.begin(16,2);
lcd.print("Kontrol 4 Lampu");
lcd.setCursor(0,1);
lcd.print(" Via SMS");
delay(2000);
lcd.clear();
lcd.print("Tes Koneksi...");
delay(1000);
gsm.println("AT");
getmodem();
getmodem();
lcd.setCursor(0, 1);
lcd.print(inString);
lcd.clear();
lcd.print(" Koneksi OK ");
delay(2000);
//--------------------------dig output Relay
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
digitalWrite(A0, 0);
digitalWrite(A1, 0);
digitalWrite(A2, 0);
digitalWrite(A3, 0);
//--------------------------dig input baca LDR
pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);
pinMode(13, INPUT);
//--------------------------pull up
digitalWrite(10, 1);
digitalWrite(11, 1);
digitalWrite(12, 1);
digitalWrite(13, 1);
}
//=============================program utama
void loop() {
lcd.begin(16,2);
lcd.print("SMS Control 4Rly");
lcd.setCursor(0,1);
lcd.print("Tunggu SMS masuk");
//----------------------data ENTER
getmodem();
lcd.begin(16,2);
lcd.print("SMS Masuk...");
//----------------------data CMTI:
getmodem2();
i=inString2.indexOf(':');
if(i>0){
Stemp=inString2.substring(0,i);
if(Stemp=="+CMTI"){
i=inString2.indexOf(',');
j=inString2.length ();
i=i+1;
inbox=inString2.substring(i,j);
gsm.print("AT+CMGR=");
gsm.println(inbox);
getmodem();
getmodem();
getmodem2();
i=inString.indexOf(',');
i=i+2;
j=inString.indexOf(',',i);
j=j-1;
noPengirim=inString.substring(i,j);
//----------------------------------------------------Relay ON
if(inString2=="1 on"){
digitalWrite(A0,1);
delay(200);
baca_sensor1();
kirim_sms();
}
else if(inString2=="2 on"){
digitalWrite(A1,1);
delay(200);
baca_sensor2();
kirim_sms();
}
else if(inString2=="3 on"){
digitalWrite(A2,1);
delay(200);
baca_sensor3();
kirim_sms();
}
else if(inString2=="4 on"){
digitalWrite(A3,1);
delay(200);
baca_sensor4();
kirim_sms();
}
//---------------------------------------------isi SMS "All on"
else if(inString2=="All on"){
digitalWrite(A0,1);
digitalWrite(A1,1);
digitalWrite(A2,1);
digitalWrite(A3,1);
delay(200);
baca_all_sensor();
kirim_all_sms();
}
//----------------------------------------------------Relay OFF
else if(inString2=="1 off"){
digitalWrite(A0,0);
delay(200);
baca_sensor1();
kirim_sms();
}
else if(inString2=="2 off"){
digitalWrite(A1,0);
delay(200);
baca_sensor2();
kirim_sms();
}
else if(inString2=="3 off"){
digitalWrite(A2,0);
delay(200);
baca_sensor3();
kirim_sms();
}
else if(inString2=="4 off"){
digitalWrite(A3,0);
delay(200);
baca_sensor4();
kirim_sms();
}
//-------------------------------------------isi SMS "All off"
else if(inString2=="All off"){
digitalWrite(A0,0);
digitalWrite(A1,0);
digitalWrite(A2,0);
digitalWrite(A3,0);
delay(200);
baca_all_sensor();
kirim_all_sms();
}
//-----------------------------------------------isi SMS "Cek"
else if(inString2=="Cek"){
baca_all_sensor();
kirim_all_sms();
}
//--------------------------------------------------other sms
else {
gsm.print("AT+CMGS=");
gsm.println(noPengirim);
delay(1000);
gsm.print("Format Salah!");
gsm.write((byte)26);
gsm.println();
lcd.clear();
lcd.print("Format Salah!");
}
delay(3000);
lcd.begin(16,2);
lcd.print("Hapus SMS:");
//-------------------------hapus inbox
getmodem();
getmodem();
gsm.print("AT+CMGD=");
gsm.println(inbox);
do{
getmodem();
}
while(inString != "OK");
lcd.print(inbox);
lcd.setCursor(0,1);
lcd.print(inString);
delay(3000);
}
}
}
//====================================baca data serial
void getmodem()
{
f=1;
inString="";
while(f)
{
if(gsm.available())
{
str=gsm.read();
switch (str)
{
case '\r': break;
case '\n':f=0; break;
default:inString+=(char)str;
}
}
}
}
//====================================
void getmodem2()
{
f=1;
inString2="";
while(f)
{
if(gsm.available()>0)
{
str=gsm.read();
switch (str)
{
case '\r': break;
case '\n':f=0; break;
default:inString2+=(char)str;
}
}
}
}
//===================================baca sensor 1
void baca_sensor1(){
if (digitalRead(10) == 0){
Sensor="Lampu 1= ON ";
}
else{
Sensor="Lampu 1= OFF";
}
}
//====================================baca sensor 2
void baca_sensor2(){
if (digitalRead(11) == 0){
Sensor="Lampu 2= ON ";
}
else{
Sensor="Lampu 2= OFF";
}
}
//====================================baca sensor 3
void baca_sensor3(){
if (digitalRead(12) == 0){
Sensor="Lampu 3= ON ";
}
else{
Sensor="Lampu 3= OFF";
}
}
//====================================baca sensor 4
void baca_sensor4(){
if (digitalRead(13) == 0){
Sensor="Lampu 4= ON ";
}
else{
Sensor="Lampu 4= OFF";
}
}
//====================================baca semua sensor
void baca_all_sensor(){
delay(1000);
if (digitalRead(11) == 0){
Sensor2="ON ";
}
else{
Sensor2="OFF";
}
if (digitalRead(12) == 0){
Sensor3="ON ";
}
else{
Sensor3="OFF";
}
if (digitalRead(13) == 0){
Sensor4="ON ";
}
else{
Sensor4="OFF";
}
if (digitalRead(10) == 0){
Sensor1="ON ";
}
else{
Sensor1="OFF";
}
}
//====================================kirim SMS
void kirim_sms(){
gsm.print("AT+CMGS=");
gsm.println(noPengirim);
delay(1000);
gsm.print(Sensor);
gsm.write((byte)26);
gsm.println();
lcd.begin(16,2);
lcd.print(Sensor);
lcd.setCursor(0,1);
lcd.print("Kirim SMS....");
}
//====================================kirim Semua SMS
void kirim_all_sms(){
gsm.print("AT+CMGS=");
gsm.println(noPengirim);
delay(1000);
gsm.print("Lampu1="); gsm.print(Sensor1); gsm.print(", ");
gsm.print("Lampu2="); gsm.print(Sensor2); gsm.print(", ");
gsm.print("Lampu3="); gsm.print(Sensor3); gsm.print(", ");
gsm.print("Lampu4="); gsm.print(Sensor4); gsm.print(".");
gsm.write((byte)26);
gsm.println();
lcd.begin(16,2);
lcd.print("Kirim SMS....");
delay(1000);
lcd.begin(16,2);
lcd.print("L1:"); lcd.print(Sensor1);
lcd.print(" L2:"); lcd.print(Sensor2);
lcd.setCursor(0, 1);
lcd.print("L3:"); lcd.print(Sensor3);
lcd.print(" L4:"); lcd.print(Sensor4);
lcd.setCursor(0,1);
}
Coding --> Sim900A (Recomended)
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
#include <GPRS_Shield_Arduino.h>
LiquidCrystal_I2C lcd(0x3F, 20, 4);
#define PIN_TX 9
#define PIN_RX 8
#define BAUDRATE 9600
#define PHONE_NUMBER "085714112026"// sesuaikan
#define relay_1on "Relay 1 On"
#define relay_2on "Relay 2 On"
#define relay_3on "Relay 3 On"
#define relay_4on "Relay 4 On"
#define relay_1off "Relay 1 Off"
#define relay_2off "Relay 2 Off"
#define relay_3off "Relay 3 Off"
#define relay_4off "Relay 4 Off"
#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
int messageIndex = 0;
char data[50];
char phone[16];
char datetime[24];
GPRS gprsTest(PIN_TX, PIN_RX, BAUDRATE); //RX,TX,BaudRate
void setup() {
lcd.begin();
lcd.setCursor(0, 0);
lcd.print("Initialization...");
delay(1000);
Serial.begin(9600);
while (!gprsTest.init()) {
delay(1000);
lcd.setCursor(0, 1);
lcd.print("init error\r\n");
}
lcd.setCursor(0, 2);
lcd.println("gprs init success");
delay(2000);
lcd.clear();
//--------------------------dig output Relay
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
digitalWrite(A0, 1);
digitalWrite(A1, 1);
digitalWrite(A2, 1);
digitalWrite(A3, 1);
}
//============================================program utama
void loop() {
lcd.setCursor(0, 0);
lcd.print(" Remote 4 Relay");
lcd.setCursor(0, 1);
lcd.print(" System is Ready");
lcd.setCursor(0, 2);
lcd.print(" Waiting ");
//----------------------data CMTI:
messageIndex = gprsTest.isSMSunread();
if (messageIndex > 0) { //At least, there is one UNREAD SMS
gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
//----------------------data ENTER
lcd.setCursor(0, 2);
lcd.print(" 1 New Message ");
//In order not to full SIM Memory, is better to delete it
gprsTest.deleteSMS(messageIndex);
if (String(message) == "1 on")
{
lcd.setCursor(0, 3);
lcd.print(" Relay 1 On");
digitalWrite(A0, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_1on);
}
else if (String(message) == "2 on") {
lcd.setCursor(0, 3);
lcd.print(" Relay 2 On");
digitalWrite(A1, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_2on);
}
else if (String(message) == "3 on") {
lcd.setCursor(0, 3);
lcd.print(" Relay 3 On");
digitalWrite(A2, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_3on);
}
else if (String(message) == "4 on") {
lcd.setCursor(0, 3);
lcd.print(" Relay 4 On");
digitalWrite(A3, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_4on);
}
//-------------------------isi SMS "1 off"
else if (String(message) == "1 off") {
lcd.setCursor(0, 3);
lcd.print(" Relay 1 Off");
digitalWrite(A0, 1);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_1off);
}
//-------------------------isi SMS "2 off"
else if (String(message) == "2 off") {
lcd.setCursor(0, 3);
lcd.print(" Relay 2 Off");
digitalWrite(A1, 1);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_2off);
}
else if (String(message) == "3 off") {
lcd.setCursor(0, 3);
lcd.print(" Relay 3 Off");
digitalWrite(A2, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_3off);
}
else if (String(message) == "4 off") {
lcd.setCursor(0, 3);
lcd.print(" Relay 4 Off");
digitalWrite(A3, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_4off);
}
lcd.setCursor(0, 2);
lcd.print(" Sending a Message");
delay(3000);
lcd.clear();
}
}
#include <SoftwareSerial.h>
#include <GPRS_Shield_Arduino.h>
LiquidCrystal_I2C lcd(0x3F, 20, 4);
#define PIN_TX 9
#define PIN_RX 8
#define BAUDRATE 9600
#define PHONE_NUMBER "085714112026"// sesuaikan
#define relay_1on "Relay 1 On"
#define relay_2on "Relay 2 On"
#define relay_3on "Relay 3 On"
#define relay_4on "Relay 4 On"
#define relay_1off "Relay 1 Off"
#define relay_2off "Relay 2 Off"
#define relay_3off "Relay 3 Off"
#define relay_4off "Relay 4 Off"
#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
int messageIndex = 0;
char data[50];
char phone[16];
char datetime[24];
GPRS gprsTest(PIN_TX, PIN_RX, BAUDRATE); //RX,TX,BaudRate
void setup() {
lcd.begin();
lcd.setCursor(0, 0);
lcd.print("Initialization...");
delay(1000);
Serial.begin(9600);
while (!gprsTest.init()) {
delay(1000);
lcd.setCursor(0, 1);
lcd.print("init error\r\n");
}
lcd.setCursor(0, 2);
lcd.println("gprs init success");
delay(2000);
lcd.clear();
//--------------------------dig output Relay
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
digitalWrite(A0, 1);
digitalWrite(A1, 1);
digitalWrite(A2, 1);
digitalWrite(A3, 1);
}
//============================================program utama
void loop() {
lcd.setCursor(0, 0);
lcd.print(" Remote 4 Relay");
lcd.setCursor(0, 1);
lcd.print(" System is Ready");
lcd.setCursor(0, 2);
lcd.print(" Waiting ");
//----------------------data CMTI:
messageIndex = gprsTest.isSMSunread();
if (messageIndex > 0) { //At least, there is one UNREAD SMS
gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
//----------------------data ENTER
lcd.setCursor(0, 2);
lcd.print(" 1 New Message ");
//In order not to full SIM Memory, is better to delete it
gprsTest.deleteSMS(messageIndex);
if (String(message) == "1 on")
{
lcd.setCursor(0, 3);
lcd.print(" Relay 1 On");
digitalWrite(A0, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_1on);
}
else if (String(message) == "2 on") {
lcd.setCursor(0, 3);
lcd.print(" Relay 2 On");
digitalWrite(A1, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_2on);
}
else if (String(message) == "3 on") {
lcd.setCursor(0, 3);
lcd.print(" Relay 3 On");
digitalWrite(A2, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_3on);
}
else if (String(message) == "4 on") {
lcd.setCursor(0, 3);
lcd.print(" Relay 4 On");
digitalWrite(A3, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_4on);
}
//-------------------------isi SMS "1 off"
else if (String(message) == "1 off") {
lcd.setCursor(0, 3);
lcd.print(" Relay 1 Off");
digitalWrite(A0, 1);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_1off);
}
//-------------------------isi SMS "2 off"
else if (String(message) == "2 off") {
lcd.setCursor(0, 3);
lcd.print(" Relay 2 Off");
digitalWrite(A1, 1);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_2off);
}
else if (String(message) == "3 off") {
lcd.setCursor(0, 3);
lcd.print(" Relay 3 Off");
digitalWrite(A2, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_3off);
}
else if (String(message) == "4 off") {
lcd.setCursor(0, 3);
lcd.print(" Relay 4 Off");
digitalWrite(A3, 0);
delay(2000);
gprsTest.sendSMS(PHONE_NUMBER, relay_4off);
}
lcd.setCursor(0, 2);
lcd.print(" Sending a Message");
delay(3000);
lcd.clear();
}
}
How it Works
1. Connect the Arduino with Peripherals needed.
2. Plug in the Power Source on the device.
3. Add some library if needed
4. Compile and upload the script program5. First, Modem will initialize and it takes about 3 seconds
4. When receiving SMS with certain format then LCD will display
5. Then will execute the command and directly send SMS feed back
6. 7. After sending SMS message, lcd will return to normal view
Video for Project III - 4. Controlling 4 Channel of Relay using SMS with Feedback based On Arduino
Required file
No comments:
Post a Comment