LAMPIRAN A
Sintaks Program Sistem Autotracking pada Stasiun Pengirim
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include "printf.h"
#include <Wire.h>
#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp;
static const int RXPin = 3, TXPin = 4; // GPS connections (RX pin connects to TX on module and other wise)
static const uint32_t GPSBaud = 9600; // GPS Baud Rate
SoftwareSerial ss(RXPin, TXPin); // The serial connection to the GPS device
TinyGPSPlus gps; // The TinyGPS++ object
// BMP Altitude[0]
double myAlt[1]; //current BMP height
// GPS Latitude[0]/Longitude[1]
RF24 radio(7,8); // nRF24L01 radio attached (CE, CSN)
RF24Network network(radio); // Network uses that radio
const uint16_t channel = 60; // Channel of our node
const uint16_t this_node = 1; // Address of our node
const uint16_t other_node = 0; // Address of the base
unsigned long packets_sent; // How many packets have we sent already
// Structure of our payload, limited to 32 bytes
struct payload_t // 32 bytes max
{
unsigned long counter; // 4 bytes
double lat; // 4 bytes
double lng; // 4 bytes
double Altitude; // 4 bytes
};
void setup()
{
Serial.begin(9600);
Wire.begin();
ss.begin(GPSBaud); // start Software Serial
bmp.begin();
SPI.begin();
radio.begin();
network.begin(channel, this_node);
}
Serial.println(F("No GPS detected: check wiring."));
while(true);
}
}
}
}
void getGPS() //Baca data latitude, longitude dan altitude
if (gps.location.isValid())
{
myLL[0] = gps.location.lat();
myLL[1] = gps.location.lng();
myAlt[0]= bmp.readAltitude(101500);
printf("Altitude = ");
void sendPayload() //kirim data yang telah terbaca
{
payload_t payload = {packets_sent++, myLL[0], myLL[1], myAlt[0]};
RF24NetworkHeader header(/*to node*/ other_node);
bool ok = network.write(header,&payload,sizeof(payload));
radio.powerDown(); // Power down the radio. Note that the radio will get powered back up on the next write() call.
}
static void smartDelay(unsigned long ms) // ensures that the gps object is being "fed"
unsigned long start = millis();
do
{
while (ss.available())
gps.encode(ss.read());
} while (millis() - start < ms);
}
Sintaks Program Sistem Autotracking pada Stasiun Penerima
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <Servo.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include "printf.h"
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <LiquidCrystal_I2C.h>
#include <HMC5883L.h>
HMC5883L compass;
int error = 0;
static const uint32_t GPSBaud = 9600;
Servo myservo;
Servo myservo1;
LiquidCrystal_I2C lcd(0x27, 20, 4);
Adafruit_BMP085 bmp;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);
double x1,x2,y1,y2,a,b,c,alt1,alt2;
double sudut,jarak,sudut_elevasi;
RF24 radio(7,8);
RF24Network network(radio); // Network uses that radio
const uint16_t channel = 60; // Channel of our node
const uint16_t this_node = 0; // Address of our node
const uint16_t other_node = 1; // Address of the other node
unsigned long packets_sent; // How many packets have we sent already
// GPS Latitude[0];Longitude[1]
double setLL[2]; //stored location
double myLL[2]; //current GPS location
double setAlt[1]; //stored altitude
// Structure of our payload, limited to 32 bytes
struct payload_t // 32 bytes max
{
unsigned long counter; // 4 bytes
double lat; // 4 bytes
double lng; // 4 bytes
float Altitude; // 4 bytes
};
void setup()
{
lcd.begin();
lcd.backlight();
Serial.begin(9600);
bmp.begin();
myservo.attach(9); //azimuth
myservo.write(180);
delay(900);
myservo1.attach(10); //elevasi
delay(900);
myservo.detach();
myservo1.detach();
printf_begin();
network.begin(channel,this_node);
Wire.begin(); // Start the I2C interface.
compass = HMC5883L(); // Construct a new HMC5883 compass.
error = compass.SetScale(1.3); // Set the scale of the compass.
if(error != 0) // If there is an error, print it out.
Serial.println(compass.GetErrorText(error));
// Set the measurement mode to Continuous
error = compass.SetMeasurementMode(Measurement_Continuous);
if(error != 0) // If there is an error, print it out.
Serial.println(compass.GetErrorText(error));
void loop()
{
ss.begin(9600); //GPS on
delay(10);
network.update(); //pump the radio network regularly
delay(100);
//latitude, longitude & altitude stasiun penerima---
x1 = gps.location.lat();
y1 = gps.location.lng();
alt1 = bmp.readAltitude(101500);
Serial.print("x1 : ");
Serial.println(x1,6);
Serial.print("y1 : ");
Serial.println(y1,6);
Serial.print("alt1 : ");
Serial.println(alt1);
smartDelay(100);
//---
x2 = setLL[0];
y2 = setLL[1];
alt2 = setAlt[0];
Serial.print("x2 : ");
Serial.println(x2,6);
Serial.print("y2 : ");
Serial.println(y2,6);
Serial.print("alt2 : ");
Serial.println(alt2);
//latitude, longitude & altitude stasiun pengirim---
ss.end(); //GPS off
//kompas---
MagnetometerRaw raw = compass.ReadRawAxis();
MagnetometerScaled scaled = compass.ReadScaledAxis();
int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis)
float heading = atan2(scaled.YAxis, scaled.XAxis);
float declinationAngle = 0.0457;
heading += declinationAngle;
if(heading < 0)
heading += 2*PI;
if(heading > 2*PI)
heading -= 2*PI;
float headingDegrees = heading * 180/M_PI;
Serial.println(headingDegrees);
//kompas---
while(network.available())
{
getRadioData(); //Terima data Stasiun pengirim
//LCD---
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(x2,6);
lcd.setCursor(0, 1);
lcd.print(y2,6);
lcd.setCursor(0, 2);
lcd.print(x1,6);
lcd.setCursor(0, 3);
lcd.print(headingDegrees);
lcd.setCursor(15,2);
lcd.print("elv");
lcd.setCursor(15,3);
lcd.print(sudut_elevasi);
//LCD---
if (headingDegrees >=100 && headingDegrees <= 110) // ----> badan stasiun penerima ke arah TIMUR
myservo.detach();
}
}
//---AZIMUTH---
//---elevasi---
int pos;
myservo1.attach(10);
pos = 16 + sudut_elevasi;
myservo1.write(pos);
delay(1000);
myservo1.detach();
//---elevasi---
}
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F("No GPS data received: check wiring"));
} //end of void loop
double hitung_sudut()
{
a = x2 - x1;
b = y2 - y1;
c = b/a;
{
c = c*(-1);
}
sudut = round(atan(c)*180/3.14159265);
delay(10);
Serial.print("sudut : ");
Serial.println(sudut);
sudut_elevasi = round(atan(t_per_j)*180/3.14159265);
}
// This custom version of delay() ensures that the gps object is being "fed".
static void smartDelay(unsigned long ms)
{
unsigned long start = millis();
{
while (ss.available())
gps.encode(ss.read());
} while (millis() - start < ms);
}
void getRadioData()
{
RF24NetworkHeader header;
payload_t payload={packets_sent++, myLL[0], myLL[1], myAlt[0]};
bool done = false;
while (!done)
{
done = network.read(header,&payload,sizeof(payload));
setLL[0] = payload.lat;
setLL[1] = payload.lng;
setAlt[0]= payload.Altitude;
printf(" Alt: ",setAlt[0],6);
Serial.print(setAlt[0],6);
printf(" Lat: ",setLL[0],6);
Serial.print(setLL[0],6);
Serial.print(setLL[1],6);
printf("\n");
}
LAMPIRAN B
Diagram Alir Sistem Autotracking Sudut Elevasi
LAMPIRAN C
Tabel hasil pengujian autotracking sudut azimuth pertama
No
Latitude Longitude Latitude Longitude
1 3.557109 98.658201 3.557471 98.658882 62° 63° 1°
Grafik hasil pengujian autotracking sudut azimuth pertama
61.5
Tabel hasil pengujian autotracking sudut azimuth kedua
Latitude Longitude Latitude Longitude
1 3.557109 98.658201 3.556967 98.659556 96° 95° 1°
Grafik hasil pengujian autotracking sudut azimuth kedua
94.4
Tabel hasil pengujian autotracking sudut azimuth ketiga
Latitude Longitude Latitude Longitude
1 3.557109 98.658201 3.556495 98.659558 114° 112° 2°
Grafik hasil pengujian autotracking sudut azimuth ketiga
111
Tabel hasil pengujian autotracking sudut elevasi pertama
No Ketinggian RX (m)
Grafik hasil pengujian autotracking sudut elevasi pertama
14
Tabel hasil pengujian autotracking sudut elevasi kedua
No Ketinggian RX (m)
Grafik hasil pengujian autotracking sudut elevasi kedua
29
Tabel hasil pengujian autotracking sudut elevasi ketiga
No Ketinggian RX (m)
Grafik hasil pengujian autotracking sudut elevasi ketiga
39.4