Translate

Membuat Alat Pengisian Air Otomatis (Pertamini) Berbasis Arduino

Membuat Alat Pengisian Air Otomatis (Pertamini) Berbasis Arduino


       Pada kesempatan kali ini saya akan mejelaskan mengenai bagaimana cara membuat sebuah alat yang dapat digunakan untuk mengisi air secara otomatis seperti pertamini, jadi sistem kerjanya yaitu user menekan keypad berapa ml yang dia butuhkan lalu tekan start untuk memulai pengisian air, alat ini juga dilengkapi sensor IR proximity sehingga jika belum ada gelas untuk menampung airnya maka ketika ditekan start airnya tidak akan mengalir. jadi yang dibutuhkan adalah adanya benda / gelas untuk menampung air dan tombol start ditekan. jika air sudah sesuai dengan yang diinginkan maka relay akan off kan solenoid agar air tidak mengalir. untuk lebih jelasnya berikut adalah skema dan kodingnya.



a. Skema Alat




b. Program Arduino IDE
     
#include <Wire.h>
#include <SPI.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>  //i2C LCD Library
LiquidCrystal_I2C lcd(0x3F, 16, 2); //library i2c lcd 16x2

int relay = 4;
int btstart = A1;
int btstartx;
int btstop = A2;
int btstopx;

int dataadc;

char customKey;
const byte ROWS = 4;
const byte COLS = 4;
long passwd = 0;
long isiku;
long beli;

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

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

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;
int totalMilliLitres;

unsigned long oldTime;
long dataku = 0;

void setup() 
{
  
  pinMode(btstart, INPUT_PULLUP);
  pinMode(btstop, INPUT_PULLUP);
  
  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

  lcd.setCursor(0,0); 
  lcd.print("SELAMAT DATANG");
  delay(3000);
  lcd.clear();
}

void loop() 
{
  
  int dataadc = analogRead(A0);
  
/*
  lcd.setCursor(0,0); 
  lcd.print("1.250mL");
  lcd.setCursor(8,0); 
  lcd.print("3.500mL");
  lcd.setCursor(0,1); 
  lcd.print("2.750mL");
  lcd.setCursor(8,1); 
  lcd.print("4.1000mL");
*/
 
  customKey = customKeypad.getKey();

  if(customKey >= '0' && customKey <= '9')
    {
     beli = beli * 10 + (customKey - '0');
    }
        
     lcd.setCursor(0,0);
     lcd.print("ISI BERAPA?");
     lcd.setCursor(0,1);
     lcd.print(beli);
     lcd.print("  ");
    
    if(customKey == '#'){
     delay(200);
     lcd.clear();
     beli = 0; 
    }
    
    if(customKey == 'A'){
     beli = 250;
    }

    if(customKey == 'B'){ 
     beli = 500;
    }
    
    if(customKey == 'C'){
     beli = 750;
    }  

    if(customKey == 'D'){     
     beli = 1000;
    } 
    
    btstartx = digitalRead(btstart);
    
    if((btstartx == 0)&&(dataadc < 700)){
     lcd.clear();
     delay(200);
     digitalWrite(relay, LOW); //buka 
     mulaiisi();
    }   
}

void mulaiisi(){

lcd.setCursor(0,0); 
lcd.print("Beli ");
lcd.print(beli);
lcd.print(" mL   ");

delay(100);
  
if((millis() - oldTime) > 1000)    // Only process counters once per second
  { 

    detachInterrupt(sensorInterrupt);
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
    flowMilliLitres = (flowRate / 60) * 1000;
    totalMilliLitres += flowMilliLitres;
       
    frac = (flowRate - int(flowRate)) * 10;
     
    lcd.setCursor(0,1);
    lcd.print("Spd: ");             // Output separator
    lcd.print(flowMilliLitres);
    lcd.print(" mL/s   ");

    // Print the cumulative total of litres flowed since starting
    lcd.setCursor(0,2); 
    lcd.print("ISI: ");             // Output separator
    lcd.print(totalMilliLitres);
    lcd.print(" mL   "); 

    pulseCount = 0;
    
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

  if(totalMilliLitres >= beli){
    lcd.clear();
    delay(1000);
    digitalWrite(relay, HIGH);
    lcd.setCursor(0,0); 
    lcd.print("SELESAI ");
    delay(3000);
    lcd.clear();
    return;
    }
  
  }

btstopx = digitalRead(btstop);
if(btstopx == 0){
    lcd.clear();
    delay(1000);
    digitalWrite(relay, HIGH);
    lcd.setCursor(0,0); 
    lcd.print("SELESAI ");
    delay(3000);
    lcd.clear();
    return;
}
    
mulaiisi(); 
}
  
void pulseCounter()
{
  pulseCount++;
}




c. Cara Penggunaan Alat

         Jadi alat ini yang pertama mengisi nilai kuantitas air yang diinginkan menggunakan keypad lalu tombol A untuk memilih 250 ml. tombol B untuk memilih 500 ml. C untuk memilih 750 ml dan tombol D untuk 1000 ml. jika ingin custom bisa menggunakan keypad pakai angka 0 sampai 9. jika ingin clear tekan # lalu jika ingin memulai pertamakali harus dekatkan gelas sampai sensor mendeteksi kemudian tekan tombol start untuk memulai pengisian, jika pengisian sudah sesuai takaran maka pengisian akan berhenti secara otomatis. 










Monitor Flow Meter Air Topup via Blynk

Monitor Flow Meter Air Topup via Blynk


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa digunakan untuk memonitor flowmeter air / udara dengan sistem topup dengan aplikasi blynk. alat ini juga bisa dimonitor secara online mengenai flowmeternya dan saldo yang tersisa. untuk lebih jelasnya berikut adalah komponen dan kodingnya.



a. Arduino Uno 




b. Flow Sensor




c. Nodemcu esp8266





d. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16,2);

int total1 = 0;
int total2 = 0;
float totalflow1;
float totalflow2;
float lebih1;
float lebih2;

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;

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

float calibrationFactor1 = 4.5;

volatile byte pulseCount1;

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

unsigned long oldTime1;

int topup1 = 8;
int topup2 = 9;
int topup3 = 10;
int topup4 = 11;

int topup1x;
int topup2x;
int topup3x;
int topup4x;

void setup() {

Serial.begin(9600);

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

 pinMode(topup1, INPUT);
 pinMode(topup2, INPUT);
 pinMode(topup3, INPUT);
 pinMode(topup4, INPUT);
 
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

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

  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

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

  pulseCount1        = 0;
  flowRate1          = 0.0;
  flowMilliLitres1   = 0;
  totalMilliLitres1  = 0;
  oldTime1           = 0;

  attachInterrupt(sensorInterrupt1, pulseCounter1, FALLING);

}

void loop() {

  if((millis() - oldTime) > 1000)
  {

    detachInterrupt(sensorInterrupt);
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
    flowMilliLitres = (flowRate / 60) * 1000;
    totalMilliLitres += flowMilliLitres;

    pulseCount = 0;
   
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  }
    
    if((millis() - oldTime1) > 1000)
  {

    detachInterrupt(sensorInterrupt1);
    flowRate1 = ((1000.0 / (millis() - oldTime1)) * pulseCount1) / calibrationFactor1;
    oldTime1 = millis();
    flowMilliLitres1 = (flowRate1 / 60) * 1000;
    totalMilliLitres1 += flowMilliLitres1;

    pulseCount1 = 0;
   
    attachInterrupt(sensorInterrupt1, pulseCounter1, FALLING);
  }
      
  totalflow1 = totalMilliLitres/1000;    
  totalflow2 = totalMilliLitres1/1000;
  
  lebih1 = total1 - totalflow1;
  lebih2 = total2 - totalflow2;
  
  lcd.setCursor(0, 0);
  lcd.print(totalflow1);
  lcd.print(" / ");
  lcd.print(total1);
  lcd.print("   ");
  lcd.setCursor(0, 1);
  lcd.print(totalflow2);
  lcd.print(" / ");
  lcd.print(total2);
  lcd.print("   ");

topup1x = digitalRead(topup1);
topup2x = digitalRead(topup2);
topup3x = digitalRead(topup3);
topup4x = digitalRead(topup4);

if(topup1x == 0){
total1 = 5;
}

if(topup2x == 0){
total1 = 10;
}

if(topup3x == 0){
total2 = 5;
}

if(topup4x == 0){
total2 = 10;
}

Serial.print("*");
Serial.print(totalflow1*100);
Serial.print(",");
Serial.print(lebih1*100);
Serial.print(",");
Serial.print(totalflow2*100);
Serial.print(",");
Serial.print(lebih2*100);
Serial.println("#"); 

delay(200);

}

void pulseCounter()
{
  pulseCount++;
}

void pulseCounter1()
{
  pulseCount1++;
}



e. Program Nodemcu ESP8266

#define BLYNK_PRINT Serial   
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

int temp;
int x = 5;
int y;

int value1;
int value2;

float flow1 = 0;
float flow2 = 0;
float lebih1 = 0;
float lebih2 = 0;

float datain1;
float datain2;
float datain3;
float datain4;

String dataIn;
String dt[10];
int i;
boolean parsing=false;

char auth[] = "jhgjhgRDSERES89oiu5fhhgfdggfd891235fghklkj";
char ssid[] = "hotspot hpku";
char pass[] = "112345678";

SimpleTimer timer;

void sendSensor()
{

 Blynk.virtualWrite(V2, flow1);
 Blynk.virtualWrite(V3, lebih1);
 Blynk.virtualWrite(V4, flow2);
 Blynk.virtualWrite(V5, lebih2);
 delay(1000);

}

void setup()
{
 
  dataIn="";
  // Debug console
  Serial.begin(9600);
  
  pinMode(D1,OUTPUT);
  pinMode(D2,OUTPUT);
  pinMode(D3,OUTPUT);
  pinMode(D4,OUTPUT);  

  digitalWrite(D1,HIGH);
  digitalWrite(D2,HIGH);
  digitalWrite(D3,HIGH);
  digitalWrite(D4,HIGH);
  
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop()
{

while(Serial.available()>0) {
//   dataIn="";
    char inChar = (char)Serial.read();
    dataIn += inChar;
    if (inChar == '\n') {
    parsing = true;
  }
}

if(parsing){
  parsingData();
   
  Blynk.run();
  timer.run();
}

}

void parsingData(){
int j=0;

//kirim data yang telah diterima sebelumnya
//Serial.print("data masuk : ");
//Serial.print(dataIn);
//Serial.print("\n");

//inisialisasi variabel, (reset isi variabel)
dt[j]="";
//proses parsing data
for(i=1;i<dataIn.length();i++){
//pengecekan tiap karakter dengan karakter (#) dan (,)
if ((dataIn[i] == '#') || (dataIn[i] == ','))
{
//increment variabel j, digunakan untuk merubah index array penampung
j++;
dt[j]="";       //inisialisasi variabel array dt[j]
}
else
{
//proses tampung data saat pengecekan karakter selesai.
dt[j] = dt[j] + dataIn[i];
}
}

datain1 = dt[0].toInt();
datain2 = dt[1].toInt();
datain3 = dt[2].toInt();
datain4 = dt[3].toInt();

//kirim data hasil parsing
Serial.print("data 1 : ");
Serial.print(datain1);
Serial.print("\n");
Serial.print("data 2 : ");
Serial.print(datain2);
Serial.print("\n");
Serial.print("data 3 : ");
Serial.print(datain3);
Serial.print("\n");
Serial.print("data 4 : ");
Serial.print(datain4);
Serial.print("\n");

 flow1 = datain1 / 100.0;
 lebih1 = datain2 / 100.0;
 flow2 = datain3 / 100.0;
 lebih2 = datain4 / 100.0;

}




f. Interface Blynk





g. VIDEO HASILNYA






Monitor Suhu dan Debu ONLINE BLYNK Sensor DHT11 dan GP2Y1010AU0F

Monitor Suhu dan Debu ONLINE BLYNK Sensor DHT11 dan GP2Y1010AU0F


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa mengukur suhu dan debu secara online dengan menggunakan Blynk. alat ini menggunakan sensor DHT11 dan GP2Y1010AU0F. untuk lebih jelasnya berikut adalah komponen dan kodingnya. 



a. Nodemcu ESP8266




b. Sensor DHT11




c. Sensor Debu GP2Y1010AU0F




d. LCD + I2C





e. Program Arduino IDE

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);

int ledx = D6;
int h;
int t;
float Dustval;
int dataadc;
float v;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "TMJHGJ764HFJGF434NVNBCVXNBVNHMMVBVX";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Yanuar Iphone";
char pass[] = "13579ynr";

#define DHTPIN 0          // D3 dan led di D4

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
  Blynk.virtualWrite(V9, t);
  Blynk.virtualWrite(V10, Dustval);
}

void setup()
{

  lcd.begin(); //set lcd i2c
  lcd.noCursor(); //biar gak ada cursor di lcd
  lcd.clear(); //clear lcd
  pinMode(ledx,OUTPUT); 
  
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop()
{

  h = dht.readHumidity();
  t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

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

//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);    //on
delayMicroseconds(176);

dataadc = analogRead(A0);
delayMicroseconds(40);

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

v = dataadc * (5.0 / 1023.0);

//y = 0.166x - 0.129
Dustval = (v * 0.166) - 0.129;

   lcd.setCursor(0, 0);
   lcd.print("Suhu: ");
   lcd.print(t);
   lcd.print(" C   ");
   lcd.setCursor(0, 1);
   lcd.print("Dust= ");
   lcd.print(Dustval);
   lcd.print(" mg/m3   ");
   
  Blynk.run();
  timer.run();
}




f. VIDEO HASILNYA







Monitor Ketinggian Air (Water Level) dan Berat sampah Serta Hujan + SMS GATEWAY

 Monitor Ketinggian Air (Water Level) dan Berat sampah Serta Hujan + SMS GATEWAY 


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan beberapa sensor beserta fitur sms. alat ini digunakan untuk monitoring ketinggian air / water level dan juga berat serta air hujan, untuk notifikasi menggunakan sms. untuk lebih jelasnya berikut adalah program dan daftar komponennya. 



a. Arduino Uno




b. Loadcell




c. Sensor Jarak HC-SRF04




d. Sensor Air / Hujan




e. Modul SMS SIM900A






f. Program Arduino IDE

#include <Wire.h>
#include "HX711.h"
#include "SIM900.h"
#include <SoftwareSerial.h>
#include <stdlib.h>
#include "sms.h"
SMSGSM sms;

#define trigPin 10
#define echoPin 11

// HX711.DOUT    - pin #4
// HX711.PD_SCK    - pin #5
HX711 scale(4, 5);       

long duration, distance;
float tera = 0;
int berat;
float fix;
int x;
int dataadc;
char string[160];
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
char strsms[5];
int mark = 0;

//gerbang pintu air
int motor1 = 9;
int motor2 = 8;
//pengangkut sampah
int motor3 = 7;
int motor4 = 6;

void setup(){
  
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);  
pinMode(motor1, OUTPUT);
pinMode(motor2, OUTPUT);  
pinMode(motor3, OUTPUT);
pinMode(motor4, OUTPUT);  
   
scale.set_scale(2280.f);       // this value is obtained by calibrating the scale with known weights; see the README for details
scale.tare();                  // reset the scale to 0

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

void loop(){
  
digitalWrite(trigPin, LOW);  // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
 
berat = scale.get_units(10) * 1;
//fix = ((berat + 1.523) / 0.223) - tera ;

dataadc = analogRead(A0);

Serial.print("Berat= ");
Serial.print(berat);
Serial.print(" ");
Serial.print("Jarak= ");
Serial.print(distance);
Serial.print(" ");
Serial.print("Hujan= ");
Serial.println(dataadc);

if((distance <= 5)&&(mark == 0)){
digitalWrite(motor1,HIGH);
digitalWrite(motor2,LOW);
delay(5000);
digitalWrite(motor1,LOW);
digitalWrite(motor2,LOW);
mark = 1;  
}

if((distance >= 10)&&(mark == 1)){
digitalWrite(motor1,LOW);
digitalWrite(motor2,HIGH);
delay(5000);  
digitalWrite(motor1,LOW);
digitalWrite(motor2,LOW);
mark = 0;
}

//jika berat > 10gr
if(berat > 10){
if (sms.SendSMS("085123456789", "SAMPAH MENUMPUK"))
Serial.println("\nSMS sent OK");
digitalWrite(motor3,HIGH);
digitalWrite(motor4,LOW);
}

//jika berat < 10gr
if(berat < 10){
digitalWrite(motor3,LOW);
digitalWrite(motor4,LOW);
}

scale.power_down();                  
delay(1000);
scale.power_up();

}  




g. VIDEO HASILNYA