#include String inWord; char inByte; String data; SoftwareSerial GPS_Serial(10, 11); // RX, TX 11 is not connected SoftwareSerial mySerial(3, 2); // Rx & Tx is connected to SIM module Tx and Rx #include #include #include Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085); float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; void setup() { // Start the GPS module Serial.begin(9600); Serial.println("Pressure Sensor Test"); Serial.println(""); /* Initialise the sensor */ if(!bmp.begin()) { /* There was a problem detecting the BMP085 ... check your connections */ Serial.print("Ooops, no BMP085 detected ... Check your wiring or I2C ADDR!"); while(1); } GPS_Serial.begin(9600); } void loop() { sensors_event_t event; /* Calculating altitude with reasonable accuracy requires pressure * * sea level pressure for your position at the moment the data is * * converted, as well as the ambient temperature in degress * * celcius. If you don't have these values, a 'generic' value of * * 1013.25 hPa can be used (defined as SENSORS_PRESSURE_SEALEVELHPA * * in sensors.h), but this isn't ideal and will give variable * * results from one day to the next. * * * * You can usually find the current SLP value by looking at weather * * websites or from environmental information centers near any major * * airport. * * */ if(bmp.pressureToAltitude(seaLevelPressure, event.pressure) >= 1){ // number 1 here is just a value used for test, but this should be chnaged with the maximum height the drone can fly to. Serial.println("Intruder"); delay(500); while (GPS_Serial.available() > 0) { inByte = GPS_Serial.read(); if (inByte == '\n') { // END OF LINE // check is data we want // you can change this to get any data line values if (inWord.startsWith("$GPRMC")) { // put data string in variable data = inWord; Serial.println(data); mySerial.begin(9600); Serial.println("Initializing..."); delay(1000); mySerial.println("AT"); //Handshaking with SIM900 mySerial.println("AT+CMGF=1"); // Configuring TEXT mode updateSerial(); mySerial.println("AT+CMGS=\"+ZZxxxxxxxxxxx\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms updateSerial(); mySerial.print("unauthorized drone flight detected at:"); mySerial.print(data); //text content updateSerial(); mySerial.write(char(26)); // clear the inword variable inWord = ""; } else { // clear the inword variable as not the data we want inWord = ""; } } else { // build data string inWord += inByte; } } // end if serial } else{ Serial.println("good"); } delay(500); } void updateSerial() { delay(500); while (Serial.available()) { mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port } while(mySerial.available()) { Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port } }