Translate

Membuat Alat Monitoring Ketinggian Air (Water Level) ARDUINO via WIFI Ethernet Shield

Membuat Alat Monitoring Ketinggian Air (Water Level) ARDUINO via WIFI Ethernet Shield


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang digunakan untuk mengukur ketinggian air atau water level dengan menggunakan arduino dan sensor air, media pengiriman datanya menggunakan wifi dan penerimanya bisa menggunakan komputer atau handphone yang sudah dilengkapi software browser. untuk lebih jelasnya berikut adalah skema dan programnya.



a. Arduino Uno + Ethernet Shield




b. Sensor Hujan / Air




c. Router Wifi






d. Program Arduino IDE

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,200);

EthernetServer server(80);

String readString;

int x = 500;

void setup() {

 pinMode(4,OUTPUT);
 pinMode(7,OUTPUT);

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

  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  int dataadc1 = analogRead(0);
  int dataadc2 = analogRead(1);
  int dataadc3 = analogRead(2);

  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
     if (readString.length() < 100) {

          //store characters to string
          readString += c;
          //Serial.print(c);
        }
        if (c == '\n' && currentLineIsBlank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println("Refresh: 1");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println(" ");
          client.println("<title> Monitor Ketinggian Air </title> ");    
          client.println("<body bgcolor = #000000>");    
          client.println("<center>");
            client.println("<font color = yellow><center><h1>MONITOR KETINGGIAN AIR<br></h1></center><br></font>");
            client.println("<font color = #FFFFFF>");
            client.println("<h2>");
            client.println("Sensor 1 = ");
            client.print(dataadc1);
            client.println("<br />");
            client.println("Sensor 2 = ");
            client.print(dataadc2);
            client.println("<br />");
            client.println("Sensor 3 = ");
            client.print(dataadc3);
            client.println("<br />");
            client.println("<br />");
            client.println("Ketinggian Air = ");
           
            if((dataadc1 > x)&&(dataadc2 > x)&&(dataadc3 > x)){
            client.println("Tidak ada Air ");
            digitalWrite(4,LOW);
            digitalWrite(7,LOW);           
            }
           
            if((dataadc1 < x)&&(dataadc2 > x)&&(dataadc3 > x)){
            client.println("1 - 30 cm ");
            digitalWrite(4,HIGH);
            digitalWrite(7,LOW);  
            }
           
            if((dataadc1 < x)&&(dataadc2 < x)&&(dataadc3 > x)){
            client.println("30 - 60 cm ");
            digitalWrite(4,HIGH);
            digitalWrite(7,LOW);
            }
           
            if((dataadc1 < x)&&(dataadc2 < x)&&(dataadc3 < x)){
            client.println("1 meter atau lebih ");
            digitalWrite(4,HIGH);
            digitalWrite(7,LOW);
            }
           
            client.println("</h2>");     
          client.println("</font>");
          client.println("</center>");
          client.println("</body>");
          client.println("</html>");
           
          break;      
        }   
        if (c == '\n') {
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
    Serial.println("client disonnected");
  }

         readString="";

}




e. VIDEO HASILNYA









Membuat Alat Prabayar Air Isi Ulang Otomatis Berbasis RFID RC-522 Water Flow Sensor

Membuat Alat Prabayar Air Isi Ulang Otomatis Berbasis RFID RC-522 Water Flow Sensor


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat untuk topup air isi ulang menggunakan RFID, jadi seperti halnya pulsa sms yang menggunakan kartu untuk pengisian kuotanya. Alat dilengkapi dengan sensor water flow untuk menghitung debit air yang terpakai jika debit air yang mengalir sudah sama seperti kuota yang dibeli maka solenoid valve akan menutup namun jika masih ada saldo atau kuotanya maka solenoid akan hidup yang artinya air bisa mengalir. untuk lebih jelasnya berikut adalah skema dan hasilnya. 




a. Arduino Uno




b. RFID RC522




c. LCD 16x2 + I2C




d. Modul Relay 1 Channel




e. Solenoid Valve






f. Program Arduino Ide

#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h>  //i2C LCD Library
LiquidCrystal_I2C lcd(0x3F, 16, 2); //library i2c lcd

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

int buzzer = 3;
int relay = 4;

int putaran = 0;

byte sensorInterrupt = 0;  // 0 = digital pin 2
byte sensorPin       = 2;

float calibrationFactor = 4.5;

volatile byte pulseCount;

unsigned int frac;
float flowRate;
unsigned int flowMilliLitres;
float totalMilliLitres;

unsigned long oldTime;

 int sisa;
 int saldo;
int aa;
int bb;
int cc;

byte sensorInterrupt1 = 1;  // 1 = digital pin 3
byte sensorPin1       = 2;

float calibrationFactor1 = 4.5;

volatile byte pulseCount1;

unsigned int frac1;
float flowRate1;
unsigned int flowMilliLitres1;
float totalMilliLitres1;

unsigned long oldTime1;

void setup()
{
  pinMode(buzzer,OUTPUT);
  digitalWrite(buzzer,LOW);
  pinMode(relay,OUTPUT);
  digitalWrite(relay,HIGH);

  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitres  = 0;
  oldTime           = 0;

  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
 
  lcd.begin(); //set lcd i2c
  lcd.noCursor(); //biar gak ada cursor di lcd
  lcd.clear(); //clear lcd
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
//  Serial.println("Put your card to the reader...");
//  Serial.println();

  delay(1000);

}


void loop()
{

  lcd.setCursor(0,0);
  lcd.print("Dekatkan Kartu");

   SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  Serial.println("Put your card to the reader...");

  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    //return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    //return;
  }
  //Show UID on serial monitor
  //lcd.setCursor(0,0);
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++)
  {
 //    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
 //    Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
 
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
   
 if ((content.substring(1) == "B3 96 7A 89")&&(aa == 0))
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,0);
      lcd.print("ID=");
      lcd.print(content.substring(1));
      lcd.setCursor(0,1);
      lcd.print("ISI 1000 lt     ");
      delay(3000);
      lcd.clear();
      saldo = 1000;
      aa = 1;
      mulai();
  }

 if ((content.substring(1) == "86 B2 99 21")&&(bb == 0))
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,0);
      lcd.print("ID=");
      lcd.print(content.substring(1));
      lcd.setCursor(0,1);
      lcd.print("ISI 3000 lt     ");
      delay(3000);
      lcd.clear();
      saldo = 3000;
      bb = 1;
      mulai();
  }

   if ((content.substring(1) == "C7 25 B3 73")&&(cc == 0))
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,0);
      lcd.print("ID=");
      lcd.print(content.substring(1));
      lcd.setCursor(0,1);
      lcd.print("ISI 5000 lt     ");
      delay(3000);
      lcd.clear();
      saldo = 5000;
      cc = 1;
      mulai();
  }

 
}


void mulai(){
 
    detachInterrupt(sensorInterrupt);
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
    flowMilliLitres = (flowRate / 60) * 1000;
    totalMilliLitres += flowMilliLitres;
     
    // Print the flow rate for this second in litres / minute
    Serial.print("Flow rate: ");
    Serial.print(int(flowRate));  // Print the integer part of the variable
    Serial.print(".");             // Print the decimal point
    // Determine the fractional part. The 10 multiplier gives us 1 decimal place.
    frac = (flowRate - int(flowRate)) * 10;
    Serial.print(frac, DEC) ;      // Print the fractional part of the variable
    Serial.print("L/min");
    // Print the number of litres flowed in this second
    Serial.print("  Current Liquid Flowing: ");             // Output separator
    Serial.print(flowMilliLitres);
    Serial.print("mL/Sec");

    saldo = saldo - flowMilliLitres;

    if(saldo < 0){
      saldo = 0;
      }
     
    lcd.setCursor(0,0);
    lcd.print("Flow=");
    lcd.print(flowMilliLitres);
    lcd.print("mL/Sec        ");   
    lcd.setCursor(0,1);
    lcd.print("Sisa=");
    lcd.print(saldo);
    lcd.print("mL/Sec        ");

    // Print the cumulative total of litres flowed since starting
    Serial.print("  Output Liquid Quantity: ");             // Output separator
    Serial.print(totalMilliLitres);
    Serial.println("mL");

    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;
  
    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

delay(100);


if(saldo > 0){
  digitalWrite(relay,LOW);
  }

if(saldo == 0){
  digitalWrite(relay,HIGH);
  lcd.clear();
  lcd.setCursor(0,0);    
  lcd.print("KUOTA HABIS              "); 
  delay(3000);
  return;
}


  mulai();
}


void pulseCounter()
{
  pulseCount++;
}




g. VIDEO HASILNYA








Membuat Alat Prabayar Pulsa Air Otomatis Menggunakan Arduino Keypad Matrix 4x4 dan RFID RC522 dengan Interface VB 6.0 dan dataase Ms. Access

Membuat Alat Prabayar Pulsa Air Otomatis Menggunakan Arduino Keypad Matrix 4x4 dan RFID RC522 dengan Interface VB 6.0 dan dataase Ms. Access


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk topup pulsa air otomatis berbasis RFID jadi seperti halnya pulsa sms atau kuota internet yang harus di topup untuk penggunaannya, alat ini juga seperti itu namun aplikasinya untuk air, jadi kita membeli berapa liter air dan akan disimpan untuk ID kartu tersebut, setelah itu jika ingin membeli air hanya perlu dekatkan kartu kealat kemudian akan dikurangi oleh nilai pembelian sehingga akan tampak saldo yang tersisa. untuk lebih jelasnya berikut adalah skema dan programnya.



a. Arduino Uno




b. RFID RC-522




c. Keypad Matrik 4x4




d. LCD 16x2 + I2C






e. Program Arduino IDE

#include <SPI.h>
#include <Keypad.h>
#include <MFRC522.h>
#include <LiquidCrystal_I2C.h>  //i2C LCD Library
LiquidCrystal_I2C lcd(0x3F, 16, 2); //library i2c lcd

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

int buzzer = 8;

char customKey;
const byte ROWS = 4;
const byte COLS = 4;
long passwd = 0;
long isiku;
long kartu1;
long kartu2;
long kartu3;
long kartu4;
int id;
long beli;

char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {2,3,4,5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6,7,A0,A1}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup()
{
  pinMode(buzzer,OUTPUT);
  digitalWrite(buzzer,LOW);
  lcd.begin(); //set lcd i2c
  lcd.noCursor(); //biar gak ada cursor di lcd
  lcd.clear(); //clear lcd
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
//  Serial.println("Put your card to the reader...");
//  Serial.println();

  delay(1000);

}


void loop()
{

  lcd.setCursor(0,0);
  lcd.print("Pilih Menu");
  lcd.setCursor(0,1);
  lcd.print("A.Isi    B.Bayar");
 
customKey = customKeypad.getKey();

    if(customKey == 'B'){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Dekatkan Kartu");
    delay(3000);
    lcd.clear();
    isiscan();
    lcd.clear();
    beli = 0;
    bayar();
    }

    if(customKey == 'C'){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Dekatkan Kartu");
    delay(3000);
    lcd.clear(); 
    cek();
    }
   
    if(customKey == 'A'){
    lcd.clear();
    delay(1000);
    passwd = 0;
    isi();
      lcd.setCursor(0,0);
      lcd.print("Dekatkan Kartu");
    delay(3000);
    lcd.clear();
    isiscan();
    delay(1000);
    isiku = 0;
    scan();
    } 
   
}


void cek(){
 
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
//  Serial.println("Put your card to the reader...");

  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    //return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    //return;
  }
  //Show UID on serial monitor
  //lcd.setCursor(0,0);
//  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++)
  {
 //    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
 //    Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
//  Serial.println();
//  Serial.print("Message : ");
  content.toUpperCase();

  if (content.substring(1) == "C5 9C F1 29")
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);
    
      lcd.setCursor(0,0);
      lcd.print("ID=");
      lcd.print(content.substring(1));
      lcd.setCursor(0,1);
      lcd.print("Saldo=");
      lcd.print(kartu1);
      lcd.print("       ");
      delay(3000);
      lcd.clear();
      return;
  }

 if (content.substring(1) == "94 C6 77 89")
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,0);
      lcd.print("ID=");
      lcd.print(content.substring(1));
      lcd.setCursor(0,1);
      lcd.print("Saldo=");
      lcd.print(kartu2);
      lcd.print("       ");
      delay(3000);
      lcd.clear();
      return;
  }

   if (content.substring(1) == "A3 32 48 83")
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,0);
      lcd.print("ID=");
      lcd.print(content.substring(1));
      lcd.setCursor(0,1);
      lcd.print("Saldo=");
      lcd.print(kartu3);
      lcd.print("       ");
      delay(3000);
      lcd.clear();
      return;
  }

   if (content.substring(1) == "F7 3E B8 73")
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,0);
      lcd.print("ID=");
      lcd.print(content.substring(1));
      lcd.setCursor(0,1);
      lcd.print("Saldo=");
      lcd.print(kartu4);
      lcd.print("       ");
      delay(3000);
      lcd.clear();
      return;
  }

  cek(); 
  }


void isi(){
 
  lcd.setCursor(0,0);
  lcd.print("Input Password");
 
customKey = customKeypad.getKey();

    if(customKey >= '0' && customKey <= '9')
    {
      passwd = passwd * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print(passwd);
    }
  
    if((customKey == 'D')&&(passwd == 112233)){
    lcd.clear();
    delay(1000);
    customKey == ' ';
    return;
    }

    if(customKey == 'C'){
    lcd.clear();
    delay(200);
    passwd = 0;
    }
  
 isi();
  }


void isiscan(){

  lcd.setCursor(0,0);
  lcd.print("Scan Kartu");
 
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
//  Serial.println("Put your card to the reader...");
 
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    //return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    //return;
  }
  //Show UID on serial monitor
  //lcd.setCursor(0,0);
//  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++)
  {
 //    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
 //    Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
//  Serial.println();
//  Serial.print("Message : ");
  content.toUpperCase();

  if (content.substring(1) == "C5 9C F1 29")
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,1);
      lcd.print(content.substring(1));
      delay(3000);
      id = 1;
      lcd.clear();
      content.substring(1) = "";
      return;
  }

 if (content.substring(1) == "94 C6 77 89")
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,1);
      lcd.print(content.substring(1));
      delay(3000);
      id = 2;
      lcd.clear();
      content.substring(1) = "";
      return;
  }

   if (content.substring(1) == "A3 32 48 83")
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,1);
      lcd.print(content.substring(1));
      delay(3000);
      id = 3;
      lcd.clear();
      content.substring(1) = "";
      return;
  }

   if (content.substring(1) == "F7 3E B8 73")
  {
     digitalWrite(buzzer,HIGH);
     delay(200);
     digitalWrite(buzzer,LOW);

      lcd.setCursor(0,1);
      lcd.print(content.substring(1));
      delay(3000);
      id = 4;
      lcd.clear();
      content.substring(1) = "";
      return;
  }

isiscan(); 
}



void scan(){
 
  lcd.setCursor(0,0);
  lcd.print("Isi Berapa lt?");
 
customKey = customKeypad.getKey();

    if(customKey >= '0' && customKey <= '9')
    {
      isiku = isiku * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print(isiku);
    }
  
    if(customKey == 'C'){
    lcd.clear();
    delay(200);
    isiku = 0;
    }

    if((customKey == 'D')&&(id == 1)){
    lcd.clear();
    delay(2000);
    kartu1 = isiku;
    return;
    }

    if((customKey == 'D')&&(id == 2)){
    lcd.clear();
    delay(2000);
    kartu2 = isiku;
    return;
    }

    if((customKey == 'D')&&(id == 3)){
    lcd.clear();
    delay(2000);
    kartu3 = isiku;
    return;
    }

    if((customKey == 'D')&&(id == 4)){
    lcd.clear();
    delay(2000);
    kartu4 = isiku;
    return;
    }
   
  
 scan();
  }





void bayar(){

  lcd.setCursor(0,0);
  lcd.print("Beli Berapa lt?");
 
customKey = customKeypad.getKey();

    if(customKey >= '0' && customKey <= '9')
    {
      beli = beli * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print(beli);
    }
  
    if(customKey == 'C'){
    lcd.clear();
    delay(200);
    beli = 0;
    }

    if((customKey == 'D')&&(id == 1)){
    lcd.clear();
    delay(2000);
    kartu1 = kartu1 - beli;

    if(kartu1 >= 0){
    Serial.println(id);
    Serial.println(beli);
    Serial.println(kartu1); 
    delay(1000);
    lcd.setCursor(0,0);
    lcd.print("BERHASIL");
    lcd.setCursor(0,1);
    lcd.print("SALDO=");
    lcd.print(kartu1);
    delay(5000);
    lcd.clear();
    return;
    }

    if(kartu1 < 0){
    kartu1 = kartu1 + beli; 
    lcd.setCursor(0,0);
    lcd.print("SALDO KURANG");
    lcd.setCursor(0,1);
    lcd.print("SALDO=");
    lcd.print(kartu1);
    delay(5000);
    lcd.clear();
    beli = 0;
    }

    }

    if((customKey == 'D')&&(id == 2)){
    lcd.clear();
    delay(2000);
    kartu2 = kartu2 - beli;

    if(kartu2 >= 0){
    Serial.println(id);
    Serial.println(beli);
    Serial.println(kartu2); 
    delay(1000);
    lcd.setCursor(0,0);
    lcd.print("BERHASIL");
    lcd.setCursor(0,1);
    lcd.print("SALDO=");
    lcd.print(kartu2);
    delay(5000);
    lcd.clear();
    return;
    }

    if(kartu2 < 0){
    kartu2 = kartu2 + beli; 
    lcd.setCursor(0,0);
    lcd.print("SALDO KURANG");
    lcd.setCursor(0,1);
    lcd.print("SALDO=");
    lcd.print(kartu2);
    delay(5000);
    lcd.clear();
    beli = 0;
    }

    }

    if((customKey == 'D')&&(id == 3)){
    lcd.clear();
    delay(2000);
    kartu3 = kartu3 - beli;

    if(kartu3 >= 0){
    Serial.println(id);
    Serial.println(beli);
    Serial.println(kartu3);
    delay(1000);
    lcd.setCursor(0,0);
    lcd.print("BERHASIL");
    lcd.setCursor(0,1);
    lcd.print("SALDO=");
    lcd.print(kartu3);
    delay(5000);
    lcd.clear();
    return;
    }

    if(kartu3 < 0){
    kartu3 = kartu3 + beli; 
    lcd.setCursor(0,0);
    lcd.print("SALDO KURANG");
    lcd.setCursor(0,1);
    lcd.print("SALDO=");
    lcd.print(kartu3);
    delay(5000);
    lcd.clear();
    beli = 0;
    }

    }

    if((customKey == 'D')&&(id == 4)){
    lcd.clear();
    delay(2000);
    kartu4 = kartu4 - beli;

    if(kartu4 >= 0){
    Serial.println(id);
    Serial.println(beli);
    Serial.println(kartu4);
    delay(1000);
    lcd.setCursor(0,0);
    lcd.print("BERHASIL");
    lcd.setCursor(0,1);
    lcd.print("SALDO=");
    lcd.print(kartu4);
    delay(5000);
    lcd.clear();
    return;
    }

    if(kartu4 < 0){
    kartu4 = kartu4 + beli; 
    lcd.setCursor(0,0);
    lcd.print("SALDO KURANG");
    lcd.setCursor(0,1);
    lcd.print("SALDO=");
    lcd.print(kartu4);
    delay(5000);
    lcd.clear();
    beli = 0;
    }
    }
   
  bayar();
  }



 

 f. Program Interface VB 6.0



- Module 1.bas
Public Conn As New ADODB.Connection
Public Rs As New ADODB.Recordset
Public SQl As String
Public i As Byte

Public Sub dbConnect()
Set Conn = New ADODB.Connection
Conn.ConnectionString = strConn
Conn.Open
End Sub

Public Function strConn() As String
Set Conn = New ADODB.Connection
Set Rs = New ADODB.Recordset
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\yanuar\Desktop\interface\database\dbsuhu.mdb;Persist Security Info=False"

End Function



- Form 1.frm
Option Explicit
Dim arrdata()
Dim TotalBaca As Integer
Dim BMI As Single
Dim Keterangan As String
Const MAKSBACA = 15

Dim Conn1 As ADODB.Connection
Dim Cmd1 As ADODB.Command
Dim Param1 As ADODB.Parameter
Dim Rs1 As ADODB.Recordset

Private Sub berhenti_Click()
  start.Enabled = True
    berhenti.Enabled = False
    TimerBaca.Enabled = False
End Sub


Private Sub Command1_Click()
Dim SQl As String
   
   Call dbConnect
   
    SQl = "INSERT INTO tbsuhu VALUES('" & Text2(0).Text & "','" & Label4.Caption & "','" & Label2.Caption & "','" & Text2(1).Text & "','" & Text2(2).Text & "')"
   
    Dim Rs As Recordset
    Set Rs = New ADODB.Recordset
    Rs.Open SQl, Conn, adOpenDynamic

End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim i As Byte
For i = 1 To 16
    ComboCOM.AddItem (i)
Next i

End Sub

Private Sub MSComm2_OnComm()
Dim buffer As String
Dim temp As String
Dim pisah() As String
Dim i As Integer

If MSComm2.CommEvent = comEvReceive Then
    buffer = MSComm2.Input
    pisah = Split(buffer, Chr$(13))
On Error Resume Next
If buffer <> " " Then
With Text1
    .SelStart = Len(.Text)
    .SelText = buffer
End With
For i = 0 To 2
    If 0 < 3 Then
        Text2(i).Text = CStr(pisah(i))
        End If
        Next i
    Else
    buffer = " "
    End If
End If
End Sub

Private Sub start_Click()
Dim u As Integer

    On Error GoTo ada_eror
   
    MSComm2.CommPort = ComboCOM.Text
    MSComm2.Settings = "9600,N,8,1"
    MSComm2.RThreshold = 15
    MSComm2.InputLen = 15
    MSComm2.InputMode = comInputModeText
    MSComm2.PortOpen = True ' buka port
   
    ReDim arrdata(1 To MAKSBACA + 1)
    For u = 1 To MAKSBACA
        arrdata(u) = 0
    Next
    TotalBaca = 0
    start.Enabled = False
    berhenti.Enabled = True
    TimerBaca.Enabled = True
    Timer1.Enabled = True
    Timer2.Enabled = True
    Timer3.Enabled = True
ada_eror:
 If ComboCOM.ListIndex < 1 Then
    MsgBox "COM berada di Nomor : " & Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "ERROR"
    start.Enabled = True
    berhenti.Enabled = True
    ComboCOM.Text = "Pilih COM"
End If

End Sub

Private Sub Timer2_Timer()
Adodc1.Refresh
Dim ok As Integer
Dim mode As Integer


End Sub

Private Sub Timer3_Timer()
MSComm2_OnComm
End Sub

Private Sub Timer4_Timer()
 Label4.Caption = Format(Time, "hh:mm:ss")
 Label2.Caption = Format(Date, "dd:mm:yy")
End Sub

Private Sub TimerBaca_Timer()
Dim strInput As String
Dim strPotong As String
Dim singleInput As Single
Dim u As Integer
    strInput = MSComm2.Input
        strPotong = strInput
        If TotalBaca >= MAKSBACA Then
            TimerBaca.Enabled = False
            If MSComm2.PortOpen = True Then MSComm2.PortOpen = False
            Call berhenti_Click
        End If
 
 
 
End Sub





g. VIDEO HASILNYA







Alat Kendali Pompa (Relay) Menggunakan SMS berbasis ARDUINO dan SMS Gateway SIM900A

Alat Kendali Pompa (Relay) Menggunakan SMS berbasis ARDUINO dan SMS Gateway SIM900A


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa digunakan untuk kendali pompa dengan menggunakan SMS, pompa dipasangkan ke relay sehingga yang akan aktif adalah relay, jika relay aktif maka pompa akan aktif, jika relay off maka pompa akan off juga. alat ini dikendalikan menggunakan 2 cara yaitu dengan menggunakan sms dan dengan tombol push button. untuk lebih jelasnya berikut adalah skema dan programnya.



a. Arduino Uno




b. Modul SIM900A




c. LCD 16x2 + I2C




d. Modul relay






e. Program Arduino

#include <Wire.h>
#include <LiquidCrystal_I2C.h> 

#include "SIM900.h"
#include <SoftwareSerial.h>

#include <stdlib.h>
#include "sms.h"
SMSGSM sms;

LiquidCrystal_I2C lcd(0x27, 16, 2);

int relay1 = 4;
int relay2 = 5;
int btstart = 10;
int btstop = 9;
int led = 6;
int btstartx = 0;
int btstopx = 0;
int mark = 0;
int cacah = 0;

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


void setup(){
    
  lcd.begin(); //set lcd i2c
  lcd.noCursor(); //biar gak ada cursor di lcd
  lcd.clear(); //clear lcd
  Serial.begin(9600);
 
  lcd.setCursor(0, 0);
  lcd.print("LOADING.....");

  pinMode(relay1,OUTPUT);
  pinMode(relay2,OUTPUT);
  digitalWrite(relay1,HIGH);
  digitalWrite(relay2,HIGH);
 
  pinMode(led,OUTPUT);
  digitalWrite(led,HIGH);
 
  pinMode(btstart,INPUT_PULLUP);
  pinMode(btstop,INPUT_PULLUP);
       
      Serial.println("GSM Shield testing.");

     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("085726123456", "Alat Ready"))
          //Serial.println("\nSMS sent OK");
     }
    
     lcd.clear(); //clear lcd
 
}



void loop(){

 btstartx = digitalRead(btstart);

 if(btstartx == 0){
  lcd.setCursor(0, 0);
  lcd.print("KIRIM SMS START   ");
 
  if (sms.SendSMS("085726123456", "Pompa ON"))
          Serial.println("\nSMS sent OK");
          digitalWrite(relay1,LOW);
          mark = 1;
 lcd.clear();  
 btstartx = 1;
 }


  btstopx = digitalRead(btstop);

  if(btstopx == 0){
  lcd.setCursor(0, 0);
  lcd.print("KIRIM SMS STOP   ");
 
  if (sms.SendSMS("085726123456", "Pompa OFF"))
          Serial.println("\nSMS sent OK");
          digitalWrite(relay1,HIGH);
          mark = 0;
  lcd.clear(); 
  btstopx = 1; 
  cacah = 0;
  }

 
 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,"On")){     
      if (sms.SendSMS("085726123456", "Pompa ON"))
          Serial.println("\nSMS sent OK");
          digitalWrite(relay1,LOW);
          mark = 1;
    }
   
    if(!strcmp(smsbuffer,"Off")){     
       if (sms.SendSMS("085726123456", "Pompa OFF"))
          Serial.println("\nSMS sent OK");
          digitalWrite(relay1,HIGH);
          mark = 0;
          cacah = 0;
    }
 
    delsms();
  }
 }

  delay(1000);
 
  if(mark == 1){
  cacah++;
  }
 
 
  if(cacah > 10){
    if (sms.SendSMS("085726123456", "Pompa ON"))
      Serial.println("\nSMS sent OK");
      cacah = 0;       
  }
 
    lcd.setCursor(0, 1);
    lcd.print("Waktu=");
    lcd.print(cacah);
    lcd.print(" ");
 
  btstartx = digitalRead(btstart);
  btstopx = digitalRead(btstop);

  lcd.setCursor(12, 1);
  lcd.print(btstartx);
  lcd.print("-");
  lcd.print(btstopx);
 
 
}



void delsms()
{
  for (int i=0; i<10; i++)
  {
      int pos=sms.IsSMSPresent(SMS_ALL);
      if (pos!=0)
      {
        if (sms.DeleteSMS(pos)==1){}else{}
      }
  }
}




f. VIDEO HASILNYA