Translate

Arduino Timbangan Digital dan Water Flow Interface Grafik Delphi 7

Arduino Timbangan Digital dan Water Flow Interface Grafik Delphi 7


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi sebagai pengukur berat atau timbangan digital dan juga alat ini dapat mengukur flow aliran air dengan menggunakan sensor water flow. Arduino yang digunakan adalah arduino uno sebagai pemprosesan data. interface yang digunakan adalah software Delphi 7. untuk lebih jelasnya berikut adalah program dan daftar komponenya.



a. Arduino Uno




b. Loadcell + HX711




c. Sensor Water Flow






d. Program Arduino IDE

#include <Wire.h>
#include "HX711.h"

// HX711.DOUT    - pin #8
// HX711.PD_SCK    - pin #9

HX711 scale(8, 9);        // parameter "gain" is ommited; the default value 128 is used by the library

float tera = 0;
float berat;
float fix;
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;

float kalmasaa;
float kalflow;

void setup() {

  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

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

  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

  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

}

void loop() {

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

    detachInterrupt(sensorInterrupt);
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
    flowMilliLitres = (flowRate / 60) * 1000;
    totalMilliLitres += flowMilliLitres;
     
    unsigned int frac;
   
    //Serial.print("Flow rate: ");
    //Serial.print(int(flowRate));  /
    //Serial.print(".");            
    frac = (flowRate - int(flowRate)) * 10;
    //Serial.print(frac, DEC) ;     
    //Serial.print("L/min");
    //Serial.print("  Current Liquid Flowing: ");   
    //Serial.print(flowMilliLitres);
    //Serial.print("mL/Sec");

    //Serial.print("  Output Liquid Quantity: ");

    //kalibrasi
    kalmassa = (berat - 3.1115) / 1.1535;
    kalflow = (totalMilliLitres - 3.1115) / 1.1535;
    
    //Serial.print(kalmassa),Serial.println("a");   
    Serial.print(berat),Serial.println("a"); 
    //Serial.print(kalflow),Serial.println("b");
    Serial.print(totalMilliLitres),Serial.println("b");
    
    pulseCount = 0;
   
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
 // }
   
   berat = scale.get_units(10) * -1;
   //fix = ((berat + 1.523) / 0.223) - tera ;

 if (fix < 0 ) {
  fix = 0;
  }

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

}

void pulseCounter()
{
  pulseCount++;
}




e. Program Interface Delphi 7


unit TA;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,strutils, TeeProcs, TeEngine, Chart, CPort, mmsystem,
  Series, Buttons;

type
  TForm1 = class(TForm)
    ComPort1: TComPort;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Chart1: TChart;
    Shape1: TShape;
    Shape2: TShape;
    GroupBox2: TGroupBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Memo1: TMemo;
    Label1: TLabel;
    Label2: TLabel;
    Timer1: TTimer;
    Label7: TLabel;
    Label8: TLabel;
    BitBtn1: TBitBtn;
    Chart2: TChart;
    Series1: TFastLineSeries;
    Series2: TFastLineSeries;
    Label5: TLabel;
    Timer2: TTimer;
    Timer3: TTimer;
    
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Memo1Change(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
comport1.ShowSetupDialog;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Timer2.Enabled := True;
Timer3.Enabled := True;
if button2.Caption='Connect' then
   begin
   button2.Caption:='Disconnect';
   comport1.Open;
   end
else if button2.Caption='Disconnect' then
   begin
   button2.Caption:='Connect';
   comport1.Close;
   end;

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.Color:=clwhite;
Edit2.Color:=clwhite;
edit1.text:='';
edit2.text:='';
memo1.Text:='';
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ThousandSeparator:=',';
DecimalSeparator:='.';
end;

procedure TForm1.Memo1Change(Sender: TObject);
var ruang,kulit:double;
    rin,kin:string;
    jumlahdata:integer;

begin
  shape1.Brush.Color:=clgreen;
  shape2.Brush.Color:=clgreen;
  jumlahdata:=chart1.GetMaxValuesCount;
  form1.Caption:=inttostr(jumlahdata);

//  if jumlahdata =10000 then
//     begin
//     Series1.Clear;
//     Series2.Clear;
//    end;

  rin:=memo1.Lines[memo1.Lines.count-2];
  kin:=memo1.Lines[memo1.Lines.count-1];

  if rightstr(rin,1)= 'a' then
     begin
     edit1.Text:=leftstr(rin,length(rin)-1);
     ruang:=strtofloat(edit1.text);
     Series1.Add(ruang,'',clred) ;
     shape1.Brush.Color:=clred;
     end;
  if rightstr(kin,1)='b' then
     begin
     edit2.Text:=leftstr(kin,length(kin)-1);
     kulit:=strtofloat(edit2.text);
     Series2.Add(kulit,'',clgreen) ;
     shape2.Brush.Color:=clred;
     end;


end;

procedure TForm1.Edit1Change(Sender: TObject);
var ruang:double;
begin
ruang:=strtofloat(edit1.text);


end;

procedure TForm1.Edit2Change(Sender: TObject);
var kulit:double;
begin
kulit:=strtofloat(edit2.text);

end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
label7.Caption:='Date  '+ FormatdateTime('d/mm/yyyy',Date);
label8.Caption:='Time  '+ FormatDateTime('hh:nn:ss',Time);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var x:double;
    y:double;

begin
x:=strtofloat(edit1.text);
y:=strtofloat(edit2.text);


end;

procedure TForm1.Timer3Timer(Sender: TObject);
var buff:string;
Count: Integer;
begin
comport1.ReadStr(buff,count);
memo1.Text:=memo1.Text+buff;
end;


end.





f. VIDEO HASILNYA









ALAT MONITOR KADAR GULA DARAH ONLINE DAN MONITOR VIA ANDROID NODEMCU ESP8266 ARDUINO DAN THINGSPEAK

Alat Monitor Kadar Gula Darah ONLINE dan Monitor via Android NODEMCU ESP8266 ARDUINO dan Thingspeak


          Pada ksempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat dengan menggunakan Nodemcu ESP8266 dengan fungsinya yaitu untuk monitor gula darah secara non invasive. alat ini berbasis mikrokontroller dengan server yang digunakan yaitu Thingspeak. jadi alat ini akan memonitor hasilnya melalui 2 buah perangkat yaitu internet dan android. untuk android menggunakan bluetooth dan untuk internet dengan menggunakan server bebasis internet. untuk lebih jelasnya berikut adalah program dan daftar komponennya.



a. Nodemcu ESP8266




b. LCD + I2C




c. Bluetooth HC-05




d. Sensor Photodioda






e. Program Arduino IDE

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

LiquidCrystal_I2C lcd(0x27, 16, 2);

String apiKey = "AAABBB2345DDEEEFFFGG";     //  Enter your Write API key from ThingSpeak
const char* resource = "/update?api_key=";

const char *ssid =  "my hotspot";     // replace with your wifi ssid and wpa2 key
const char *pass =  "12345678";
const char* server = "api.thingspeak.com";

int bt = D4;
int btx = 0;
int adcsensor;
float fix;
int datafix;
int cacah = 0;
float kalibrasi;
int tanda = 0;

WiFiClient client;

void setup() {

  WiFi.begin(ssid, pass);
  
  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  
  pinMode(bt,INPUT);
  digitalWrite(bt,HIGH);
  
}


void loop(){
 delay(100);
   
 btx = digitalRead(bt);

 if(btx == 0){
   delay(200); 
   tanda = 1; 
   cacah = 0;
   lcd.clear();
   delay(1000);
 }

if(tanda == 0){ 
 lcd.setCursor(0,0);
 lcd.print("TEKAN MULAI");
 lcd.setCursor(0,1);
 lcd.print("mg/dl= ");
 lcd.print(fix);
 lcd.print("      "); 
   Serial.print("mmHg= ");
   Serial.println(fix);
   Serial.println("    ");
   Serial.println("    ");
}



if(tanda == 1){  
 datafix = 0;
 fix = 0;

adcsensor = analogRead(A0);

 lcd.setCursor(0,0);
 lcd.print("ADC= ");
 lcd.print(adcsensor);
 lcd.print("      ");

 cacah++;

 datafix = adcsensor + datafix;

 delay(100);


 if(cacah >= 20){
  fix = datafix / 20.0;
  //kalibrasi = (fix - 1022.1) / 0.0967;
  cacah = 0;
  lcd.clear();  

              if (client.connect(server,80))   //   "184.106.153.149" or api.thingspeak.com
                      {  
                            
                             String postStr = apiKey;
                             postStr +="&field1=";
                             postStr += String(fix);
                             postStr += "\r\n\r\n";

                             client.print(String("GET ") + resource + apiKey + "&field1=" + fix + " HTTP/1.1\r\n" + "Host: " + server + "\r\n" + "Connection: close\r\n\r\n");                             
                                        
                             client.print("Host: api.thingspeak.com\n");
                             client.print("Connection: close\n");
                             client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
                             client.print("Content-Type: application/x-www-form-urlencoded\n");
                             client.print("Content-Length: ");
                             client.print(postStr.length());
                             client.print("\n\n");
                             client.print(postStr);

                             Serial.print("mmHg= ");
                             Serial.println(fix);
                             delay(10000);
                        }
                        
  
 client.stop();
  tanda = 0;
  }

}

}





f. Program Android







g. VIDEO HASILNYA







Simulasi Timer Count Down ARDUINO Proteus

Simulasi Timer Count Down ARDUINO Proteus


      Pada kesempatan kali ini saya akan menjelaskan mengenai sebuah alat simulasi dengan menggunakan software proteus 7. Alat ini berfungsi untuk timer mundur dengan beberapa pilihan waktu. ada beberapa buah tombol yang mana tiap tombol mewakili waktu tertentu. untuk lebih jelasnya berikut adalah programnya.



a. Program Arduino IDE

#include "Wire.h"
//#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal.h>
//LiquidCrystal_I2C lcd(0x27, 16, 2);
LiquidCrystal lcd(16,17,18,19,20,21);

int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int btreset = 8;

int btonoff = 14;

int onoff = 0;

int detik;
int menit;
int mulaix;

int x = 0;

int dipsw1 = 9;
int dipsw2 = 10;
int dipsw3 = 11;
int dipsw4 = 12;

int sw1 = 0;
int sw2 = 0;
int sw3 = 0;
int sw4 = 0;

int counter = 0;
int jalan;
int jalanx;
int waktu;

int mark = 0; 

void setup(void){

  lcd.begin(16,2);
  lcd.clear();
  lcd.noCursor();

Serial.begin(9600);

//indikator
pinMode(led1,OUTPUT);
digitalWrite(led1,HIGH);

pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
pinMode(led5,OUTPUT);
pinMode(led6,OUTPUT);

pinMode(btreset,INPUT);

pinMode(dipsw1,INPUT);
pinMode(dipsw2,INPUT);
pinMode(dipsw3,INPUT);
pinMode(dipsw4,INPUT);

pinMode(btonoff,INPUT);

digitalWrite(btreset,HIGH);
digitalWrite(dipsw1,HIGH);
digitalWrite(dipsw2,HIGH);
digitalWrite(dipsw3,HIGH);
digitalWrite(dipsw4,HIGH);
digitalWrite(btonoff,HIGH);
  
}

void loop(void){
//Serial.println("utama");


onoff = digitalRead(btonoff);

if(onoff == 1){
//Serial.println("aktif");

digitalWrite(led6,LOW);

sw1 = digitalRead(dipsw1);
sw2 = digitalRead(dipsw2);
sw3 = digitalRead(dipsw3);
sw4 = digitalRead(dipsw4);

if((sw1 == 1)&&(sw2 == 1)&&(sw3 == 1)&&(sw4 == 1)){
delay(200);
waktu = 0;
lcd.setCursor(0,1);
lcd.print("TS=0M");
}

if((sw1 == 0)&&(sw2 == 1)&&(sw3 == 1)&&(sw4 == 1)){
delay(200);
waktu = 60;
menit = 1;
lcd.setCursor(0,1);
lcd.print("TS=1M");
}

if((sw1 == 1)&&(sw2 == 0)&&(sw3 == 1)&&(sw4 == 1)){
delay(200);
waktu = 120;
menit = 2;
lcd.setCursor(0,1);
lcd.print("TS=2M");
}

if((sw1 == 1)&&(sw2 == 1)&&(sw3 == 0)&&(sw4 == 1)){
delay(200);
waktu = 180;
menit = 3;
lcd.setCursor(0,1);
lcd.print("TS=3M");
}

if((sw1 == 1)&&(sw2 == 1)&&(sw3 == 1)&&(sw4 == 0)){
delay(200);
waktu = 240;
menit = 4;
lcd.setCursor(0,1);
lcd.print("TS=4M");
}

counter = 0;
jalan = waktu / 1; 
jalanx = jalan + 10;

digitalWrite(led3,LOW);
digitalWrite(led4,LOW);

//Serial.println(waktu);

if(waktu > 0){
delay(200);  
mulai();

}

}


if(onoff == 0){
//Serial.println("non-aktif");
digitalWrite(led6,HIGH);
digitalWrite(led3,LOW);  
digitalWrite(led4,LOW);
}


  
}



void mulai(){
//Serial.println("mulai");

lcd.setCursor(0,0);
lcd.print("FATIGUE  WARNING");
lcd.setCursor(8,1);
lcd.print("TR=");
lcd.print(menit);
lcd.print(":");
lcd.print(detik);
lcd.print(" ");


if((detik <= 0)&&(menit > 0)){
detik = 59;
menit--;
}

if((detik < 0)&&(menit == 0)){
detik = 0;  
lcd.clear();
return; 
}


onoff = digitalRead(btonoff);

if(onoff == 0){
lcd.clear();  
detik = 0;
return;
}  

detik--;
   
x = digitalRead(btreset);  

if((x == 0)&&(mark == 0)){
  mark = 1;
  delay(200);
  //if(x == 1){
  //Serial.println("kena reset");
  digitalWrite(led5,HIGH);
  delay(1000);
  digitalWrite(led5,LOW);
  lcd.clear();
  detik = 0;
  return;
  //}
}


if((x == 1)&&(mark == 1)){
  delay(200);
  mark = 0;  
}

counter++;
//Serial.println(counter);

if (counter >= jalan){
digitalWrite(led3,HIGH);   
digitalWrite(led2,LOW);
delay(500);
digitalWrite(led3,LOW);
digitalWrite(led2,LOW);
delay(500);
}
if (counter < jalan){
digitalWrite(led3,LOW);
digitalWrite(led2,HIGH);
delay(500);
digitalWrite(led2,LOW);
delay(500);
}

if(counter >= jalanx){
digitalWrite(led4,HIGH);
}
if(counter < jalanx){
digitalWrite(led4,LOW);
}

mulai();
}





b. VIDEO HASILNYA