Translate

Timer Counter Board Mini 4WD 3 Jalur Line / Track

 Timer Counter Board Mini 4WD 3 Jalur Line / Track 

        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa digunakan untuk counter timer untuk balapan mobil mini 4WD, jadi alat ini menggunakan 3 buah sensor sesuai dengan jumlah track yang dipakai kemudian terdapat 3 lap sehingga jika ada yang telah mencapai 3 lap terlebih dahulu dialah yang menang. untuk lebih jelasnya berikut adalah koding dan komponennya.

 

a. Arduino Uno


b. Sensor Proximity


c. Koneksi Arduino ke P10 HUB12



d. Program Arduino IDE

#include <Wire.h>
#include <SPI.h>        //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h>        //Library DMD yang menyediakan fungsi penampilan teks, gambar dsb
#include <TimerOne.h>   //Library peripheral Timer1 untuk menjalankan prosedur pindai panel DMD
#include <Time.h>     //Library waktu yang menyediakan tipe data, struktur, dan obyek waktu
#include "Arial_black_16.h"
#include "Arial_Black_16_ISO_8859_1.h"
#include "Arial14.h"
#include "DejaVuSans9.h"
#include "Droid_Sans_12.h"
#include "Droid_Sans_16.h"
#include "DejaVuSansItalic9.h"
#include "Mono5x7.h"
#include "SystemFont5x7.h"

#define WAKTU_TAMPIL_JAM      10    //detik
#define WAKTU_TAMPIL_KALENDAR 5     //detik

#define DISPLAY_COLUMN_COUNT  2
#define DISPLAY_ROW_COUNT     1

#define PIXELS_PER_COLUMN  32
#define PIXELS_PER_ROW    16

DMD dmd(DISPLAY_COLUMN_COUNT, DISPLAY_ROW_COUNT);
unsigned char show = 0;

char lineBuff[20];
char lineBuff2[20];

int lineA;
int lineB;
int lineC;
int mulai;
int seconds;
int cs;
long start_time = 0;
int lapa,lapb,lapc;
 
void ScanDMD()
{
  dmd.scanDisplayBySPI();
}


void setup(void)
{
 
  pinMode(2,INPUT);
  pinMode(3,INPUT);
  pinMode(4,INPUT);
 
  dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
  Serial.begin(9600);
   //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 1000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
  Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
 
  //clear/init the DMD pixels held in RAM
  dmd.clearScreen( true );
 
}


void loop(void)
{

//============================================
lineA = digitalRead(2);
lineB = digitalRead(3);
lineC = digitalRead(4);

if((lineA == 0)&&(lineB == 1)&&(lineC == 1)&&(mulai == 1)){
lapa++;
delay(100);
}

if((lineA == 1)&&(lineB == 0)&&(lineC == 1)&&(mulai == 1)){
lapb++;
delay(100);
}

if((lineA == 1)&&(lineB == 1)&&(lineC == 0)&&(mulai == 1)){
lapc++;
delay(100);
}

if((lineA == 0)&&(lineB == 0)&&(lineC == 1)&&(mulai == 1)){
lapa++;
lapb++;
delay(100);
}

if((lineA == 0)&&(lineB == 1)&&(lineC == 0)&&(mulai == 1)){
lapa++;
lapc++;
delay(100);
}

if((lineA == 1)&&(lineB == 0)&&(lineC == 0)&&(mulai == 1)){
lapb++;
lapc++;
delay(100);
}

if((lineA == 0)&&(lineB == 0)&&(lineC == 0)&&(mulai == 1)){
lapa++;
lapb++;
lapc++;
delay(100);
}

//=============================================
if(lapa > 2){
dmd.clearScreen( true );  
hasila();  
}

if(lapb > 2){
dmd.clearScreen( true );  
hasilb();  
}

if(lapc > 2){
dmd.clearScreen( true );  
hasilc();  
}

//=============================================
lineA = digitalRead(2);

if((lineA == 0)&&(mulai == 0)){
  delay(200);
  mulai = 1;
  start_time = millis();  
}  

if(mulai == 1){
seconds = (millis() - start_time) / 1000;
cs = ((millis() - start_time) / 10) % 100;;
}

//===========================================================================  
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 37,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, "%d/%d/%d ", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
//===========================================================================

}


void hasila(){
 
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 35,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, " A", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  

hasila();  
}


void hasilb(){
 
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 35,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, " B", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  

hasilb();  
}


void hasilc(){
 
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 35,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, " C", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  

hasilc();  
}

 

e. VIDEO HASILNYA



Simulasi Autoclave Arduino Sensor MPX5500 dan Thermocouple Tipe-K

Simulasi Autoclave Arduino Sensor MPX5500 dan Thermocouple Tipe-K 

      Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk memanaskan benda di suhu tertentu agar bersih dari kuman atau bakteri, jadi alat ini terdapat dua sensor yaitu sensor suhu dan sensor tekanan. yang dimonitor adalah suhunya terlebih dahulu kemudian tekanannya dalam satuan bar. untuk lebih jelasnya berikut koding dan kompoennya.

 

a. Komponen


 

b. Program Arduino IDE

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

int thermoDO = 4; //bisa juga S0
int thermoCS = 5;
int thermoCLK = 6; //bisa juga SCK
int dataku;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

int solenoid = 7;
int heater = 8;
int btset = 12;
int btsetx;
int sp = 125;
int mark;
int buzzer = 9;
int sensorValue;
float sensorVoltage;
float kPa;
float bar;

DS3231 rtc(SDA, SCL);
Time t;


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

  rtc.begin();
  rtc.setDOW(FRIDAY);     // Set Day-of-Week to SUNDAY
  rtc.setTime(0, 0, 0);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(13, 5, 2022);   // Set the date to January 1st, 2014

  pinMode(btset,INPUT_PULLUP);
  pinMode(solenoid,OUTPUT);
  pinMode(heater,OUTPUT);
  pinMode(buzzer,OUTPUT);
  digitalWrite(solenoid,HIGH); //OFF
  digitalWrite(heater,LOW);
  digitalWrite(buzzer,HIGH); //OFF
  delay(500);  
}


void loop() {
 
 sensorValue = analogRead(A0);
 sensorVoltage = sensorValue * (5.0 / 1023.0);
// convert the reading to it’s PSI equivilant [(Vout = Vs*(0.0018*P+0.04)), (Vs = 5.0Vdc)]
// thus: P= (-V+0.2)/0.009 (kPa)
 kPa = (sensorVoltage - 0.2) / 0.009;
 bar = kPa / 100.0;

  dataku = thermocouple.readCelsius();

  btsetx = digitalRead(btset);
 
 if(btsetx == 0){
  mark = 1;
  lcd.setCursor(10, 1);
  lcd.print("ON");
  }

  lcd.setCursor(0, 0);
  lcd.print("T=");
  lcd.print(dataku);
  lcd.print(" ");
  lcd.print("P=");
  lcd.print(bar);
  lcd.print("   ");
  lcd.setCursor(0, 1);
  lcd.print("SP=");
  lcd.print(sp);
  lcd.print(" ");

if((dataku < sp)&&(mark == 1)){
digitalWrite(heater,HIGH);
}

if((dataku >= sp)&&(mark == 1)){
lcd.clear();
delay(2000);
rtc.setTime(0, 29, 0);
mulai();
pendinginan();
}
 
delay(200);
}


void pendinginan(){

 sensorValue = analogRead(A0);
 sensorVoltage = sensorValue * (5.0 / 1023.0);
// convert the reading to it’s PSI equivilant [(Vout = Vs*(0.0018*P+0.04)), (Vs = 5.0Vdc)]
// thus: P= (-V+0.2)/0.009 (kPa)
 kPa = (sensorVoltage - 0.2) / 0.009;
 bar = kPa / 100.0;
 
  digitalWrite(heater,LOW); //OFF
    
  lcd.setCursor(0, 0);
  lcd.print("Pendinginan");
  lcd.setCursor(0, 1);
  lcd.print("P= ");
  lcd.print(bar);
  lcd.print("   ");

if(bar < 0.1){
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("SOLENOID ON");
   digitalWrite(solenoid,LOW); //ON solenoid
   delay(10000);
   digitalWrite(solenoid,HIGH); //OFF solenoid
   digitalWrite(heater,LOW); //OFF
   mark = 0;
   return;   
}

delay(200);
pendinginan();
}


void mulai(){

 t = rtc.getTime();
 
 sensorValue = analogRead(A0);
 sensorVoltage = sensorValue * (5.0 / 1023.0);
// convert the reading to it’s PSI equivilant [(Vout = Vs*(0.0018*P+0.04)), (Vs = 5.0Vdc)]
// thus: P= (-V+0.2)/0.009 (kPa)
 kPa = (sensorVoltage - 0.2) / 0.009;
 bar = kPa / 100.0;
 
 dataku = thermocouple.readCelsius();

  lcd.setCursor(0, 0);
  lcd.print("T=");
  lcd.print(dataku);
  lcd.print(" ");
  lcd.print("P=");
  lcd.print(bar);
  lcd.print("   ");
 
  lcd.setCursor(0, 1);
  lcd.print("SP=");
  lcd.print(sp);
  lcd.print(" ");
  lcd.print(t.hour);
  lcd.print(":");
  lcd.print(t.min);
  lcd.print(":");
  lcd.print(t.sec);
  lcd.print("   ");

if(dataku < sp){
digitalWrite(heater,HIGH);
}

if(dataku >= sp){
digitalWrite(heater,LOW);
}

if(t.min == 30){
 lcd.clear();
 digitalWrite(buzzer,LOW); //ON
 delay(3000);
 digitalWrite(buzzer,HIGH); //OFF
 return;
}
 
delay(200);  
mulai();  
}

 

 

c. VIDEO HASILNYA


Kendali Motor Stepper Menggunakan Fingerprint Arduino

 Kendali Motor Stepper Menggunakan Fingerprint Arduino

           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan sensor fingerprint untuk mengendalikan motor stepper. alat ini menggunakan driver TB6600 dan arduino. untuk fingerprint yang digunakan menggunakan modul DY-50 untuk lebih jelasnya berikut adalah komponen dan kodingnya.


a. Komponen yang dipakai


b. Program Arduino IDE

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#define dirPin 2
#define stepPin 3

int getFingerprintIDez();
int parkir1;
int parkir2;
int parkir3;
int parkir4;
int parkir5;
int parkir6;

int nilaifp;
int a,b,c,d;
int cw, ccw;
int stepsPerRevolution;

SoftwareSerial mySerial(10,11);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()
{
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);

  pinMode(A1,INPUT);
  pinMode(A2,INPUT);
  pinMode(A3,INPUT);
  pinMode(A4,INPUT);
  pinMode(A5,INPUT);
  pinMode(A6,INPUT);
 
  Serial.begin(9600);
  Serial.println("fingertest");

  // set the data rate for the sensor serial port
  finger.begin(57600);
 
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
  Serial.println("Waiting for valid finger...");
}

void loop()                     // run over and over again
{
  getFingerprintIDez();
  delay(50);            //don't ned to run this at full speed.
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
 
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }  
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);  
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  bacasensor();
 
  if(finger.fingerID == 0){
  nilaifp = 1;
  stepsPerRevolution = 0;
  }
 
  if(finger.fingerID == 1){
  nilaifp = 2;
  stepsPerRevolution = 600;
  gerakccw();
  delay(3000);
  stepsPerRevolution = 600;
  gerakcw();
  }
 
  if(finger.fingerID == 2){
  nilaifp = 3;
  stepsPerRevolution = 1200;
  gerakccw();
  delay(3000);
  stepsPerRevolution = 1200;
  gerakcw();
  }

  if(finger.fingerID == 3){
  nilaifp = 4;
  stepsPerRevolution =1800;
  gerakcw();
  delay(3000);
  stepsPerRevolution = 1800;
  gerakccw();
  }

  if(finger.fingerID == 4){
  nilaifp = 5;
  stepsPerRevolution = 1200;
  gerakcw();
  delay(3000);
  stepsPerRevolution = 1200;
  gerakccw();
  }

  if(finger.fingerID == 5){
  nilaifp = 6;
  stepsPerRevolution = 600;
  gerakcw();
  delay(3000);
  stepsPerRevolution = 600;
  gerakccw();
  }

  return finger.fingerID;
}

void gerakcw(){
 
digitalWrite(dirPin, LOW); // CW    
for (int i = 0; i < stepsPerRevolution; i++) {
 digitalWrite(stepPin, HIGH);
 delayMicroseconds(1000); // ganti delay untuk mempercepat motor
 digitalWrite(stepPin, LOW);
 delayMicroseconds(1000); // ganti delay untuk mempercepat motor
}  
 
}

void gerakccw(){
 
digitalWrite(dirPin, HIGH); // CCW    
for (int i = 0; i < stepsPerRevolution; i++) {
 digitalWrite(stepPin, HIGH);
 delayMicroseconds(1000); // ganti delay untuk mempercepat motor
 digitalWrite(stepPin, LOW);
 delayMicroseconds(1000); // ganti delay untuk mempercepat motor
}  
 
}

void bacasensor(){

//jika terdeteksi ada yg parkir nilainya 0
//kosong nilainya 1

parkir1 = digitalRead(A1);
parkir2 = digitalRead(A2);
parkir3 = digitalRead(A3);
parkir4 = digitalRead(A4);
parkir5 = digitalRead(A5);
parkir6 = digitalRead(A6);  

Serial.print("Parkir: ");
Serial.print(parkir1);
Serial.print(parkir2);
Serial.print(parkir3);
Serial.print(parkir4);
Serial.print(parkir5);
Serial.println(parkir6);  
 
}



c. VIDEO HASILNYA


MONITOR TEMPERATURE HUMIDITY DHT11 PANEL P10 RGB HUB75

MONITOR TEMPERATURE HUMIDITY DHT11 PANEL P10 RGB HUB75
 

       Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor suhu dan kelembaban dengan menggunakan interface panel p10 rgb dengan hub75 dan Arduino. untuk lebih jelasnya berikut adalah komponen dan kodingnya.
 
 
a. Arduino Uno
 

 
b. Panel P10 RGB HUB75
 


 
c. Sensor DHT11
 

 
 
d. Program Arduino IDE

#include <Wire.h>
#include <Adafruit_GFX.h>   
#include <RGBmatrixPanel.h>
#include "DHT.h"  //library dht11

#define DHTPIN 10     // pin digital untuk dht11
#define DHTTYPE DHT11   // set dht11

DHT dht(DHTPIN, DHTTYPE);  //set dht11

#define F2(progmem_ptr) (const __FlashStringHelper *)progmem_ptr

#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A   A0
#define B   A1
#define C   A2

RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);

String t,h;
int suhu,humy;

void setup()
{
  dht.begin();  //mulai dht11
  matrix.begin();
  matrix.setTextWrap(false); // Allow text to run off right edge
  matrix.setTextSize(1);
}

void loop()
{
 
  humy = dht.readHumidity();  //ambil data humidity
  suhu = dht.readTemperature();  //ambil data suhu c
 
  t = String(suhu);
  h = String(humy);
 
  matrix.fillScreen(0);
  matrix.setTextColor(matrix.Color444(1, 0, 0));
  matrix.setCursor(1, 1); //x,y
  matrix.print("T:");
  matrix.setTextColor(matrix.Color444(0, 1, 0));
  matrix.print(t);

  matrix.setTextColor(matrix.Color444(1, 1, 15));
  matrix.setCursor(1, 8); //x,y  
  matrix.print("H:");
  matrix.setTextColor(matrix.Color444(3, 1, 0));
  matrix.print(h);
 
  delay(1000);  
}




e. VIDEO HASILNYA



 
 

JAM DIGITAL PANEL P10 RGB HUB75 ARDUINO

 JAM DIGITAL PANEL P10 RGB HUB75 ARDUINO
 

         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah jam digital dengan menggunakan panel P10 RGB dengan Arduino dan RTC. jadi alat ini hanya menampilkan jam, menit dan detik dengan warna yang berbeda. untuk lebih jelasnya berikut adalah komponen dan kodingnya.

 
a. Arduino Uno



b. RTC DS3231

 

c. Panel P10 RGB


d. Program Arduino IDE

#include <Wire.h>
#include <DS3231.h>
#include <Adafruit_GFX.h>   
#include <RGBmatrixPanel.h>

DS3231  rtc(SDA, SCL);
Time  t;

#define F2(progmem_ptr) (const __FlashStringHelper *)progmem_ptr

#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A   A0
#define B   A1
#define C   A2

RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);

String jam,menit,detik;

void setup()
{
  matrix.begin();
  matrix.setTextWrap(false); // Allow text to run off right edge
  matrix.setTextSize(1);
  matrix.fillScreen(0);
  rtc.begin();
  //rtc.setDOW(THURSDAY);     // Set Day-of-Week to SUNDAY
  //rtc.setTime(15, 53, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(13, 5, 2022);   // Set the date to January 1st, 2014
}

void loop()
{
  t = rtc.getTime();

  jam = t.hour;
  menit = t.min;
  detik = t.sec;
 
  matrix.setTextColor(matrix.Color444(1, 0, 0));
  matrix.setCursor(1, 8); //x,y
  matrix.print(jam);
  matrix.setTextColor(matrix.Color444(3, 1, 0));
  matrix.print(":");
  matrix.setTextColor(matrix.Color444(0, 1, 0));
  matrix.print(menit);
 
  matrix.setCursor(10, 1); //x,y
  matrix.setTextColor(matrix.Color444(0, 0, 1));
  matrix.print(detik);
 
  delay(1000);
  matrix.fillScreen(0);
}



e. VIDEO HASILNYA

 
 

Monitor Arus Sensor ACS712 dengan WEMOS D1 ESP8266 THINGSPEAK

Monitor Arus Sensor ACS712 dengan WEMOS D1 ESP8266 THINGSPEAK

         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan esp8266 dengan sensor acs712 untuk monitoring arus dc. jadi alat ini hanya untuk monitoring arus saja menggunakan webserver thingspeak. untuk lebih jelasnya berikut adalah komponen dan kodingnya.

 

 a. Wemos D1 ESP8266


b. Sensor Arus ACS712


c. Program Arduino IDE


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

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

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

int adcarus;
float v;
float arus;
 

WiFiClient client;

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

  Serial.println("Connecting to ");
  Serial.println(ssid);

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

  WiFi.begin(ssid, pass);

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


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



void loop()
{

 adcarus = analogRead(A0);
 v = adcarus * (4.1 / 1023.0);
 arus = (v - 2.5)/0.1;

 if(arus <= 0.5 ){
  arus = 0;
 }
 
  lcd.setCursor(0,0);
  lcd.print("Arus: ");
  lcd.print(arus);
  lcd.print("   ");
 
  if (client.connect(server,80))   //   "184.106.153.149" or api.thingspeak.com
              {
                           
                             String postStr = apiKey;
                             postStr +="&field1=";
                             postStr += String(arus);
                             postStr += "\r\n\r\n";

                             client.print(String("GET ") + resource + apiKey + "&field1=" + arus + " 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("arus: ");
                             Serial.print(arus);
                             Serial.println(". Send to Thingspeak.");
                        }
                       
          client.stop();

          Serial.println("Waiting...");
 
  // thingspeak needs minimum 15 sec delay between updates, i've set it to 30 seconds
  delay(10000);
}



d. VIDEO HASILNYA


 

Monitor Tegangan dan Arus DC ESP32 THINGSPEAK

Monitor Tegangan dan Arus DC ESP32 THINGSPEAK

           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor tegangan dan arus dc dengan menggunakan ESP32 dengan sensor yaitu ACS712 dan modul VDC. untuk lebih jelasnya berikut adalah komponen dan kodingnya.

 

a. Modul ESP32


b. Sensor Arus ACS712


c. Sensor Tegangan DC

 

d. Program Arduino IDE

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

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

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

WiFiClient client;

int dataadc1;
int dataadc2;
float tegangan;
float arus;
float arusdc;


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

  Serial.println("Connecting to ");
  Serial.println(ssid);

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

  WiFi.begin(ssid, pass);

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

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

}


void loop() {

  dataadc1 = analogRead(35); //tegangan
  tegangan = dataadc1 * (3.9 / 4095.0) * 4.8;

  dataadc2 = analogRead(34); //arus
  arus = dataadc2 * (3.5 / 4095.0);
  arusdc = (arus - 2.5)/0.1;

  if(arusdc < 0){
    arusdc = 0;
  }
    
  lcd.setCursor(0,0);
  lcd.print("V= ");
  lcd.print(tegangan);
  lcd.print("    ");
  lcd.setCursor(0,1);
  lcd.print("I= ");
  lcd.print(arusdc);
  lcd.print("    ");
 
 if (client.connect(server,80))   //   "184.106.153.149" or api.thingspeak.com
                   {
                           
                             String postStr = apiKey;
                             postStr +="&field1=";
                             postStr += String(tegangan);
                             postStr += "\r\n\r\n";

                             client.print(String("GET ") + resource + apiKey + "&field1=" + tegangan + "&field2=" + arusdc + " 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.println(". Send to Thingspeak.");
                        }
                       
          client.stop();

          Serial.println("Waiting...");
 
  // thingspeak needs minimum 15 sec delay between updates, i've set it to 30 seconds
  delay(15000);
}



e.. VIDEO HASILNYA



Simulasi Autoclave Arduino

Simulasi Autoclave Arduino

          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat melakukan sterilisasi benda berbasis panas, jadi seperti halnya autoclave yang dapat melakukan sterilisasi, alat ini merupakan simulasi dari autioclave yang terdapat beberapa modifikasi yaitu terdapat timer dan juga terdapat saluran untuk pembuangan udara panas. untuk lebih jelasnya berikut adalah skema dan kodingnya 


a. Arduino



b. Sensor thermocouple tipe K



c. Solid state relay


d. Program Arduino IDE

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

int thermoDO = 4; //bisa juga S0
int thermoCS = 5;
int thermoCLK = 6; //bisa juga SCK
int dataku;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

int kipas = 2;
int solenoid = 3;
int heater = 7;
int fanac = 8;
int btset = 9;
int btup = 10;
int btdown = 12;
int btsetx;
int btupx;
int btdownx;
int sp = 110;
int mark;

Servo myservo;
DS3231 rtc(SDA, SCL);
Time t;


void setup() {
  lcd.begin();
  lcd.noCursor();
  lcd.clear();
  Serial.begin(9600);
  myservo.attach(11);
  myservo.write(100);

  rtc.begin();
  rtc.setDOW(FRIDAY);     // Set Day-of-Week to SUNDAY
  rtc.setTime(0, 0, 0);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(13, 5, 2022);   // Set the date to January 1st, 2014

  pinMode(btset,INPUT_PULLUP);
  pinMode(btup,INPUT_PULLUP);
  pinMode(btdown,INPUT_PULLUP);
  pinMode(kipas,OUTPUT);
  pinMode(solenoid,OUTPUT);
  pinMode(heater,OUTPUT);
  pinMode(fanac,OUTPUT);
  digitalWrite(kipas,HIGH);
  digitalWrite(solenoid,LOW);
  digitalWrite(fanac,HIGH);
  digitalWrite(heater,LOW);
  delay(500);  
}


void loop() {
 
  dataku = thermocouple.readCelsius();

  btsetx = digitalRead(btset);
  btupx = digitalRead(btup);
  btdownx = digitalRead(btdown);

 if(btsetx == 0){
  lcd.clear();
  delay(2000);
  setsuhu();
  }

  lcd.setCursor(0, 0);
  lcd.print("SUHU= ");
  lcd.print(dataku);
  lcd.print("   ");
  lcd.setCursor(0, 1);
  lcd.print("SP= ");
  lcd.print(sp);
  lcd.print("   ");

if((dataku < sp)&&(mark == 1)){
digitalWrite(heater,HIGH);
}

if((dataku >= sp)&&(mark == 1)){
lcd.clear();
delay(2000);
rtc.setTime(0, 59, 0);
mulai();
pendinginan();
}
 
delay(200);
}



void pendinginan(){
 
  myservo.write(150);
  digitalWrite(kipas,LOW);
  digitalWrite(fanac,HIGH);
  digitalWrite(heater,LOW);
    
  dataku = thermocouple.readCelsius();

  lcd.setCursor(0, 0);
  lcd.print("Pendinginan");
  lcd.setCursor(0, 1);
  lcd.print("Suhu= ");
  lcd.print(dataku);
  lcd.print("   ");

if(dataku < 30){
   digitalWrite(solenoid,HIGH); //buka solenoid
   lcd.clear();
   delay(2000);
   myservo.write(100);
   digitalWrite(kipas,HIGH);
   digitalWrite(fanac,HIGH);
   digitalWrite(heater,LOW);
   mark = 0;
   return;   
}

delay(200);
pendinginan();
}


void setsuhu(){

  btsetx = digitalRead(btset);
  btupx = digitalRead(btup);
  btdownx = digitalRead(btdown);
 
  lcd.setCursor(0, 0);
  lcd.print("SET SP= ");
  lcd.print(sp);
  lcd.print("   ");

if(btupx == 0){
  delay(200);
  sp = sp + 10;
}

if(btdownx == 0){
  delay(200);
  sp = sp - 10;
}

if(sp > 130){
  sp = 130;
}

if(sp < 110){
  sp = 110;
}

if(btsetx == 0){
  lcd.clear();
  delay(2000);
  mark = 1;
  return;
}
 
setsuhu();  
}


void mulai(){
 digitalWrite(fanac,LOW);
 t = rtc.getTime();
 
 dataku = thermocouple.readCelsius();

  btsetx = digitalRead(btset);
  btupx = digitalRead(btup);
  btdownx = digitalRead(btdown);

 if(btsetx == 0){
  lcd.clear();
  delay(2000);
  setsuhu();
  }

  lcd.setCursor(0, 0);
  lcd.print("SUHU= ");
  lcd.print(dataku);
  lcd.print("   ");
  lcd.setCursor(0, 1);
  lcd.print("SP= ");
  lcd.print(sp);
  lcd.print(" ");
  lcd.print(t.hour);
  lcd.print(":");
  lcd.print(t.min);
  lcd.print(":");
  lcd.print(t.sec);
  lcd.print("   ");

if(dataku < sp){
digitalWrite(heater,HIGH);
}

if(dataku >= sp){
digitalWrite(heater,LOW);
}

if(t.hour == 1){
 lcd.clear();
 delay(1000);
 return;
}
 
delay(200);  
mulai();  
}



e. VIDEO HASILNYA