Membuat Alat Monitoring Suhu dan Kelembaban Berbasis SMS Gateway
Pada penjelasan kali ini saya akan menerangkan mengenai bagaimana membuat sebuah alat yang berfungsi untuk mengendalikan pompa atau peralatan lain berdasarkan set point yang telah diberikan, alat ini akan mengirimkan sms jika suhu melebihi nilai set point dan kelembaban kurang dari set point, alat ini jika kita SMS ke nomer yang ada di alat dengan tulisan "monitor" maka alat akan mengirimkan pesan balik ke nomer handphone pengirim dengan isinya berupa nilai suhu dan kelembaban. alat ini dilengkapi dengan 4 buah button untuk set nilai batas atas suhu dan batas bawah kelembaban. untuk lebih jelasnya berikut adalah program dan skemanya.
a. Arduino Uno
b. Modul SMS SIM800L
c. Rangkain Driver kontroller AC
d. Program Arduino IDE
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;
#include "Wire.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
#include "DHT.h"
#define DHTPIN 4 // what digital pin we're connected to
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const int tbset = 11;
const int tbnext = 9;
const int tbdown = 10;
const int tbup = 12;
int butset = 0;
int butnext = 0;
int butup = 0;
int butdown = 0;
int z = 0;
int zz = 0;
int settemp;
int sethum;
int v;
int batassuhu;
int batashum;
char string[160];
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
void setup() {
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(2400)) {
Serial.println("\nstatus=READY");
started=true;
} else Serial.println("\nstatus=IDLE");
// if(started) {
//Enable this two lines if you want to send an SMS.
// if (sms.SendSMS("085726496643", "Arduino SMS"))
//Serial.println("\nSMS sent OK");
// }
lcd.begin(16, 2);
lcd.clear();
lcd.noCursor();
pinMode(13,OUTPUT);
pinMode(tbset,INPUT);
pinMode(tbnext,INPUT);
pinMode(tbdown,INPUT);
pinMode(tbup,INPUT);
dht.begin();
digitalWrite(tbset,HIGH);
digitalWrite(tbnext,HIGH);
digitalWrite(tbup,HIGH);
digitalWrite(tbdown,HIGH);
digitalWrite(13,LOW);
}
void loop() {
v = 0;
delay(2000);
int h = dht.readHumidity();
int t = dht.readTemperature();
int hic = dht.computeHeatIndex(t, h, false);
lcd.setCursor(0, 0);
lcd.print("Temp= ");
lcd.print(t);
lcd.print(" C");
lcd.setCursor(13, 0);
lcd.print(settemp);
lcd.setCursor(0, 1);
lcd.print("hum= ");
lcd.print(h);
lcd.print(" %");
lcd.setCursor(13, 1);
lcd.print(sethum);
butset = digitalRead(tbset);
if(butset == LOW){
delay(500);
lcd.clear();
settingsuhu();
}
if((t < settemp)&&(z == 1)){
z = 0;
digitalWrite(13,LOW);
}
if((h < sethum)&&(zz == 1)){
digitalWrite(13,LOW);
zz = 0;
}
if((t > settemp)&&(settemp > 0)&&(z == 0)){
if (sms.SendSMS("085726496000", "Suhu Melebihi Batas"))
digitalWrite(13,HIGH);
z = 1;
}
if((h < sethum)&&(sethum > 0)&&(zz == 0)){
if (sms.SendSMS("085726496000", "Kelembaban Melebihi Batas"))
digitalWrite(13,HIGH);
zz = 1;
}
sprintf(string,"Temperature: %d Humidity: %d ", t, h );
if(gsm.begin(9600)){
started=true;
}
int pos=0;
if(started){
pos=sms.IsSMSPresent(SMS_ALL);
if(pos){
sms.GetSMS(pos,n,smsbuffer,100);
if(!strcmp(smsbuffer,"monitor")){
sms.SendSMS(n,string);
}
delsms();
}
}
delay(100);
}
void delsms()
{
for (int i=0; i<10; i++)
{
int pos=sms.IsSMSPresent(SMS_ALL);
if (pos!=0)
{
if (sms.DeleteSMS(pos)==1){}else{}
}
}
}
void settingsuhu(){
lcd.setCursor(0, 0);
lcd.print(" SETTING TEMP ");
lcd.setCursor(0, 1);
lcd.print("TEMP= ");
lcd.print(batassuhu);
butup = digitalRead(tbup);
butdown = digitalRead(tbdown);
butnext = digitalRead(tbnext);
if(butup == LOW){
delay(200);
batassuhu++;
}
if(butdown == LOW){
delay(200);
batassuhu--;
}
if(butnext == LOW){
delay(200);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("LOADING......");
delay(2000);
lcd.clear();
settemp = batassuhu;
settinghum();
}
if(v == 1){
return;
}
settingsuhu();
}
void settinghum(){
lcd.setCursor(0, 0);
lcd.print("SETTING HUMIDITY");
lcd.setCursor(0, 1);
lcd.print("Hum= ");
lcd.print(batashum);
butup = digitalRead(tbup);
butdown = digitalRead(tbdown);
butnext = digitalRead(tbnext);
if(butup == LOW){
delay(200);
batashum++;
}
if(butdown == LOW){
delay(200);
batashum--;
}
if(butnext == LOW){
delay(200);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("LOADING......");
delay(3000);
lcd.clear();
sethum = batashum;
v = 1;
return;
}
settinghum();
}
e. CONTOH SMS
e. VIDEO ALATNYA
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :