Translate

Monitor Suhu dan Tekanan Udara Interface Delphi 7 dan Kendali Relay Wireless HC-12 DS18B20 Arduino

Monitor Suhu dan Tekanan Udara Interface Delphi 7 dan Kendali Relay Wireless HC-12 (Sensor suhu DS18B20) Arduino


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan sistem wireless untuk monitor suhu dan tekanan udara dan juga kendali relay via Delphi 7. alat ini menggunakan sensor DS18b20 dan Arduino. untuk lebih jelasnya berikut adalah koding dan skemanya.


1. Skema Transmitter



2. Skema Receiver


3. Program Arduino Transmitter

#include <Wire.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <LiquidCrystal_I2C.h>  //i2C LCD Library

#define ONE_WIRE_BUS 6 

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

LiquidCrystal_I2C lcd(0x27, 16, 2); 

int angka;
int relay1 = 4;
int relay2 = 5;
int suhu;
float pressure_pascal;
float pressure_bar;
int pressure_barx;
int dataadc;
int x;
float v;
float kpa;
float mpa;

void setup()
{
  Serial.begin(9600);  
  sensors.begin();
  pinMode(relay1,OUTPUT);
  pinMode(relay2,OUTPUT);
  lcd.begin();
  lcd.clear();
  lcd.noCursor(); 
}

void loop()
{
  sensors.requestTemperatures();
  suhu = sensors.getTempCByIndex(0);
 
  x = analogRead(A0);
  v = x*(5.0/1023.0);
  pressure_pascal = (3.0*(v-0.47))*1000000.0;
  pressure_bar = pressure_pascal/10e5;
  pressure_barx = pressure_bar * 100.0; 
  
  lcd.setCursor(0,0);
  lcd.print("Suhu: ");
  lcd.print(suhu);
  lcd.print(" C  ");
      
  lcd.setCursor(0,1);
  lcd.print("Bar: "); 
  lcd.print(pressure_bar);
  lcd.print("   ");

  Serial.print("*");
  Serial.print(suhu);
  Serial.print(",");
  Serial.print(pressure_barx);
  Serial.println("#");
  delay(200);

  if (Serial.available() > 0) {
    angka = Serial.parseInt();
    lcd.setCursor(14,1);
    lcd.print(angka); 

    if(angka == 1){
      digitalWrite(relay1,HIGH);
    }    
    if(angka == 2){
      digitalWrite(relay1,LOW);
    }    
    if(angka == 3){
      digitalWrite(relay2,HIGH);
    }    
    if(angka == 4){
      digitalWrite(relay2,LOW);
    }
    
  }  


4. Program Arduino Receiver

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

SoftwareSerial HC12(10, 11);

int value1;
int value2;
int suhu = 0;
float bar = 0;
int datain1;
int datain2;
int barx;
char str;
int angka;

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

void setup(){
dataIn=""; 
lcd.begin();
lcd.clear();
lcd.noCursor();
Serial.begin(9600);
HC12.begin(9600); 
}

void loop(){
    
  lcd.setCursor(0,0);
  lcd.print(suhu);
  lcd.print("/");
  lcd.print(bar);
  lcd.print("/");
  lcd.print(angka);
  lcd.print(" ");
  barx = bar;
  
  Serial.print(suhu),Serial.println ('a');
  Serial.print(barx),Serial.println ('b');

if(Serial.available()>0)
{

str = Serial.read();

if(str == '1')
{
 angka = 1; 
 HC12.print(angka);  
}

if(str == '2')
{
 angka = 2; 
 HC12.print(angka); 
}

if(str == '3')
{
 angka = 3; 
 HC12.print(angka);  
}

if(str == '4')
{
 angka = 4; 
 HC12.print(angka);  
}

}

delay(1000);

//secara wireless
if(HC12.available()>0) {
    char inChar = (char)HC12.read();
    dataIn += inChar;
    if (inChar == '\n') {
    parsing = true;
  }
}

if(parsing){
    parsingData();    
    parsing=false;
    dataIn="";
  } 

}

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();

 suhu = datain1;
 bar = datain2 / 100.0;
  


5. Program 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;
    GroupBox4: TGroupBox;
    Edit3: TEdit;
    Edit4: TEdit;
    BitBtn1: TBitBtn;
    Series1: TFastLineSeries;
    Series2: TFastLineSeries;
    Edit5: TEdit;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    procedure ComPort1RxChar(Sender: TObject; Count: Integer);
    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 Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

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

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

procedure TForm1.Button2Click(Sender: TObject);
begin
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
comport1.WriteStr('1');
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
     chart1.Series[0].Clear;
     chart1.Series[1].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);
     chart1.Series[0].Add(ruang,'',clwhite) ;
     shape1.Brush.Color:=clwhite;
     end;
  if rightstr(kin,1)='b' then
     begin
     edit2.Text:=leftstr(kin,length(kin)-1);
     kulit:=strtofloat(edit2.text);
     chart1.Series[1].Add(kulit,'',clwhite) ;
     shape2.Brush.Color:=clwhite;
     end;
end;

procedure TForm1.Edit1Change(Sender: TObject);
var ruang:double;
begin
ruang:=strtofloat(edit1.text);
if ruang<30 then
   begin
   edit1.Color:=clwhite;
   edit3.text:= 'Lembab';
   end;
if ruang>31 then
   begin
   edit1.Color:=clwhite;
   edit3.text:= 'Kering';
   end;
if (ruang>=31) and (ruang<=30) then
   begin
   edit1.Color:=clwhite;
   edit3.text:= 'Normal';
   end;
end;

procedure TForm1.Edit2Change(Sender: TObject);
var kulit:double;
begin
kulit:=strtofloat(edit2.text);
if kulit<60 then
   begin
   edit2.Color:=clwhite;
   edit4.text:= 'Kering';
   end;
if kulit>61 then
   begin
   edit2.Color:=clwhite;
   edit4.text:= 'Lembab';
   end;
if (kulit>=61) and (kulit<=60) then
   begin
   edit2.Color:=clwhite;
   edit4.text:= 'Normal';
   end;
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.Button5Click(Sender: TObject);
begin
comport1.WriteStr('2');
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
comport1.WriteStr('3');
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
comport1.WriteStr('4');
end;

end.



6. VIDEO HASILNYA




Lux Meter PID Control Motor Stepper Sensor BH1750 dan Driver TB6600

Lux Meter PID Control Motor Stepper Sensor BH1750 dan Driver TB6600


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengukur LUX dan putaran motor stepper dengan menggunakan metode PID control. alat ini menggunakan sensor BH1750 dan driver stepper TB6600. untuk lebih jelasnya berikut adalah komponen dan kodingnya.


a. Komponen




b. Program Arduino IDE

/* BH1750 wiring
  VCC >>> 3.3V
  SDA >>> A4 
  SCL >>> A5
  addr >> A3
  Gnd >>>Gnd
 */
 
#include <Wire.h>
#include <BH1750FVI.h>
#include <LiquidCrystal_I2C.h> 

LiquidCrystal_I2C lcd(0x27, 16, 2); 
BH1750FVI LightSensor;
uint16_t lux;
#define dirPin 2
#define stepPin 3
int langkah;

float kp = 0.15;
float ki = 1.67;
float kd = 1.15;

float p,i,d,suhu;
float error,errorx,sumerr;
int sp = 60;
int pid;

void setup() {   
  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
  LightSensor.begin();
  LightSensor.SetAddress(Device_Address_H);//Address 0x5C
  LightSensor.SetMode(Continuous_H_resolution_Mode);
}

void loop() {

  error = sp - lux;
  p = error * kp;
  sumerr = error + errorx;
  i = ki * sumerr;
  d = kd * (error - errorx) ;
  pid = p + i + d;

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

  if(pid > 1000){
  pid = 500;
  }

  Serial.println(pid);
   
  lux = LightSensor.GetLightIntensity();

  if(lux < 55){
  if(langkah <= 150){  
  kanan();  
  }
  }

  if(lux > 65){
  if(langkah >= 0){  
  kiri();  
  }
  }

  lcd.setCursor(0,0);
  lcd.print("Lux: ");
  lcd.print(lux);
  lcd.print("   ");

  lcd.setCursor(0,1);
  lcd.print("ST: ");
  lcd.print(langkah);
  lcd.print(" ");
  lcd.print(pid);
  lcd.print("   ");
  
errorx = error;
}

void kiri(){
  digitalWrite(dirPin, LOW); // putar CCW jarum jam
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(pid); // ganti delay untuk mempercepat motor
  digitalWrite(stepPin, LOW);
  delayMicroseconds(pid); // ganti delay untuk mempercepat motor 
  langkah--; 
}

void kanan(){
  digitalWrite(dirPin, HIGH); // putar CW jarum jam
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(pid); // ganti delay untuk mempercepat motor
  digitalWrite(stepPin, LOW);
  delayMicroseconds(pid); // ganti delay untuk mempercepat motor 
  langkah++; 
}


c. VIDEO HASILNYA



Monitor Jarak dan Suhu HY-SRF05 dan DS18B20 Serta Kendali ON OFF Relay IOT BLYNK 2.0 NODEMCU ESP8266

Monitor Jarak dan Suhu HY-SRF05 dan DS18B20 Serta Kendali ON OFF Relay IOT BLYNK 2.0 NODEMCU ESP8266


       Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor suhu air dan jarak ketinggian air (water level) dengan menggunakan IOT Blynk 2.0 yang mana dapat memonitor dan mengendalikan dengan jarak jauh dengan menggunakan internet. untuk lebih jelasnya berikut adalah komponen dan kodingnya. 



a. Komponen




b. Program Arduino IDE

#define BLYNK_TEMPLATE_ID "TMXL6mWi-XXXX"
#define BLYNK_TEMPLATE_NAME "monitor suhu jarak iot"
#define BLYNK_AUTH_TOKEN "APJjyV28gzQqQTjYaeEj-KXxxXxxXxxx"
#define BLYNK_PRINT Serial  

#include <Wire.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <LiquidCrystal_I2C.h>  //i2C LCD Library

#define ONE_WIRE_BUS 13 //D7 pin of nodemcu
//define sound speed in cm/uS
#define SOUND_SPEED 0.034
#define CM_TO_INCH 0.393701

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

LiquidCrystal_I2C lcd(0x27, 16, 2); 

BlynkTimer timer;

char ssid[] = "hotspothpku";
char pass[] = "123456789";

float suhu;
int jarak;
int relay = D6;
int pinValue;
const int trigPin = D3;
const int echoPin = D8;

long duration;
float distanceCm;
float distanceInch;

BLYNK_WRITE(V2)
{
  pinValue = param.asInt();   

  if(pinValue == 1){    
  digitalWrite(relay,LOW);
  }
  
  if(pinValue == 0) {
  digitalWrite(relay,HIGH);
  }
  
}

void sendSensor()
{
Blynk.virtualWrite(V0, suhu);
Blynk.virtualWrite(V1, distanceCm);
}

void setup()
{
  Serial.begin(9600);  
  sensors.begin();
  pinMode(relay,OUTPUT);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  timer.setInterval(1L, sendSensor);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
}

void loop()
{
sensors.requestTemperatures();
suhu = sensors.getTempCByIndex(0);

  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  
  // Calculate the distance
  distanceCm = duration * SOUND_SPEED/2;  

  lcd.setCursor(0,0);
  lcd.print("Suhu: ");
  lcd.print(suhu,1);
  lcd.print(" C  ");
      
  lcd.setCursor(0,1);
  lcd.print("S: "); 
  lcd.print(distanceCm);
  lcd.print(" cm   ");

  delay(1);
  
  Blynk.run(); 
  timer.run();



c. VIDEO HASILNYA




Monitor Tegangan VAC 220v dengan Notifikasi SMS ARDUINO

Monitor Tegangan VAC 220v dengan Notifikasi SMS ARDUINO  


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mendeteksi tegangan AC 220 volt dengan notifikasi via sms, jadi ketika istrik padam maka akan ada notifikasi sms dan jika listrik nyala juga akan ada notifikasi sms. untuk lebih jelasnya berikut adalah komponen dan kodingnya.


a. Komponen




b. Program Arduino IDE

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

LiquidCrystal_I2C lcd(0x27,16,2);

int vin = 0;
int iin = 0;
int vout;
float kal;

int a = 0;
int zero = 1;
int kondisi = 0;
int dataadc;

char string[160];
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
unsigned long values[100];

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

  Serial.println("GSM Shield testing.");
     if (gsm.begin(2400)) {
          Serial.println("\nstatus=READY");
          started=true;
     } else Serial.println("\nstatus=IDLE");

     if(started) {
           if (sms.SendSMS("088123456789", "Alat Ready"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("082123456789", "Alat Ready"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("083123456789", "Alat Ready"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("085123456789", "Alat Ready"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("085123456789", "Alat Ready"))
          Serial.println("\nSMS sent OK");
     }
     
}

void loop() {

dataadc = analogRead(A3);

if(dataadc > 1000){
  lcd.setCursor(0,0);
  lcd.print("Vac: 0     ");
  lcd.print("    ");
}

if(dataadc < 1000){
  lcd.setCursor(0,0);
  lcd.print("Vac: 220  ");
  lcd.print("    ");
}

 if((dataadc > 1000)&&(kondisi == 1)){
           if (sms.SendSMS("088123456789", "LISTRIK BLUMBANG BUNDER MATI"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("082123456789", "LISTRIK BLUMBANG BUNDER MATI"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("083123456789", "LISTRIK BLUMBANG BUNDER MATI"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("085123456789", "LISTRIK BLUMBANG BUNDER MATI"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("085123456789", "LISTRIK BLUMBANG BUNDER MATI"))
          Serial.println("\nSMS sent OK");
      kondisi = 0;
      delay(3000);
   }
 
 if((dataadc < 1000)&&(kondisi == 0)){
           if (sms.SendSMS("088123456789", "LISTRIK BLUMBANG BUNDER NYALA"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("082123456789", "LISTRIK BLUMBANG BUNDER NYALA"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("083123456789", "LISTRIK BLUMBANG BUNDER NYALA"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("085123456789", "LISTRIK BLUMBANG BUNDER NYALA"))
          Serial.println("\nSMS sent OK");
           if (sms.SendSMS("085123456789", "LISTRIK BLUMBANG BUNDER NYALA"))
          Serial.println("\nSMS sent OK");
      kondisi = 1;
      delay(3000);
   }
     
delay(200);
}



c. VIDEO HASILNYA




Monitor Gula Darah Non Invasive Notif Telegram IOT SP8266 Nodemcu

Monitor Gula Darah Non Invasive Notif Telegram IOT SP8266 Nodemcu


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat dapat memonitor gula darah secara non invasive dengan menggunakn notifikasi Telegram dengan IOT ESP8266 Nodemcu. untuk lebih jelasnya berikut adalah koding dan komponennya.


a. Komponen




b. Program ESP8266

#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>

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

char ssid[ ] = "hotspothpku";
char pass[ ] = "12345678";//password wifi

#define BOTtoken "6479039456:AAEewLE_SoxTckygc_A1EgP8lXxxxxxxxxx" //token bot telegram
#define idChat "123456789" //idbot

WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

int bt = D6;
int btx = 0;
int adcsensor;
float fix;
int datafix;
int cacah = 0;
float kalibrasi;
int tanda = 0;
int buzzer = D7;

void setup() {

  pinMode(buzzer,OUTPUT);
  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  
  pinMode(bt,INPUT_PULLUP);
  digitalWrite(bt,HIGH);

  client.setInsecure();
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

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("      "); 
}

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(); 

    bot.sendChatAction(idChat, "Sedang mengetik...");
    Serial.print("Mg/dl : ");
    Serial.println(fix);
    delay(2000);
    
    String suhu = " Gula Darah : ";
    suhu += float(fix);
    suhu += " mg/dl\n";
    suhu += "Informasi Kesehatan Penyakit Tidak Menular Diabetes Militus, bisa akses di:https://drive.google.com/drive/folders/xxxxxxxxxxxxxxxx \n";
    bot.sendMessage(idChat, suhu, "");
    Serial.print("Mengirim data sensor ke telegram");
   
  tanda = 0;
  }

  if(fix > 100){
    digitalWrite(buzzer,HIGH);
    delay(3000);
    digitalWrite(buzzer,LOW);
  }

}

}



c. VIDEO HASILNYA






ALAT TEST BUTA WARNA ESP32 WEBSERVER

ALAT TEST BUTA WARNA ESP32 WEBSERVER


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat digunakan untuk melakukan test buta warna, jadi nanti ada 5 buah kertas test yang mana nanti akan diinputkan kedalam alat sehingga bisa muncul nilainya. untuk lebih jelasnya berikut adalah koding dan komponenya.



a. Komponen


 

b. Program ESP32

#include <Wire.h>
#include <Keypad.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <LiquidCrystal_I2C.h>
#include <ESP32Servo.h>
#include <SPI.h>

static const int servoPin = 18;

LiquidCrystal_I2C lcd(0x27, 16, 2);

Servo servo1;

int benar;
char customKey;
const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {13,12,14,27};
byte colPins[COLS] = {26,25,33,32};

int x = 0;
int nilaisetmax = 0;
int nilai,angka;

Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);

const char* ssid = "hotspothpku";
const char* password = "123456789";

WiFiServer server(80);
//AsyncWebServer server(80);

void setup()
{
  lcd.begin();
  lcd.clear();
  lcd.noCursor();

  Serial.begin(9600);
  
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");
  
  servo1.attach(servoPin);
  servo1.write(100);
}

void loop()
{
  test1();
  gerakservo();
  test2();
  gerakservo();
  test3();
  gerakservo();
  test4();
  gerakservo();
  test5();   
  gerakservo();
  hasil();
     
}

void gerakservo(){
servo1.write(150);  
delay(1000);
servo1.write(100);
}

void hasil(){

WiFiClient client = server.available();

int result = benar * 20;

lcd.setCursor(0,0);
lcd.print("NILAI: "); 
lcd.print(result); 

if(result < 90){
lcd.setCursor(0,1);
lcd.print("BUTA WARNA  "); 
}

if(result > 90){
lcd.setCursor(0,1);
lcd.print("NORMAL     "); 
}

  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println("Refresh: 1");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");
   
  client.println("<center>");
  client.println("<h1>");
  client.println("Monitoring WARNA");
  client.println("</h1>");
   
  client.println("<h3>");

if(angka == 0){  
  client.println("BUDI ");
if(result > 90){
  client.println(" NORMAL ");
  }
if(result < 90){
  client.println(" BUTA WARNA ");
  }  
}  
  client.println("<br>");

if(angka == 1){  
  client.println("DEWI ");
if(result > 90){
  client.println(" NORMAL ");
  }
if(result < 90){
  client.println(" BUTA WARNA ");
  }  

if(angka == 2){  
  client.println("TONI ");
if(result > 90){
  client.println(" NORMAL ");
  }
if(result < 90){
  client.println(" BUTA WARNA ");
  }  
 
  client.println("</h3>");  
  client.println("</center>");
  client.println("</html>");

  delay(1);

customKey = customKeypad.getKey();
 if(customKey == 'B'){
      lcd.clear();
      angka++;
      delay(1000);
      return;
  }
    
hasil();  
}

void test1(){
  
  lcd.setCursor(0,0);
  lcd.print("JAWAB 1 ");

  customKey = customKeypad.getKey();
 
  if(customKey >= '0' && customKey <= '9')
    {
      nilai = nilai * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print(nilai);
    }

 if(customKey == 'A'){
      
      if(nilai == 2){
       benar++;   
       }
               
      lcd.clear();
      delay(1000);
      nilai = 0;
      return;
  }
    
delay(200); 
test1();  
}

void test2(){
  
  lcd.setCursor(0,0);
  lcd.print("JAWAB 2 ");

  customKey = customKeypad.getKey();
 
  if(customKey >= '0' && customKey <= '9')
    {
      nilai = nilai * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print(nilai);
    }

 if(customKey == 'A'){
      
      if(nilai == 5){
       benar++;   
       }
               
      lcd.clear();
      delay(1000);
      nilai = 0;
      return;
  }
    
delay(200); 
test2();  
}

void test3(){
  
  lcd.setCursor(0,0);
  lcd.print("JAWAB 3 ");

  customKey = customKeypad.getKey();
 
  if(customKey >= '0' && customKey <= '9')
    {
      nilai = nilai * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print(nilai);
    }

 if(customKey == 'A'){
      
      if(nilai == 8){
       benar++;   
       }
               
      lcd.clear();
      delay(1000);
      nilai = 0;
      return;
  }
    
delay(200); 
test3();  
}

void test4(){
  
  lcd.setCursor(0,0);
  lcd.print("JAWAB 4 ");

  customKey = customKeypad.getKey();
 
  if(customKey >= '0' && customKey <= '9')
    {
      nilai = nilai * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print(nilai);
    }

 if(customKey == 'A'){
      
      if(nilai == 8){
       benar++;   
       }
               
      lcd.clear();
      delay(1000);
      nilai = 0;
      return;
  }
    
delay(200); 
test4();  
}

void test5(){
  
  lcd.setCursor(0,0);
  lcd.print("JAWAB 5 ");

  customKey = customKeypad.getKey();
 
  if(customKey >= '0' && customKey <= '9')
    {
      nilai = nilai * 10 + (customKey - '0');
      lcd.setCursor(0,1);
      lcd.print(nilai);
    }

 if(customKey == 'A'){
      
      if(nilai == 0){
       benar++;   
       }
               
      lcd.clear();
      delay(1000);
      nilai = 0;
      return;
  }
    
delay(200); 
test5();  
}



c. VIDEO HASILNYA