LAMPIRAN 1 Tutorial Implementasi Editor Pengukuran, Pengiriman dan Penerimaan a.
Implementasi Editor Pengukuran Berikut adalah langkah-langkah pengukuran meliputi: 1. Buka editor arduino kemudian setting sketch dan tools menggunakan arduino UNO. 2. Masukkan listing program sesuai dengan pengukuran yang diinginkan. 3. Kemudian lakukan verify load library setelah selesai upload dan serialkan kepada monitor tampilan data. 4. Catat hasil pengukuran.
b.
Implementasi Editor Pengiriman Menggunakan Wireless Tool Kit 2.5.2 Berikut adalah langkah-langkah menginstall editor pengiriman meliputi: 1. Siapkan editor Wireless Tool Kit 2.5.2 2. Edit listing program sesuai dengan protokol yang digunakan yaitu UDP. 3. Lakukan perintah open project pada WTK kemudian setting sesuai dengan perangkat yang digunakan yaitu Nokia series E63. 4. Untuk mendapatkan file yang sudah dieksekusi dalam format .jar pilih perintah set package. 5. Setelah format .jar muncul pada folder WTK lakukan build project untuk menjalankan project yang sudah dibuat pada emulator yang sudah disediakan. 6. Ambil file eksekusi yang berformat .jar lalu install pada perangkat Nokia series E63. 7. Aplikasi akan muncul pada layar handphone dan siap untuk dilakukan proses pengiriman.
Universitas Sumatera Utara
c.
Implementasi Editor Penerimaan Menggunakan Netbeans 8.0.1 Berikut adalah langkah-langkah menjalankan editor penerimaan meliputi: 1. Siapkan editor Netbeans 8.0.1 2. Edit listing program sesuai dengan protokol yang digunakan yaitu UDP 3. Lakukan perintah open package pada editor Netbeans. 4. Setelah file muncul maka langkah selanjutnya adalah mensetting IP address dari perangkat pengirim. 5. Kemudian pilih perintah run file. 6. Setelah kedua perangkat terhubung, catat hasil pengiriman dan penerimaan.
Universitas Sumatera Utara
LAMPIRAN 2 Listing Program Monitoring Pengukuran Menggunakan Arduino UNO #include <Time.h> int voltPin = 0; //voltage divider (middle terminal) connected to analog pin 0 int currentPin = 2; //TMP36 data pin int val = 0; // variable to store the value read int volt = 0; //variable to store the voltage calculated int current = 0; static const int RXPin = 19,TXPin = 18; void setup() { Serial.begin(9600); //setup serial setTime(9,20,0,17,01,15); // set time to noon August 8 2014 harus diset setiap melakukan uji coba } void loop() { int reading = analogRead(voltPin); //read the input pin float voltage = reading*4.2; voltage /= 1024.0; int reading2 = analogRead(currentPin); //read the input pin float current = voltage - reading2*4.2; current /= 1024.0; float v_negatif = voltage + current; Serial.print(voltage); Serial.print(" volts titik + "); Serial.print(v_negatif); Serial.print(" volts titik - "); float arus = current/0.22; Serial.print(arus); Serial.print(" ampere "); float power = (arus*arus*0.22)*1000; Serial.print(power); Serial.print(" milliwatt "); float energi = (power*3600)/1000; Serial.print(energi); Serial.print(" joule "); digitalClockDisplay(); delay(500); } void digitalClockDisplay(){ // digital clock display of the time
Universitas Sumatera Utara
Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(" "); Serial.print(day()); Serial.print(" "); Serial.print(month()); Serial.print(" "); Serial.print(year()); Serial.println(); } void printDigits(int digits){ // utility function for clock display: prints preceding colon and leading 0 Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); }
Universitas Sumatera Utara
LAMPIRAN 3 Listing Program Pengirim Data Transmisi UDP Menggunakan Bahasa Java Editor Wireless Tool Kit (WTK) 2.5.2 Pengirim Data Transmisi UDP import java.io.IOException; import java.util.Calendar; import java.util.Date; import javax.microedition.io.*; import javax.microedition.io.Datagram; import javax.microedition.io.DatagramConnection; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.StringItem; import javax.microedition.lcdui.TextField; public class UDP implements Runnable, CommandListener { private DatagramMIDlet parent; private Display display; private Form f; private StringItem si; private TextField tf; private Command startCommand = new Command("Start", Command.ITEM, 1); private Command exitCommand = new Command("Exit", Command.EXIT, 1); private String address; String portString=null; private int port; Datagram dg=null; DatagramConnection dc=null; int [] dataVideo = {27905,10857,10917,10515,11907,11781,9177,12155,11000,12108,12302,11632, 12925,13483,14148,13980,13712,13552,13047,12577,12444,9233,11987,11228,1 2680,12126,12303,7804,9186,8085,31240,11651,12027,10740,10423,11018,1124 8,11677,11357,11753,9010,9752,10805,10338,11190,10750,10708,12489,12904, 12950,11123,10705,10616,8986,14107,13506,11235,11216,12941,10818,31106,1
Universitas Sumatera Utara
2476,11951,12363,11544,11067,11534,11980,11709,10765,11147,10873,10970,1 1726,11119,10775,11780,12343,13098,12615,12790,10794,11144,12698,13855,1 3137,12396,10971,12085,13142,29278,12874,13496,13151,12708,12505,10515,9 982,10110,9883,9687,10641,10899,10513,9948,9885,10573,7807,10218,11314,1 0749,11022,11133,10697,10294,11288,11115,8114,9364,10308,28494,8786,1124 9,11913,11774,12409,13288,12369,11681,11319,11402,10929,12043,12540,1329 2,13490,13149,13797,13858,14737,14607,14331,14564,12183,13580,11448,1027 1,10285,11285,9210,26459,10331,11038,14130,15156,13330,14587,14574,14217 ,12256,11247,9761,10684,10049,11178,10881,10122,10911,11036,11254,12558, 13251,13286,13264,13276,12107,12418,12088,11178,11337,24525,9651,10029,1 0542,10987,10391,10336,9674,8960,10312,10262,10967,10846,10758,10961,123 61,12516,10760,10072,9608,9883,10452,10218,9691,9403,9326,9421,8636,9578, 9950,23711,11427,12099,11643,11177,11786,12914,15258,16807,18862,19315,1 8799,19767,15869,15771,13366,14238,13196,17803,20947,20938,20302,21273,2 3927,22763,21242,22183,19795,23711,18951,43787,20868,21750,21976,24037,2 4528,24831,24249,21167,20932,20143,24477,16516,20241,22495,25438,25269,2 6435,17921,19784,24119,26064,26342,21836,17681,20602,22030,22848,23277,2 2502,45781,14661,19359,18430,16623,18240,14352,17137,18796,18626,16799,1 5646,21259,22197,18583,22628,25014,23053,21356,21428,22351,21949,19129,1 6436,21768,25520,24413,24244,21886,17520}; //Generate byte 010101; String s ="0100000101000001010000010100000101000001010000010100000101000001 010000010100000101000001010000010100000101000001010000010100000101 000001010000010100000101000001010000010100000101000001010000010100 000101000001010000010100000101000001010000010100000101000001010000 010100000101000001010000010100000101000001010000010100000101000001 010000010100000101000001010000010100000101000001010000010100000101 000001010000010100000101000001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010
Universitas Sumatera Utara
000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010
Universitas Sumatera Utara
000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010
Universitas Sumatera Utara
000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001" + "01000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010
Universitas Sumatera Utara
000010100000101000001010000010100000101000001010000010100000101000 001010000010100000101000001010000010100000101000001010000010100000 101000001010000010100000101000001010000010100000101000001010000010 100000101000001010000010100000101000001010000010100000101000001010 00001"; int urutan =0; byte[] bytes = null; public UDP(DatagramMIDlet m, int p) { parent = m; port = p; display = Display.getDisplay(parent); f = new Form("UDP Server"); si = new StringItem("Status:", " "); f.append(si); //f.addCommand(startCommand); f.addCommand(exitCommand); f.setCommandListener(this); display.setCurrent(f); portString = String.valueOf(port); } public void start() { Thread t = new Thread(this); t.start(); } public void run() { try { si.setText("Menunggu permintaan sambungan "+portString); dc = (DatagramConnection) Connector .open("datagram://:" + portString); while (true) { dg = dc.newDatagram(100); dc.receive(dg); address = dg.getAddress(); si.setText("Permintaan diterima " + new String(dg.getData(), 0, dg.getLength())); //Program mengirim video //Kirim video 6x10detik for(int k=0;k<6;k++){ int frame=dataVideo.length; for(int i=0;i
Universitas Sumatera Utara
Date date = new Date(); try { String ss="kirim :"+date.getTime()+" urutan: "+urutan+" frame :"+i+" : "+s; bytes=ss.getBytes(); dg = dc.newDatagram(bytes, bytes.length, address); si.setText("Mengirim paket "+urutan+" frame:"+i); dc.send(dg); } catch (Exception ioe) { ioe.printStackTrace(); } urutan++; } try { Thread.sleep(30);//1000 milliseconds is one second. } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } urutan++; } } } } catch (IOException ioe) { Alert a = new Alert("Server", "Port " + portString + " is already taken.", null, AlertType.ERROR); a.setTimeout(Alert.FOREVER); a.setCommandListener(this); display.setCurrent(a); } catch (Exception e) { e.printStackTrace(); } } public void commandAction(Command c, Displayable s) { if ((c == Alert.DISMISS_COMMAND) || (c == exitCommand)) { parent.destroyApp(true); parent.notifyDestroyed(); } } public void stop() { } }
Universitas Sumatera Utara
LAMPIRAN 4 Listing Program Penerima Data Transmisi UDP Menggunakan Bahasa Java Editor Netbeans 8.0.1 Penerima Data Transmisi UDP import java.io.*; import java.net.*; import java.util.*; class UDPClient { private InetAddress IPAddress; boolean done; //boolean keepGoing; public UDPClient(String sHostName) { String s1; int size; BufferedReader br; try { IPAddress = InetAddress.getByName(sHostName); System.out.println ("Attemping to connect to " + IPAddress + ") via UDP port 5555"); } catch (UnknownHostException ex) { System.err.println(ex); System.exit(1); }
// set up the buffered reader to read from the keyboard try { DatagramSocket clientSocket = new DatagramSocket(); byte[] sendData = new byte[1024]; s1 = "Request"; sendData = s1.getBytes(); System.out.println ("Sending data to " + sendData.length); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 5555); clientSocket.send(sendPacket); byte[] receiveData = new byte[1024]; DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
Universitas Sumatera Utara
System.out.println ("Waiting for return packet"); //clientSocket.setSoTimeout(100000000); while (true){ Date date = new Date(); try { clientSocket.receive(receivePacket); System.out.println("Terima :"+date.getTime()+" "+receivePacket.getLength()+" "+new String(receivePacket.getData())); } catch (SocketTimeoutException ste){ System.out.println ("Timeout Occurred: Packet assumed lost"); if (done) // // keepGoing = false; } System.out.println(); } // clientSocket.close(); } catch (IOException ex) { System.err.println(ex); } }
public static void main(String args[]) throws Exception { String serverHostname = new String ("192.168.101.11"); if (args.length > 0) serverHostname = args[0]; new UDPClient (serverHostname); } }
Universitas Sumatera Utara