Translate

MONITOR SUHU DAN KELEMBABAN DHT22 SMS GATEWAY SIM900A ARDUINO

MONITOR SUHU DAN KELEMBABAN DHT22 SMS GATEWAY SIM900A ARDUINO


            Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk monitoring suhu dan kelembaban dengan sensor dht22 via sms gateway, jadi alat ini akan mengirimkan sms setiap 1 jam sekali ke handphone yang dituju, alat ini dilengkapi dengan RTC sehingga untuk waktu bisa lebih akurat. untuk lebih jelasnya berikut adalah daftar komponen dan programnya.  



a. Arduino Uno




b. Modul SMS SIM900A




c. RTC DS3231




d. Sensor DHT22




e. LCD + I2C






f. Program Arduino IDE

#include "Wire.h"
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#include "SIM900.h"
#include <SoftwareSerial.h>

#include "sms.h"
SMSGSM sms;

#define DHTPIN 8     // what digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22
#define DS3231_I2C_ADDRESS 0x68

DHT dht(DHTPIN, DHTTYPE);

LiquidCrystal_I2C lcd(0x27, 16, 2);

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;



// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}

byte savejam;

int mark = 0;
char string[160];

int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];

int tanda = 0;
int tanda2 = 0;

void setup() {

  lcd.begin();
  lcd.clear();
  lcd.noCursor();

   lcd.setCursor(0,0);
   lcd.print("LOADING......");
 
     //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) {
         if (sms.SendSMS("085123123123", "Alat Ready"))
          Serial.println("\nSMS sent OK");
     }

  dht.begin();
  Serial.begin(9600);
   while (!Serial) {
  }

  lcd.clear();

    Wire.begin();
  // set the initial time here:
  // DS3231 seconds, minutes, hours, day, date, month, year
   setDS3231time(0,59,5,6,23,11,18);

}


void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)
{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}
void displayTime()
{
  lcd.setCursor(0,1);
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  lcd.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  lcd.print(":");
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);
  lcd.print(" ");
  Serial.print(dayOfMonth, DEC);
  Serial.print("/");
  Serial.print(month, DEC);
  Serial.print("/");
  Serial.print(year, DEC);
  Serial.print(" Day of week: ");
  switch(dayOfWeek){
  case 1:
    Serial.println("Sunday");
    break;
  case 2:
    Serial.println("Monday");
    break;
  case 3:
    Serial.println("Tuesday");
    break;
  case 4:
    Serial.println("Wednesday");
    break;
  case 5:
    Serial.println("Thursday");
    break;
  case 6:
    Serial.println("Friday");
    break;
  case 7:
    Serial.println("Saturday");
    break;
  }
}

void loop(){
 displayTime();
 int h = dht.readHumidity();
 int t = dht.readTemperature();
 int f = dht.readTemperature(true);

 int hum = h ;
 int suhu = t;

 sprintf(string,"suhu = %d dan kelembaban = %d ", t , h);

  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  float hif = dht.computeHeatIndex(f, h);
  float hic = dht.computeHeatIndex(t, h, false);

   lcd.setCursor(0,0);
   lcd.print("s/h=");
   lcd.print(suhu);
   lcd.print("/");
   lcd.print(hum);
   lcd.print("        ");


 if(hour != savejam){ 
   Serial.println("KIRIM SMS");
   if (sms.SendSMS("085123123123", string));
   savejam = hour;
   }
  
 if(suhu > 60){
 if (sms.SendSMS("085123123123", "TANDA BAHAYA SUHU > 60"))
 Serial.println("\nSMS sent OK");
 }

 if(hum < 15){
 if (sms.SendSMS("085123123123", "TANDA BAHAYA KELEMBABAN < 15"))
 Serial.println("\nSMS sent OK");
 }

 delay(1000);
 
}
 




g. VIDEO HASILNYA








Simulasi Proteus Monitor Suhu lm35 dan Jam digital RTC BASCOM AVR

Simulasi Proteus Monitor Suhu lm35 dan Jam digital RTC BASCOM AVR


         Pada kesempatan kali ini saya akan menejelaskan mengenai bagaimana cara menampilkan nilau suhu menggunakan simulasi proteus dan juga menampilkan jam digital dengan RTC. simulasi ini menggunakan Proteus 7 dan program menggunakan Bascom AVR. untuk lebih jelasnya berikut adalah programnya.



a. Program Bascom AVR

$regfile = "m16def.dat"
$crystal = 12000000
$baud = 9600

$lib "ds1307clock.lib"

Config Lcdpin = Pin , Rs = Portc.6 , E = Portc.7 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc

Cls
Cursor Off

Dim Dataadc As Word
Dim Suhu As Single

Config Sda = Portc.1
Config Scl = Portc.0
Const Ds1307w = &HD0
Const Ds1307r = &HD1

Config Clock = User

Dim Weekday As Byte
Dim Char As String * 10 , Tanda As String * 1
Dim Jam As String * 10 , Menit As String * 10 , Detik As String * 10
Dim Hari As String * 10 , Bulan As String * 10 , Tahun As String * 10
Dim A As Byte , B As Byte , C As Byte
Dim X As Byte , Y As Byte , Z As Byte
Dim Waktu As String * 10
Dim Tanggal As String * 10

Time$ = "15:30:00"
Date$ = "04-30-11"

_hour = 7
_min = 32
_sec = 0
Gosub Settime

_day = 20
_month = 3
_year = 19
Gosub Setdate

Start Adc

Mulai:
Do

Dataadc = Getadc(0)
Suhu = Dataadc * 5
Suhu = Suhu / 1023
Suhu = Suhu * 100

Print "Tanggal: " ; Date$
Print "Waktu:" ; Time$

Cls

Locate 1 , 1
Lcd "Waktu : " ; _hour ; "-" ; _min ; "-" ; _sec

Locate 2 , 1
Lcd "Suhu " ; Fusing(suhu , "#.##") ; " c      "

'Wait 1

Loop
End


Getdatetime:
  I2cstart
  I2cwbyte Ds1307w
  I2cwbyte 0

  I2cstart
  I2cwbyte Ds1307r
  I2crbyte _sec , Ack
  I2crbyte _min , Ack
  I2crbyte _hour , Ack
  I2crbyte Weekday , Ack
  I2crbyte _day , Ack
  I2crbyte _month , Ack
  I2crbyte _year , Nack
  I2cstop
  _sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
  _day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year)
Return

Setdate:
  _day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year)
  I2cstart
  I2cwbyte Ds1307w
  I2cwbyte 4
  I2cwbyte _day
  I2cwbyte _month
  I2cwbyte _year
  I2cstop
Return

Settime:
  _sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
  I2cstart
  I2cwbyte Ds1307w
  I2cwbyte 0
  I2cwbyte _sec
  I2cwbyte _min
  I2cwbyte _hour
  I2cstop
Return




b. VIDEO HASILNYA







ARDUINO MONITORSUHU KELEMBABAN DEBU DAN GAS SENSOR MQ-7 DHT11 DAN GP2Y1010AU0F

ARDUINO MONITORSUHU KELEMBABAN DEBU DAN GAS SENSOR MQ-7 DHT11 DAN GP2Y1010AU0F


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat berfungsi untuk monitor suhu dan gas serta debu. alat ini menggunakan Arduino sebagai mikrokontrollernya dan interfacenya menggunakan LCD. alat ini dapat dikembangkan untuk monitor udara disuatu tempat sehingga bisa terdeteksi kadarnya. untuk lebih jelasnya berikut adalah daftar komponen dan programnya.




a. Arduino Uno




b. Sensor Gas MQ-7




c. Sensor DHT11




d. Sensor Debu






e. Lcd + I2C






f. Program Arduino IDE

#include <Wire.h> //library
#include <LiquidCrystal_I2C.h>  //library lcd
#include "DHT.h"  //library dht11

#define DHTPIN 3     // pin digital untuk dht11
#define DHTTYPE DHT11   // set dht11

DHT dht(DHTPIN, DHTTYPE);  //set dht11
LiquidCrystal_I2C lcd(0x27, 16, 2);  //untuk library lcd i2c

int ledx = 2;   //untuk pin sensor debu
float ppm2;   //variabel untuk mq7
float RS_air; //  Get the value of RS via in a clear air
float R0 = 0.25;  // Get the value of R0 via in H2
float sensorValue;  // variabel bisa pecahan
float sensor_volt; // variabel bisa pecahan
float RS_gas;  //variabel bisa pecahan
float ratio;  //variabel bisa pecahan


void setup()  //prosedure
{
 dht.begin();  //mulai dht11
 lcd.begin();  //mulai lcd
 lcd.clear();  //bersihakn lcd
 lcd.noCursor();  //lcd tanpa kursor
 pinMode(ledx,OUTPUT);  //pin sebagai output
 pinMode(A3,OUTPUT);  //pin sebagai output
}


void loop()  //prosedure
{

 float h = dht.readHumidity();  //ambil data humidity
 float t = dht.readTemperature();  //ambil data suhu c
 float f = dht.readTemperature(true); //ambil data suhu f

 int hum = h;  //deklarasi variabel
 int suhu = t;  //deklaras variabel

  if (isnan(h) || isnan(t) || isnan(f)) {  //untuk koneksi dht11
    Serial.println("Failed to read from DHT sensor!");  //jika error
    return;  //maka kembali
  }

  float hif = dht.computeHeatIndex(f, h);  //untuk dht11
  float hic = dht.computeHeatIndex(t, h, false);  //untuk dht11


//aktif low
//GP2Y1010AU0F_SAMPLEDELAY should be 280us to perform the correct reading
//this delay should consider that ADC conversion takes 13 ADC clock cycles
//ADCtime(s) = (1/ADCclock)*13 = (1/FCPU/ADCprescaler)*13
// es (1/(8000000/64))*13 = 0.000104s = 104us
//so to perform reading at correct time
//280 - (1/FCPU/ADCprescaler)*13*1000000   , 1000000 is the conversion factor from s to us
// es. 280 - 104 = 176

digitalWrite(ledx,LOW);    //pin on
delayMicroseconds(176);  //delay

int dataadc = analogRead(A0);  //ambil adc
delayMicroseconds(40);  //delay

digitalWrite(ledx,HIGH);   //pin off
delayMicroseconds(9680);  //delay

float v = dataadc * (5.0 / 1023.0);    //untuk dikonvert ke tegangan

//y = 0.166x - 0.129   //rumus
float Dustval = (v * 0.166) - 0.129;  //rumus sensor debu
delay(80);  //delay

gasmq7();  //ambil data gas mq7

  lcd.setCursor(0,0);  //untuk menampilkan d baris atas
  lcd.print("S=");  //menulis huruf
  lcd.print(suhu); //menulis suhu
  lcd.print(" / ");  //menulis tanda /
  lcd.print("P=");  //menulis p
  lcd.print(ppm2); //menulis nilai sensor gas
  lcd.print("     "); //spasi

  lcd.setCursor(0,1);  //untuk menulis d lcd bawah
  lcd.print("Dust= "); //menulis variabel
  lcd.print(Dustval); //menulis nilai
  lcd.print(" mg/m3");  //menulis variabel

}

void gasmq7(){  //prosedure

analogWrite(A3, 1023);  //untuk mengeluarkan tegangan
//Heather 1.4 V 90 s 
    analogWrite(A3, (1023/5)*1.4 );  //untuk mengeluarkan tegangan
    //for(int i = 0; i<90; i++){     
        sensorValue = analogRead(A1);  //untuk ambil adc sensor mq7
        sensor_volt = sensorValue/1024*5.0;  //untuk menjadi tegangan
        RS_gas = (5.0-sensor_volt)/sensor_volt;  //untuk rumus
        ratio = RS_gas/R0; //Replace R0 with the value found using the calibration code
        float kal = 83.39 / ratio;  //untuk rumus
        ppm2 = pow(kal , 0.63);       //untuk jadi ppm
        delay(100);  //delay
    //}

}





g. VIDEO HASILNYA















Nodemcu ESP8266 Jam Digital RTC DS3231 Interface LCD 20x4

Nodemcu ESP8266 Jam Digital RTC DS3231 Interface LCD 20x4


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfung sebagai jam digital dengan nterface LCD. alat ini dilengkapi dengan RTC DS3231 modul sehingga akurasi waktu bisa terjaga biarpun mikrokontroller dalam keadaan OFF. alat ini menggunakan Nodemcu sebagai mikrokontrollernya. untuk lebih jelasnya berikut adalah program dan daftar komponennya.



a. Nodemcu ESP8266




b. Module RTC DS3231




c. LCD + I2C






d. Program Arduino IDE 

#include "Wire.h"
#include <LiquidCrystal_I2C.h>
#define DS3231_I2C_ADDRESS 0x68

LiquidCrystal_I2C lcd(0x3F, 16, 2);
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;


// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}


void setup() {

  lcd.begin();
  lcd.clear();
  lcd.noCursor();

  Wire.begin();
  // set the initial time here:
  // DS3231 seconds, minutes, hours, day, date, month, year
   setDS3231time(0,47,11,6,23,11,18);

}


void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)
{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}
void displayTime()
{
  lcd.setCursor(0,0);
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  lcd.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  lcd.print(":");
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);
  lcd.print(" ");
 
  lcd.setCursor(0,1);
  lcd.print(dayOfMonth, DEC);
  lcd.setCursor(0,2);
  lcd.print(month, DEC);
  lcd.print(" / ");
  lcd.print(year, DEC);
  lcd.setCursor(0,3);
  //lcd.print(" Day of week: ");
 
  switch(dayOfWeek){
  case 1:
    lcd.print("Sunday");
    break;
  case 2:
    lcd.print("Monday");
    break;
  case 3:
    lcd.print("Tuesday");
    break;
  case 4:
    lcd.print("Wednesday");
    break;
  case 5:
    lcd.print("Thursday");
    break;
  case 6:
    lcd.print("Friday");
    break;
  case 7:
    lcd.print("Saturday");
    break;
  }
}

void loop(){
 displayTime();

   delay(1000);
 
}





e. VIDEO HASILNYA







NODEMCU ESP8266 MONITOR SUHU LM35 INTERFACE LCD 20X4 I2C

NODEMCU ESP8266 MONITOR SUHU LM35 INTERFACE LCD 20X4 I2C



           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa digunakan untuk memonitor suhu ruangan dengan sensor LM35. Biasanya Menggunakan Arduino namun yang berbeda disini yaitu mikrokontrollernya menggunakan Nodemcu ESP8266. untuk lebih jelasnya berikut adalah daftar komponen dan programnya.




a. Nodemcu esp8266




b. Sensor Suhu LM35




c. LCD 20x4 I2C






d. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 20, 4);

void setup() {
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  Serial.begin(9600);
}

void loop() {

    int dataadc = analogRead(A0);
    float suhu = dataadc * (3.3/1023.0)* 100.0;
    float v = dataadc * (3.3/1023.0);
    
    lcd.setCursor(0,0);
    lcd.print("Monitor ADC & SUHU");
    lcd.setCursor(0,1);
    lcd.print("ADC = ");
    lcd.print(dataadc);
    lcd.print("     ");
    lcd.setCursor(0,2);
    lcd.print("SUHU = ");
    lcd.print(suhu);
    lcd.print("     ");
    lcd.setCursor(0,3);
    lcd.print("Volt = ");
    lcd.print(v);
    lcd.print("     ");
    
    Serial.println(suhu);
    
delay(200);

}




e. VIDEO HASILNYA