Translate

Monitor dan Kendali Suhu Menggunakan PID Thermocouple Tipe K

 Monitor dan Kendali Suhu Menggunakan PID Thermocouple Tipe K 


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa memonitor dan mengendalikan suhu menggunakan PID Control, alat ini menggunakan sensor thermocouple tipe K dan sensor asap. untuk fiturnya yaitu alat ini dapat diatur waktunya kapan dia ON dan OFF serta bisa disetting setpoint suhunya. untuk lebih jelasnya berikut adalah daftar komponen dan programnya.



a. Arduino Uno




b. Thermocouple Tipe K + Amplifier




c. Sensor Asap




d. RTC 




e. SSR (Solid state relay)






f. Program Arduino IDE

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

LiquidCrystal_I2C lcd(0x27, 20, 4);

int soPin = 7;
int thermoCS = 6;
int thermoCLK = 5;
int urutan;
int so1Pin  = 10;
int CS1Pin = 9;
int CLK1Pin= 8;
int ledM = 11;
int ledH = 13;
int buzzer = 12;

MAX6675 thermocouple(thermoCLK, thermoCS, soPin);
MAX6675 thermocouple1(CLK1Pin, CS1Pin, so1Pin);

int btset = A1;
int btup = A2;
int btdown = A3;
int btok = 2;
int btback = 4;
int ssr = 3;

int mark = 0;
int kipasx;
int x;
int btsetx;
int btupx;
int btdownx;
int btokx;
int btbackx;

int jam;
int asap;
int temp1;
int temp2;
int jamku;
float suhusp;
int modeku;
int menitku;

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

float p,i,d,suhu,pid;
float error,errorx,sumerr;
float sp;
float pidku;

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();
 
  pinMode(buzzer,OUTPUT);
  pinMode(ledM,OUTPUT);
  pinMode(ledH,OUTPUT);
  pinMode(ssr,OUTPUT);
  pinMode(btset,INPUT_PULLUP);
  pinMode(btup,INPUT_PULLUP);
  pinMode(btdown,INPUT_PULLUP);
  pinMode(btok,INPUT_PULLUP);
  pinMode(btback,INPUT_PULLUP);
 
  Wire.begin();
  Serial.begin(9600);
  // DS3231 seconds, minutes, hours, day, date, month, year
  setDS3231time(0,0,0,6,5,10,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()
{
 
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
 
  lcd.setCursor(0,0);
  // 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);
    
}

void loop()
{
  digitalWrite(ssr,HIGH);
  
  asap = analogRead(A0);  
  temp1 = thermocouple.readCelsius();
  temp2 = thermocouple1.readCelsius();
    
  lcd.setCursor(0,1);
  lcd.print("SUHU1 : "); 
  lcd.print(temp1 );
  lcd.print(" 'C     ");
  
  lcd.setCursor(0,2);
  lcd.print("SUHU2 : "); 
  lcd.print(temp2);
  lcd.print(" 'C     ");

  lcd.setCursor(0,3);
  lcd.print("ASAP: "); 
  lcd.print(asap);
  lcd.print("   ");
  
  btsetx = digitalRead(btset);
  
  if(btsetx == 0){
  delay(200);
  lcd.clear();  
  pilih();
  }
  
  if(modeku == 1){
  delay(200);
  lcd.clear();    
  setmanual();
  setDS3231time(0,0,0,6,5,10,18); 
  mulaimanu();
  }

  if(modeku == 2){
  delay(200);
  lcd.clear();    
  setDS3231time(0,0,0,6,5,10,18); 
  
  suhusp = 32.2;
  urutan = 1;
  mulaioto();
  
  suhusp = 48.8;
  urutan = 2;
  mulaioto();
  
  suhusp = 54.4;
  urutan = 3;
  mulaioto();
  
  suhusp = 65.5;
  urutan = 4;
  mulaioto();
  }   
      
  //displayTime();
  delay(1000);
   
}

void pilih(){

  btokx = digitalRead(btok);
  btbackx = digitalRead(btback);
  
  lcd.setCursor(5,0);
  lcd.print("PILIH MODE"); 
  lcd.setCursor(0,2);
  lcd.print("MANUAL      OTOMATIS");
  
  if(btokx == 0){
  delay(1000);
  lcd.clear();  
  modeku = 2;
  return;
  }
  
  if(btbackx == 0){
  delay(1000);
  lcd.clear();    
  modeku = 1;
  return;
  }

pilih();
}

void setmanual(){
  
lcd.setCursor(0,0);
lcd.print("PILIH JAM: ");  
lcd.print(jamku);
lcd.print("   "); 
lcd.setCursor(0,1);
lcd.print("PILIH MENIT: ");  
lcd.print(menitku);
lcd.print("   "); 
lcd.setCursor(0,2);
lcd.print("PILIH SUHU: ");  
lcd.print(suhusp);
lcd.print("   "); 

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

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

btsetx = digitalRead(btset);
btupx = digitalRead(btup);
btdownx = digitalRead(btdown);
btokx = digitalRead(btok);
btbackx = digitalRead(btback);

if(btupx == 0){
delay(200);
menitku = menitku + 30;
}

if(btdownx == 0){
delay(200);
menitku = menitku - 30;
}

if(menitku > 30){
jamku++;
menitku = 0;
}

if(menitku < 0){
menitku = 0;
jamku--;
}

if(btokx == 0){
delay(200);
suhusp = suhusp + 0.5;
}

if(btbackx == 0){
delay(200);
suhusp = suhusp - 0.5;
}

if(btsetx == 0){
delay(200);
lcd.clear();
return;
}

setmanual();
}

void mulaimanu(){
  
  btokx = digitalRead(btok);
  btbackx = digitalRead(btback);
  
  if((btbackx == 0)&&(btokx == 0)){
  lcd.clear();
  delay(1000);
  modeku = 0;
  return;
  }
  
  analogWrite(ssr,pidku);
 
  error = suhusp - temp1;
  p = error * kp;
  sumerr = error + errorx;
  i = ki * sumerr;
  d = kd * (error - errorx) ;
  pid = p + i + d;
 
  if(pid < 1){
  pid = 0;
  }
 
  if(pid > 255){
  pid = 255;
  }
 
  pidku = 255 - pid;
 
  lcd.setCursor(11,3); 
  lcd.print(jamku);
  lcd.print(".");
  lcd.print(menitku);
  lcd.print("/");
  lcd.print(suhusp);
   
  asap = analogRead(A0); 
  temp1 = thermocouple.readCelsius();
  temp2 = thermocouple1.readCelsius();
  
  lcd.setCursor(14,1);
  lcd.print(pid);
  lcd.print("  ");
  
  lcd.setCursor(14,0);
  lcd.print("MANUAL"); 
  
  lcd.setCursor(0,1);
  lcd.print("SUHU1: "); 
  lcd.print(temp1);
  lcd.print(" 'C ");
  
  lcd.setCursor(0,2);
  lcd.print("SUHU2: "); 
  lcd.print(temp2);
  lcd.print(" 'C ");
  
  lcd.setCursor(0,3);
  lcd.print("ASAP: "); 
  lcd.print(asap);
  lcd.print(" ");
  
  displayTime();
  delay(1000);
  
  if((hour == jamku)&&(minute == menitku)){
  lcd.clear();
  delay(1000);
  modeku = 0;
  return;
  }
  
  if(asap < 500){
  digitalWrite(ledH,HIGH);
  digitalWrite(ledM,LOW);
  digitalWrite(buzzer,LOW);
  }
  
  if(asap > 500){
  digitalWrite(ledH,LOW);
  digitalWrite(ledM,HIGH);
  digitalWrite(buzzer,HIGH);
  }
  
errorx = error;  
mulaimanu();
}

void mulaioto(){
    
  btokx = digitalRead(btok);
  btbackx = digitalRead(btback);
 
 if((btbackx == 0)&&(btokx == 0)){
  lcd.clear();
  delay(1000);
  modeku = 0;
  return;
  }
  
  analogWrite(ssr,pidku);
 
  error = suhusp - temp1;
  p = error * kp;
  sumerr = error + errorx;
  i = ki * sumerr;
  d = kd * (error - errorx) ;
  pid = p + i + d;
  
  if(pid < 1){
  pid = 0;
  }
 
  if(pid > 255){
  pid = 255;
  }
 
  pidku = 255 - pid;
  
  lcd.setCursor(11,3); 
  lcd.print("1");
  lcd.print(".");
  lcd.print("30");
  lcd.print("/");
  lcd.print(suhusp);
   
  asap = analogRead(A0); 
  temp1 = thermocouple.readCelsius();
  temp2 = thermocouple1.readCelsius();
  
  lcd.setCursor(14,1);
  lcd.print(pid);
  lcd.print("  ");
  
  lcd.setCursor(14,0);
  lcd.print("OTO"); 
  lcd.print(urutan); 
  lcd.setCursor(0,1);
  lcd.print("SUHU1: "); 
  lcd.print(temp1);
  lcd.print(" 'C ");
  
  lcd.setCursor(0,2);
  lcd.print("SUHU2: "); 
  lcd.print(temp2);
  lcd.print(" 'C ");
  
  lcd.setCursor(0,3);
  lcd.print("ASAP: "); 
  lcd.print(asap);
  lcd.print(" ");
  
  displayTime();
  delay(1000);
  
  if((hour == 1)&&(minute == 30)){
  lcd.clear();
  delay(1000);
  modeku = 0;
  return;
  }  
  
  if(asap < 500){
  digitalWrite(ledH,HIGH);
  digitalWrite(ledM,LOW);
  digitalWrite(buzzer,LOW);
  }
  
  if(asap > 500){
  digitalWrite(ledH,LOW);
  digitalWrite(ledM,HIGH);
  digitalWrite(buzzer,HIGH);
  }

errorx = error;    
mulaioto();  
}  




g. VIDEO HASILNYA









Monitor Kadar Oksigen dalam Darah (SPO2) ONLINE Thingspeak

 Monitor Kadar Oksigen dalam Darah (SPO2) ONLINE Thingspeak
 

           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengukur kadar oksigen dalam darah dengan monitor via Thingspeak secara online. jadi komunikasi alat dengan server dengan menggunakan internet. sensor yang dipakai adalah max30100 untuk lebih jelasnya berikut adalah daftar komponen dan programnya.



a. Wemos D1 mini




b. Sensor Max30100




c. LCD + I2C






d. Program Arduino IDE

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

WiFiClient client;

// ThingSpeak Settings

String apiKey = "56GJDDGKJH56GJF";
const char *ssid = "okok";
const char *pass = "123456789";
const char* server = "api.thingspeak.com";

MAX30100* pulseOxymeter;

int counter;
float Spo;

void setup() {
 
  Wire.begin();
  Serial.begin(115200);
  lcd.begin();
  lcd.clear();
 
  Serial.println("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED){\
   pulseOxymeter = new MAX30100();
 
    delay(200);
    Serial.println(".");
    }
  Serial.println("");
  Serial.println("WiFi connected");
}

void loop(){
 
pulseoxymeter_t result = pulseOxymeter->update();
 
if( result.pulseDetected == true ){
    
    lcd.setCursor(2,0);
    lcd.print( "SpO2: " );
    lcd.print( result.SaO2);
    lcd.println( " %          ");
   
 Spo = result.SaO2;
 
}
 
  counter++;

if(counter > 100){
    counter = 0;
   
if(client.connect(server, 80)){
    String postStr= apiKey;
    postStr += "&field1=";
    postStr += String(Spo);
    postStr += "\r\n\r\n";
    client.print("POST /update HTTP/1.1\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.println(Spo);
    Serial.println("%. Send to Thingspeak.");
    
  }

  client.stop();
  Serial.println("Waiting...");
  delay(15000);
}
 
}




e. Gambar Hasilnya






f. VIDEO HASILNYA






 

Monitor dan Kendali Suhu Kompor Listrik Menggunakan Arduino dan Thermocouple Tipe K

 Monitor dan Kendali Suhu Kompor Listrik Menggunakan Arduino dan Thermocouple Tipe K


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor suhu dan mengendalikan suhu agar disuatu range suhu tertentu dengan menggunakan Arduino. untuk sensor yang dipakai yaitu thermocouple tipe K dan pemanas yang digunakan adalah kompor listrik. untuk lebih jelasnya berikut adalah daftar komponen dan programnya.



a. Arduino Uno




b. LCD I2C




c. SSR AC DC




d. Driver Motor IBT2




e. Thermocouple Tipe K + Ampli




f. Program Arduino IDE

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

LiquidCrystal_I2C lcd(0x27,16,2);

int soPin = 4;
int thermoCS = 5;
int thermoCLK = 6;

int so1Pin  = 7;
int CS1Pin = 8;
int CLK1Pin= 9;
int buzzer = 12;

int motor1 = 10;
int motor2 = 11;

int bt1 = A0;
int bt2 = A1;
int bt3 = A2;
int bt4 = A3;
int bt5 = 2;

int bt1x;
int bt2x;
int bt3x;
int bt4x;
int bt5x;
int temp1;
int temp2;
int ssr = 3;

int sp = 150;
int waktu = 0;
int counter;
int mode;
int countx;

MAX6675 thermocouple(thermoCLK, thermoCS, soPin);
MAX6675 thermocouple1(CLK1Pin, CS1Pin, so1Pin);

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

  pinMode(bt1,INPUT_PULLUP);
  pinMode(bt2,INPUT_PULLUP);
  pinMode(bt3,INPUT_PULLUP);
  pinMode(bt4,INPUT_PULLUP);
  pinMode(bt5,INPUT_PULLUP);
  pinMode(ssr,OUTPUT); 
  pinMode(buzzer,OUTPUT);
  pinMode(motor1,OUTPUT);
  pinMode(motor2,OUTPUT);
  digitalWrite(buzzer,LOW);
}

void loop() {

 analogWrite(motor1,200);
 analogWrite(motor2,0);
  
 temp1 = thermocouple.readCelsius();
 temp2 = thermocouple1.readCelsius();

 bt1x = digitalRead(bt1);
 bt2x = digitalRead(bt2);
 bt3x = digitalRead(bt3);
 bt4x = digitalRead(bt4);
 bt5x = digitalRead(bt5);

 lcd.setCursor(0,0);
 lcd.print("T: "); 
 lcd.print(temp1);
 lcd.print(" / "); 
 lcd.print(temp2);
 lcd.print("     ");

 lcd.setCursor(0,1);
 lcd.print("W: "); 
 lcd.print(waktu);
 lcd.print(" P: "); 
 lcd.print(sp);
 lcd.print("    ");
 
 if(temp1 <= sp){
 digitalWrite(ssr,LOW);
 //digitalWrite(buzzer,LOW);
 }

 if(temp1 > sp){
 digitalWrite(ssr,HIGH);
 //digitalWrite(buzzer,HIGH);
 }

if(bt1x == 0){
 lcd.clear(); 
 waktu = 3000;
 mode = 1; 
 sp = 205;
 countx = 180;
 mulai();
}

if(bt2x == 0){
 lcd.clear();
 waktu = 4500;
 mode = 2; 
 sp = 230;
 countx = 225;
 mulai();
}

if(bt3x == 0){
 lcd.clear(); 
 waktu = 6000;
 mode = 3; 
 sp = 250; 
 countx = 240;
 mulai();
}
     
delay(200);
}

void mulai(){
   
 temp1 = thermocouple.readCelsius();
 temp2 = thermocouple1.readCelsius();

 bt5x = digitalRead(bt5);

 if(temp1 < sp){
 digitalWrite(ssr,LOW);
 digitalWrite(buzzer,LOW);
 }

 if(temp1 > sp){
 digitalWrite(ssr,HIGH);
 digitalWrite(buzzer,HIGH);
 }
  
 lcd.setCursor(0,0);
 lcd.print("T: "); 
 lcd.print(temp1);
 lcd.print(" / "); 
 lcd.print(temp2);
 lcd.print(" ");
 lcd.print(counter);
  
 lcd.setCursor(0,1);
 lcd.print("W: "); 
 lcd.print(waktu);
 lcd.print(" P: "); 
 lcd.print(sp);
 lcd.print("    ");  

if(temp1 >= countx){
counter++;  
}

if(counter > waktu){
  counter = 0;
  waktu = 0;
  sp = 150;
  digitalWrite(ssr,HIGH);
  lcd.clear();
  return;
}

if(bt5x == 0){
  counter = 0;
  waktu = 0;
  sp = 150;
  digitalWrite(ssr,HIGH);
  lcd.clear();
  return;
}

delay(200);  
mulai();  
}




g. VIDEO HASILNYA







Tutorial Setup Blynk untuk Arduino / Nodemcu ESP8266 / Wemos D1

 Tutorial Setup Blynk untuk Arduino / Nodemcu ESP8266 / Wemos D1
 

        Pada kesempatan kali ini saya akan menjelaskan mengenai step by step setup blynk agar terhubung ke arduino melalui internet. caranya sangatlah mudah yang pertama yaitu harus instal terlebih dahulu aplikasi blynknya bisa di playstore atau di Appstore. setelah instal aplikasinya teman-teman bisa ikuti cara lebih jelasnya yang ada di video dibawah ini. untuk koding contohnya bisa saya kasih lihat seperti dibawah ini.  



a. Nodemcu ESP8266 / Wemos D1





b. Contoh Program Arduino 

#include <Wire.h>
#define  BLYNK_PRINT Serial  
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include "MAX30105.h"
#include <LiquidCrystal_I2C.h>
#include "heartRate.h"
#include <Adafruit_MLX90614.h>
LiquidCrystal_I2C lcd(0x27, 16,2);

MAX30105 particleSensor;
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
float TargetC;
const byte RATE_SIZE = 4; //Increase this for more averaging. 4 is good.
byte rates[RATE_SIZE]; //Array of heart rates
byte rateSpot = 0;
long lastBeat = 0; //Time at which the last beat occurred

float beatsPerMinute;
int beatAvg;
int counter;

char auth[] = "hgjhgjTJUIYRgfhjjhrerewiuoiuokjhkjgfh";
char ssid[] = "myHotspot";
char pass[] = "1234567";

SimpleTimer timer;

const int speakerPin = 12;
int ledmerah = 14;
int ledhijau = 2;

void sendSensor()
{
 Blynk.virtualWrite(V5, TargetC);
 Blynk.virtualWrite(V6, beatsPerMinute);
 delay(1000);
}

void setup()
{
  
  lcd.clear();
  lcd.begin();
  lcd.noCursor();
  Serial.begin(115200);
  Serial.println("Initializing...");
   pinMode(ledmerah,OUTPUT);
   pinMode(ledhijau,OUTPUT);
   pinMode(speakerPin, OUTPUT);

   digitalWrite(ledmerah,LOW);
   digitalWrite(ledhijau,LOW);
   
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, sendSensor);

}

void loop()
{

    // Initialize sensor
  if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
  {
    Serial.println("MAX30105 was not found. Please check wiring/power. ");
    while (1);
  }
  Serial.println("Place your index finger on the sensor with steady pressure.");

  particleSensor.setup(); //Configure sensor with default settings
  particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to indicate sensor is running
  particleSensor.setPulseAmplitudeGreen(0); //Turn off Green LED

  long irValue = particleSensor.getIR();

  if (checkForBeat(irValue) == true)
  {
    //We sensed a beat!
    long delta = millis() - lastBeat;
    lastBeat = millis();

    beatsPerMinute = 60 / (delta / 1000.0);

    if (beatsPerMinute < 255 && beatsPerMinute > 20)
    {
      rates[rateSpot++] = (byte)beatsPerMinute; //Store this reading in the array
      rateSpot %= RATE_SIZE; //Wrap variable

      //Take average of readings
      beatAvg = 0;
      for (byte x = 0 ; x < RATE_SIZE ; x++)
        beatAvg += rates[x];
      beatAvg /= RATE_SIZE;
    }
  }

  counter++;

if(counter > 100){
 counter = 0;

 mlx.begin();
 TargetC = mlx.readObjectTempC();

 lcd.setCursor(0,1);
 lcd.print("Temp= ");
 lcd.print(TargetC);
 lcd.println(" 'C     ");

 if (TargetC <=  37.5) {
   digitalWrite(speakerPin, LOW);  
   digitalWrite(ledmerah,LOW);  
   digitalWrite(ledhijau,HIGH);
  }
 if (TargetC > 37.5 ) {
   digitalWrite(speakerPin, HIGH);
   digitalWrite(ledmerah,HIGH);
   digitalWrite(ledhijau,LOW);
   delay (3000);
 }
      
 Blynk.run();
 timer.run();
}

  lcd.setCursor(0,0);
  lcd.print("BPM= ");
  lcd.print(beatsPerMinute);
  lcd.println("       ");
      
  Serial.print("IR=");
  Serial.print(irValue);
  Serial.print(", BPM=");
  Serial.print(beatsPerMinute);
  Serial.print(", Avg BPM=");
  Serial.print(beatAvg);

  if (irValue < 50000)
    Serial.print(" No finger?");

  Serial.println();
}





c. VIDEO TUTORIAL






 

Deteksi Suhu Tubuh Non Contact via Telegram

 Deteksi Suhu Tubuh Non Contact via Telegram


            Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mendeteksi suhu tubuh secara non contact dengan menggunakan sensor MLX. untuk notifikasi menggunakan aplikasi telegram. jadi jika suhu telah melebihi suatu batas tertentu maka akan mengrimkan notif ke telegram dan buzzer bunyi. untuk lebih jelasnya berikut adalah program dan komponennya.



a. Wemos D1 Mini




b. Sensor MLX90614




c. Lcd 16x2 + I2C




d. Setting Telegram









e. Program Arduino IDE 

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

LiquidCrystal_I2C lcd(0x27, 16,2);

char ssid[ ] = "Hotspot HPKU";
char pass[ ] = "123456789";//password wifi

#define BOTtoken "876876875:jhgjhfGDTYDjhjoooiuoibhvrearwadxxggcfrjj" //token bot telegram
#define idChat "7657658776" //idbot

WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

 float TargetC;
 const int speakerPin = 12;
int ledmerah = 14;
int ledhijau = 2;

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {

   pinMode(ledmerah,OUTPUT);
   pinMode(ledhijau,OUTPUT);
   pinMode(speakerPin, OUTPUT);

   digitalWrite(ledmerah,LOW);
   digitalWrite(ledhijau,LOW); 
   lcd.setBacklight(HIGH);
   mlx.begin();
  lcd.clear();
  lcd.begin();
   client.setInsecure();
  Serial.begin(9600);
  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());
  mlx.begin();
  delay(5000);
  
}
void loop() {

    delay(1000);
        
  TargetC = mlx.readObjectTempC()+4;
  
 lcd.setCursor(0,0);
  lcd.print("Suhu : ");
  lcd.print(TargetC);
  lcd.println("  'C ");

     if (TargetC <  37) {
      digitalWrite(speakerPin, LOW);  
       digitalWrite(ledmerah,LOW);  
      digitalWrite(ledhijau,HIGH); 
  }

  if (  TargetC > 37) {
    bot.sendChatAction(idChat, "Sedang mengetik...");
    Serial.print("Suhu saat ini : ");
    Serial.println(TargetC);
    delay(2000);
    String suhu = " suhu sekarang : ";
    suhu += float(TargetC);
    suhu += " 'C\n";
    suhu += "Suhu maksimal!\n";
    bot.sendMessage(idChat, suhu, "");
    Serial.print("Mengirim data sensor ke telegram");
    
       if (TargetC > 37) {
      digitalWrite(speakerPin, HIGH);
        digitalWrite(ledmerah,HIGH);
        digitalWrite(ledhijau,LOW); 
     delay (3000);
    
  }  
  }
}



f. VIDEO HASILNYA






Membuat Alat Deteksi Telur Bagus / Jelek via IOT BLYNK

Membuat Alat Deteksi Telur Bagus / Jelek via IOT BLYNK


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat membedakan antara telur bagus dan telur jelek, prinsip kerjanya sederhana yaitu jika telur bagus terkena cahaya maka akan memancarkan cahaya berwarna namun jika telur jelek maka akan ada penutup yang menghalangi cahaya untuk sampai ke sensor sehingga sensor bisa mendeteksi suatu nilai. untuk lebih jelasnya berikut adalah komponen dan programnya.



a. Wemos D1




b. sensor photodioda




c. LCD + I2C 





d. Program Arduino IDE

#include <Wire.h> 
#define BLYNK_PRINT Serial  
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16,2);

int dataadc;
int tombol = D5;
int tombolx = 0;
int buzzer = 12;

char auth[] = "jhgjhgjHGJHTRSEWREhkhkjjhjhfjhfEy";
char ssid[] = "Hotspot HPKU";
char pass[] = "123456789";

SimpleTimer timer;

void sendSensor()
{
 Blynk.virtualWrite(V5, dataadc);
 delay(1000);
}

void setup() {
lcd.clear();
lcd.begin();
lcd.noCursor(); 
Wire.begin(); 
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, sendSensor);
pinMode(tombol,INPUT_PULLUP);
pinMode(buzzer,OUTPUT);
digitalWrite(buzzer,HIGH);
}


void loop() {
  
tombolx = digitalRead(tombol);

dataadc = analogRead(A0);

if(tombolx == 0){
  lcd.clear();
  mulai();
}

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

 digitalWrite(buzzer,HIGH);

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

void mulai(){
  
tombolx = digitalRead(tombol);

if(tombolx == 1){
  lcd.clear();
  return;
}

dataadc = analogRead(A0);

if((dataadc > 270)&&(dataadc < 600)&&(tombolx == 0)){
 lcd.setCursor(0,1);
 lcd.print("TELUR BAGUS      ");
 digitalWrite(buzzer,HIGH);
}
if((dataadc > 100)&&(dataadc < 270)&&(tombolx == 0)){
 lcd.setCursor(0,1);
 lcd.print("TELUR JELEK     ");
 digitalWrite(buzzer,LOW);
}
if((dataadc > 1000)){
 lcd.setCursor(0,1);
 lcd.print("LETAKKAN TELUR  ");
 digitalWrite(buzzer,HIGH);
}

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

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




e. VIDEO HASILNYA







Tensimeter Digital Online Blynk + BPM Heartbeat

 Tensimeter Digital Online Blynk + BPM Heartbeat


         Pada kesempatan kali ini saya aka menjelaskan mengenai bagaimana cara membuat sebuah tensimeter digital yang dapat dimonitor secara online menggunakan aplikasi Blynk. alat ini layaknya seperti tensimeter yang dapat mengukur sistole dan diastole serta juga dapat mengukur bpm. yang harus diperhatikan pada alat ini yaitu harus dilakukan kalibrasi secara berkala agar didapat hasil yang akurat.



a. Wemos D1 mini




b. Sensor MPX5050GP




c. LCD 16x2 + I2C




d. Sensor Bpm Max30100




e. Driver Pompa dan Solenoid




f. Skema Alat





g. Program Arduino IDE

#include <Arduino.h>
#include <math.h>
#include <Wire.h>
#define BLYNK_PRINT Serial    
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include "MAX30100.h"
#include <LiquidCrystal_I2C.h>

MAX30100* pulseOxymeter;
LiquidCrystal_I2C lcd(0x27, 16,2);

char auth[] = "hjgjhgjhGJHGOIUOiuoikjbbhvSDGDH";
char ssid[] = "hotspotku hp";
char pass[] = "123456789";

SimpleTimer timer;

float spo;
float bpm;
int counter;
int motor = D7;
int solenoid = D6;
int dataadc;
int tombol = D4;
int tombolx;
int hitung;
float vol;
float mmhg;
float mmhgx;
float sistole;
float diastole;
int sistolex;
int diastolex;
int mark = 0;

void sendSensor()
{
 Blynk.virtualWrite(V5, bpm);
 Blynk.virtualWrite(V6, sistolex);
 Blynk.virtualWrite(V7, diastolex);
 delay(1000);
}

void setup() {
  lcd.clear();
  lcd.begin();
  lcd.noCursor();
  Wire.begin();
  Serial.begin(9600);
  Serial.println("Pulse oxymeter test!");
  pulseOxymeter = new MAX30100();
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, sendSensor);
  pinMode(motor,OUTPUT);
  pinMode(solenoid,OUTPUT);
  pinMode(tombol,INPUT_PULLUP);

 lcd.setCursor(0,0);
 lcd.print("BPM= ");
 lcd.setCursor(0,1);
 lcd.print("S=   D= ");
}

void loop() {
 dataadc = analogRead(A0);
 mmhgx = (dataadc - 46.222) / 3.2;

 lcd.setCursor(0,1);
 lcd.print("S= ");
 lcd.print(sistolex);
 lcd.print(" D= ");
 lcd.print(diastolex);
 lcd.print("    ");
     
 tombolx = digitalRead(tombol); 

 if(tombolx == LOW){
  mark = 0;
  lcd.clear();
  delay(1000);
  digitalWrite(motor,HIGH);
  digitalWrite(solenoid,HIGH);
  mulai();
  }
    
  pulseoxymeter_t result = pulseOxymeter->update();
  
if( result.pulseDetected == true )
  {    
    //Serial.print( "BPM: " );
    //Serial.print( result.heartBPM );
    lcd.setCursor(0,0);
    lcd.print("BPM= ");
    lcd.print(result.heartBPM);
    lcd.print("     ");
    
    bpm = result.heartBPM;
    spo = result.SaO2;
  }

counter++;

if(counter > 100){
 counter = 0;
 Blynk.run();
 timer.run();
}

delay(10); 
}

void mulai(){
  
 dataadc = analogRead(A0);
 mmhg = (dataadc - 46.222) / 3.2;

if((mmhg >= mmhgx + 10)&&(mmhg > 100)&&(mark == 0)){
//digitalWrite(motor,LOW); 
Serial.println("SISTOLE"); 
sistole = mmhg;
mark = 2; 
digitalWrite(motor,LOW);
}

if((mmhg >= mmhgx + 5)&&(mmhg > 50)&&(mmhg < 90)&&(mark == 2)){
//digitalWrite(motor,LOW); 
Serial.println("DIASTOLE"); 
diastole = mmhg;
mark = 3;
}

 lcd.setCursor(0,1);
 lcd.print("S= ");
 lcd.print(mmhg);
 lcd.print("     ");

if(mmhg >= 150)
{
 digitalWrite(motor,LOW);   
}

mmhgx = mmhg;

Serial.println(mmhg);

if((mark == 3)&&(mmhg < 50)){
lcd.clear();
delay(1000);
mark = 0;
sistolex = sistole;
diastolex = diastole;
digitalWrite(solenoid,LOW);
Blynk.run();
timer.run();
return;  
}

delay(1);   
mulai();  
}


 

h. VIDEO HASILNYA










Kendali Kipas Angin Menggunakan Gesture Tangan Sensor APDS 9960

 Kendali Kipas Angin Menggunakan Gesture Tangan Sensor APDS 9960


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk mengendalikan kecepatan putaran kipas angin dengan menggunakan gerakan tangan atau gesture. alat ini dilengkapi dengan sensor APDS 9960 dan untuk kendali kecepatan dengan menggunakan relay modul. untuk lebih jelasnya berikut adalah program dan daftar komponennya.



a. Arduino Uno




b. Sensor Gesture APDS 9960




c. Relay Module






d. Program Arduino IDE

#include <Wire.h>
#include <SparkFun_APDS9960.h>

// Pins
#define APDS9960_INT    2 // Needs to be an interrupt pin

// Constants

// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;

int speedx;

void setup() {
  
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);

  // Set interrupt pin as input
  pinMode(APDS9960_INT, INPUT);

  // Initialize Serial port
  Serial.begin(9600);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("Y-GESTURE APDS - GestureTest"));
  Serial.println(F("--------------------------------"));
 
  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);

  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }
 
 //  Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
    Serial.println(F("Gesture sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during gesture sensor init!"));
  }
}

void loop() {
  if( isr_flag == 1 ) {
    detachInterrupt(0);
    handleGesture();
    isr_flag = 0;
    attachInterrupt(0, interruptRoutine, FALLING);
  }

if(speedx == 0){
        digitalWrite(3, HIGH);
        digitalWrite(5, HIGH);
        digitalWrite(6, HIGH);
        digitalWrite(7, HIGH);
  }

if(speedx == 1){
        digitalWrite(3, HIGH);
        digitalWrite(5, LOW);
        digitalWrite(6, HIGH);
        digitalWrite(7, HIGH);
  }

if(speedx == 2){
        digitalWrite(3, HIGH);
        digitalWrite(5, HIGH);
        digitalWrite(6, LOW);
        digitalWrite(7, HIGH);
  }  

if(speedx == 3){
        digitalWrite(3, HIGH);
        digitalWrite(5, HIGH);
        digitalWrite(6, HIGH);
        digitalWrite(7, LOW);
  }  


if(speedx > 3){  
  speedx = 3;
}

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

void interruptRoutine() {
  isr_flag = 1;
}

void handleGesture() {
    if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
        Serial.println("UP");
        speedx++;
      
        break;
      case DIR_DOWN:
        Serial.println("DOWN");
        speedx--;
        
        break;
      case DIR_LEFT:
        Serial.println("LEFT");
        digitalWrite(4, LOW);
 
        break;
      case DIR_RIGHT:
        Serial.println("RIGHT");
        digitalWrite(4, HIGH);
        
        break;
      case DIR_NEAR:
        Serial.println("NEAR");

        break;
      case DIR_FAR:
        Serial.println("FAR");

        break;
      default:
        Serial.println("NONE");
    }
  }
}





e. VIDEO HASILNYA











Tutorial Kalibrasi Tensimeter Digital

 Tutorial Kalibrasi Tensimeter Digital
 

          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara kalibrasi sebuah tensimeter digital agar hasil pengukuran bisa akurat dan sesuai standart pabrik. tutorial ini juga termasuk langkah awal didalam pembuatan tensimeter digital. sensor yang digunakan adalah mpx5050GP yang mana maksimal pengukuran adalah 50 kpa. untuk lebih jelasnya berikut adalah program dan daftar komponennya. 



a. Wemos D1 Mini




b. Sensor MPX5050GP






c. Program Arduino IDE

#include <Arduino.h>
#include <math.h>
#include <Wire.h>
#define BLYNK_PRINT Serial    
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16,2);

SimpleTimer timer;

float spo;
float bpm;
int counter;
int motor = D7;
int solenoid = D6;
int dataadc;
int tombol = D4;
int tombolx;
int hitung;
float vol;
float kpa;
float mmhg;

void setup() {
  lcd.clear();
  lcd.begin();
  lcd.noCursor();
  Serial.begin(9600);
  pinMode(motor,OUTPUT);
  pinMode(tombol,INPUT_PULLUP);
}

void loop() {

 tombolx = digitalRead(tombol);

 if(tombolx == LOW){
  digitalWrite(motor,HIGH);
  }

 if(tombolx == HIGH){
  digitalWrite(motor,LOW);
  }  
    
dataadc = analogRead(A0);
mmhg = (dataadc - 46.222) / 3.2;

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

 lcd.setCursor(0,0);
 lcd.print("ADC= ");
 lcd.print(dataadc);
 lcd.print("     ");
 lcd.setCursor(0,1);
 lcd.print("mmHg= ");
 lcd.print(mmhg);
 lcd.print("     ");
 
 delay(200);
}

 
 
d. Hasil Kalibrasi






e. VIDEO HASILNYA