Translate

IOT Project Alat Monitor Daya Arus Tegangan Power Energy Frequency Power Factor dan Kendali Relay via BLYNK

IOT Project Alat Monitor Daya Arus Tegangan Power Energy Frequency Power Factor dan Kendali Relay via BLYNK


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat dengan fungsinya yaitu sebagai monitor daya arus dan tegangan secara jarak jauh melalui internet dengan aplikasi blynk, selain itu juga kendali jarak jauh relay sehingga user bisa kendali beban secara manual dengan aplikasi blynk. untuk lebih jelasnya berikut adalah program dan daftar komponennya.



a. Arduino Uno




b. NodeMCU esp8266




c. Lcd 16x2 + I2C




d. Modul Relay




e. Sensor PZEM-004t






f. Program Arduino Uno

#include <PZEM004Tv30.h>
#include <Wire.h>  // i2C Conection Library
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2); 

PZEM004Tv30 pzem(11, 12);

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

void loop() {

    float voltage = pzem.voltage();
    int tegangan = voltage * 100;
    float current = pzem.current();
    int arus = current * 100;
    float power = pzem.power();
    int powerx = power * 100;
    float energy = pzem.energy();
    int energyx = energy * 100;
    float frequency = pzem.frequency();
    int frequencyx = frequency * 100;
    float pf = pzem.pf();
    int pfx = pf * 100;

Serial.print("*");
Serial.print(tegangan);
Serial.print(",");
Serial.print(arus);
Serial.print(",");
Serial.print(powerx);
Serial.print(",");
Serial.print(energyx);
Serial.print(",");
Serial.print(frequencyx);
Serial.print(",");
Serial.print(pfx);
Serial.println("#");  

lcd.setCursor(0, 0);
lcd.print(voltage,1);
lcd.print(" ");
lcd.print(current,1);
lcd.print(" ");
lcd.print(power,1);
lcd.print(" ");

lcd.setCursor(0, 1);
lcd.print(energy,1);
lcd.print(" ");
lcd.print(frequency,1);
lcd.print(" ");
lcd.print(pf,1);
lcd.print(" ");

delay(1000);
}



g. Program NodeMCU 

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

int temp;
int x = 5;
int y;

int value1;
int value2;

float tegangan = 0;
float arus = 0;
float powerx = 0;
float energyx = 0;
float frequencyx = 0;
float pfx = 0;

float datain1;
float datain2;
float datain3;
float datain4;
float datain5;
float datain6;

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

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "hotspotku";
char pass[] = "123456789";

SimpleTimer timer;

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

 Blynk.virtualWrite(V2, tegangan);
 Blynk.virtualWrite(V3, arus);
 Blynk.virtualWrite(V4, powerx);
 Blynk.virtualWrite(V5, energyx);
 Blynk.virtualWrite(V6, frequencyx);
 Blynk.virtualWrite(V7, pfx);
 delay(1000);

}

void setup()
{
  
  dataIn=""; 
  // Debug console
  Serial.begin(9600);

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

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

void loop()
{

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

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

}

void parsingData(){
int j=0;

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

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

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

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

//Serial.print("data 3 : ");
//Serial.print(dt[2].toInt());
//Serial.print("\n\n");

 tegangan = datain1 / 100.0;
 arus = datain2 / 100.0;
 powerx = datain3 / 100.0;
 energyx = datain4 / 100.0;
 frequencyx = datain5 / 100.0;
 pfx = datain6 / 100.0;

}




g. Interace Blynk





h. VIDEO HASILNYA









Alat Monitor Tekanan Udara Sensor MPX 5700DP

Alat Monitor Tekanan Udara Sensor MPX 5700DP


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat dengan menggunakan arduino yang berfungsi untuk mendeteksi tekanan udara menggunakan sensor mpx 5700dp. selain itu alat ini juga bisa disetting set poin sehingga pada saat kondisi tertentu beban akan on atau off sesuai kondisi yang disetting.  untuk lebih jelasnya berikut adalah program dan daftar komponennya.



a. Arduino Nano




b. LCD 16x2 + I2C





c. Modul SSR Solid State Relay




d. Sensor MPX 5700DP






e. Program Arduino IDE

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

LiquidCrystal_I2C lcd(0x27,16,2); 

int x;
float v;
float kpa;

int ssr = 12;
int bt1 = 11;
int bt2 = 10;
int bt1x;
int bt2x;
int sp;
float pa;

void setup()
{
lcd.begin();   
lcd.noCursor();
lcd.clear();
pinMode(bt1,INPUT_PULLUP);
pinMode(bt2,INPUT_PULLUP);
pinMode(ssr,OUTPUT);
digitalWrite(ssr,HIGH);
}

void loop()
{

 bt1x = digitalRead(bt1); 
 bt2x = digitalRead(bt2); 

if((bt1x == 0)&&(bt2x == 0)){
sp = 0;
}

if((bt1x == 1)&&(bt2x == 1)){
sp = 0;
}
  
if(bt1x == 0){
sp = -5;
}  
if(bt2x == 0){
sp = -15;
}
  
  x = analogRead(A0);
  v = x*(5.0/1023.0);
  kpa = ((v/5.0)-0.04)/0.0012858;
  pa = kpa * 1000;
  
  lcd.setCursor(0, 0);
  lcd.print("Pa= ");
  lcd.print(kpa);
  lcd.print("    ");
  lcd.setCursor(0, 1);
  lcd.print("SP= ");
  lcd.print(sp);
  lcd.print("    ");
  
if((kpa < sp)&&(sp < 0)){
  digitalWrite(ssr,HIGH);
}

if((kpa > sp)&&(sp < 0)){
  digitalWrite(ssr,LOW);
}

  delay(200);
  
}




f. VIDEO HASILNYA








Alat Kendali Relay dan Monitor Arus via WIFI ARDUINO Ethernet Aplikasi Android

Alat Kendali Relay dan Monitor Arus via WIFI ARDUINO Ethernet Aplikasi Android


            Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk monitor arus dan kendali relay via WIFI. alat ini menggunakan aplikasi android sebagai device kendalinya atau interfacenya. alat ini menggunakan router sebagai pemancar wifi sehingga jarak kendali dan monitor hanya sebatas jarak router saja. untuk lebih jelasnya berikut adalah program dan daftar komponennya.



a. Arduino Mega + Ethernet Shield




b. Sensor Arus ACS712




c. Relay Module 2 Channel




d. Router 




e. Program Android









f. Program Arduino IDE

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,99);

unsigned long start_times[300];
unsigned long stop_times[300];
unsigned long values[300];

const unsigned char PS_16 = (1 << ADPS2);
const unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0);
const unsigned char PS_64 = (1 << ADPS2) | (1 << ADPS1);
const unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);

EthernetServer server(80);

const int ledpin1 = A8;
const int ledpin2 = A9;

String readString;
float arus1x;
float arus1;
float arus2x;
float arus2;

void setup() {

 // set up the ADC
  ADCSRA &= ~PS_128;  // remove bits set by Arduino library

  // you can choose a prescaler from above.
  // PS_16, PS_32, PS_64 or PS_128
  ADCSRA |= PS_128;    // set our own prescaler to 64
  
   pinMode(ledpin1, OUTPUT);
   pinMode(ledpin2, OUTPUT);
   digitalWrite(ledpin1, HIGH); 
   digitalWrite(ledpin2, HIGH); 
  
  Serial.begin(9600);
   while (!Serial) {
  }

  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() {

unsigned int i;
unsigned int z;
z = 0;
   
  // capture the values to memory
  for(i=0;i<300;i++) {
    start_times[i] = micros();
    values[i] = analogRead(A0);             
 
  if (values[i] >= z) {
  z = values[i]; 
  }
    stop_times[i] = micros();
  }

  arus1x = z * (5.0/1023.0);
  arus1x = (arus1x - 2.438)/ 0.251;
  arus1 = arus1x * 1;
 
  z = 0;
  i = 0;
//=================================================

 // capture the values to memory
  for(i=0;i<300;i++) {
    start_times[i] = micros();
    values[i] = analogRead(A1);             
 
  if (values[i] >= z) {
  z = values[i]; 
  } 
    stop_times[i] = micros();
  }

  arus2x = z * (5.0/1023.0);
  arus2x = (arus2x - 2.438)/ 0.251;
  arus2 = arus2x * 1;
 
  z = 0;
  i = 0;


  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
     if (readString.length() < 100) {

          //store characters to string
          readString += c;
          //Serial.print(c);
        }
        if (c == '\n' && currentLineIsBlank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println("Refresh: 1");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println(" ");
          client.println("<title> Monitor Lampu </title> ");     
          client.println("<body bgcolor = #000000>");     
          client.println("<center>");
            client.println("<font color = yellow><center><h1>KENDALI LAMPU VIA ETHERNET ANDROID<br></h1></center><br>");
            client.println("<br />");
            client.println("<h2>");
            client.println("##");
            client.print(arus1);
            client.println("  <br />");
            client.println("###");
            client.print(arus2);
            client.println("  <br />");
            client.println("</font></h2>");
            
           client.println("<a href = \"/?lighton1\"\"><input type = 'button' value = 'ON 1' ></a>");
          client.println("<a href = \"/?lightoff1\"\"><input type = 'button' value = 'OFF 1' ></a> ");
           client.println("<a href = \"/?lighton2\"\"><input type = 'button' value = 'ON 2' ></a>");
          client.println("<a href = \"/?lightoff2\"\"><input type = 'button' value = 'OFF 2' ></a> ");
   
          client.println("</center>");
          client.println("</body>");
          client.println("</html>");
            
          break;       
        }    
        if (c == '\n') {
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
    Serial.println("client disonnected");
  }
          if(readString.indexOf("?lighton1") >0)
          {
 
            digitalWrite(ledpin1, LOW);    
          }
          else{           
          if(readString.indexOf("?lightoff1") >0)
          {

             digitalWrite(ledpin1, HIGH); 
          }
          }
         
             if(readString.indexOf("?lighton2") >0)
          {
 
            digitalWrite(ledpin2, LOW);    
          }
          else{           
          if(readString.indexOf("?lightoff2") >0)
          {

                digitalWrite(ledpin2, HIGH); 
          }
          }
          
         readString="";
}





g. VIDEO HASILNYA









Visual basic 6 (VB 6) + Database Ms. Access Kendali Arduino

Visual basic 6 (VB 6) + Database Ms. Access Kendali Arduino


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah interface dengan menggunakan visual basic 6 (VB 6) dengan fitur yang bisa mengendalikan arduino berdasarkan data yang ada pada database. jika orang tersebut sudah terdaftar maka akan bisa menghidupkan led pada arduino namun jika belum terdaftar maka tidak akan bisa menghidupkan led pada arduino. led pada arduino bisa diganti relay sehingga bisa mengendalikan solenoid door lock atau perangkat yang lain. untuk lebih jelasnya berikut koding dan komponennya.



a. Arduino Uno





b. Program Arduno IDE

#include <SPI.h>
#include <MFRC522.h>

String ok_rfid_1="2227e534";           // Kartu utama RFID Card
String ok_rfid_2="b9532dce";
String ok_rfid_3="123456ty";
String ok_rfid_4="4546ghgh";
String ok_rfid_5="1sd56hn4";
String ok_rfid_6="167bhb56";

int x = 1;
int datain;
int cacah = 1;

int led = A0;

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

    pinMode(led, OUTPUT);
    digitalWrite(led,HIGH);
}


void loop() {

if (Serial.available() > 0)
{
datain = Serial.parseInt();

if(datain == 2){
cacah++;
datain = 0;
}

if(datain == 1){
digitalWrite(led,LOW);
delay(3000);
digitalWrite(led,HIGH);
}

if(cacah > 6){
  cacah = 1;
  } 

}

if(cacah == 1){
Serial.println(ok_rfid_1);
}

if(cacah == 2){
Serial.println(ok_rfid_2);
}

if(cacah == 3){
Serial.println(ok_rfid_3);
}

if(cacah == 4){
Serial.println(ok_rfid_4);
}

if(cacah == 5){
Serial.println(ok_rfid_5);
}

if(cacah == 6){
Serial.println(ok_rfid_6);
}

delay(1000);
  
}




c. Program Interface VB 6



'===== Main Form ========
Dim Conn1 As ADODB.Connection
Dim Cmd1 As ADODB.Command
Dim Param1 As ADODB.Parameter
Dim Rs1 As ADODB.Recordset


Private Sub cbdelete_Click()
Dim SQl As String
    
    Call dbConnect
    
    SQl = "DELETE FROM Table1 WHERE Kode = '" & tbkode.Text & "'"
    
    Dim Rs As Recordset
    Set Rs = New ADODB.Recordset
    Rs.Open SQl, Conn, adOpenDynamic, adLockOptimistic
    
    tbkode.Text = ""
    tbnama.Text = ""
    tbstatus.Text = ""
    tbalamat.Text = ""
    
End Sub

Private Sub cbinsert_Click()
Dim SQl As String
    
   Call dbConnect
    If pass.Text = "1234" Then
    SQl = "INSERT INTO Table1 VALUES('" & tbkode.Text & "','" & tbnama.Text & "','" & tbstatus.Text & "','" & tbalamat.Text & "')"
    
    Dim Rs As Recordset
    Set Rs = New ADODB.Recordset
    Rs.Open SQl, Conn, adOpenDynamic
    tbkode.Text = ""
    tbnama.Text = ""
    tbstatus.Text = ""
    tbalamat.Text = ""
    pass.Text = ""
    End If
    
End Sub

Private Sub cbselect_Click()
Dim SQl As String
    
    Call dbConnect
    
    SQl = "Select * from Table1  where Kode = '" & tbkode.Text & "'"
    
    Dim Rs As Recordset
    Set Rs = New ADODB.Recordset
    Rs.Open SQl, Conn, adOpenDynamic, adLockOptimistic
    
    If Not Rs.EOF Then
        Text1.Text = Rs!Nama
        Text2.Text = Rs!Status
        Text3.Text = Rs!Alamat
    End If
End Sub

Private Sub cmdConnect_Click()
Dim port As Integer
On Error GoTo errcode

If MSComm1.PortOpen = False Then
    MSComm1.CommPort = Combo1.ListIndex + 1
    MSComm1.RThreshold = 1
    MSComm1.InputLen = 0
    MSComm1.Settings = Combo2.List(Combo2.ListIndex) & ",N,8,1"
    MSComm1.PortOpen = True
cmdConnect.Enabled = False
cmdDisconnect.Enabled = True
End If
 
Exit Sub

errcode:
    MsgBox "Port Salah !", vbOKOnly, "Peringatan"
    Combo1.SetFocus


End Sub

Private Sub cmdDisconnect_Click()
If MSComm1.PortOpen = True Then
    MSComm1.PortOpen = False
End If
cmdConnect.Enabled = True
cmdDisconnect.Enabled = False

End Sub

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Command2_Click()

If Text1.Text <> "" And Text2.Text <> "" And Text3.Text <> "" Then
MSComm1.Output = "1" + Chr(13)

Text1.Text = ""
Text2.Text = ""
Text3.Text = ""

End If

End Sub

Private Sub Command3_Click()
MSComm1.Output = "2" + Chr(13)
End Sub

Private Sub Form_Load()
Dim i As Byte
For i = 1 To 16
Combo1.AddItem (i)
Next i
With Combo2
        .AddItem "2400"
        .AddItem "4800"
        .AddItem "9600"
        .AddItem "19200"
        .AddItem "38400"
        .AddItem "56600"
        
End With
Timer2.Enabled = False
cmdConnect.Enabled = True
cmdDisconnect.Enabled = False
End Sub

Private Sub Timer1_Timer()
Adodc2.Refresh

If Text1.Text <> "" Then
Command2.Enabled = True
End If

If Text1.Text = "" Then
Command2.Enabled = False
End If

End Sub


Private Sub Timer2_Timer()
MSComm1_OnComm
End Sub

Private Sub Timer3_Timer()
Dim data As String
Dim jumlah As String

        Dim buffer As String
        If MSComm1.InBufferCount > 0 Then
            'tbkode.Text = ""
            'tbnama.Text = ""
            'tbstatus.Text = ""
            'tbalamat.Text = ""
          
        buffer = MSComm1.Input
        data = Mid$(buffer, 1, 8)
        'jumlah = Mid$(buffer, 15, 1)
        
        tbkode.Text = data
        'Text1.Text = jumlah
        
              
        End If
End Sub



'======= Module =====
Public Conn As New ADODB.Connection
Public Rs As New ADODB.Recordset
Public SQl As String
Public i As Byte

Public Sub dbConnect()
Set Conn = New ADODB.Connection
Conn.ConnectionString = strConn
Conn.Open
End Sub

Public Function strConn() As String
Set Conn = New ADODB.Connection
Set Rs = New ADODB.Recordset
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Acer\Desktop\Kodingku\interface\Database1.mdb;Persist Security Info=False"

End Function




d. VIDEO HASILNYA