-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPS-MSG-Llama.ino
43 lines (38 loc) · 1008 Bytes
/
GPS-MSG-Llama.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//GPS+MSG+sensor llama
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
SoftwareSerial mySerial(10, 11); // RX, TX for GSM module
SoftwareSerial GPSSerial(2, 3); // RX, TX for GPS module
TinyGPSPlus gps;
const int flamePin = A0;
void setup() {
mySerial.begin(9600);
GPSSerial.begin(9600);
Serial.begin(9600);
delay(1000);
mySerial.println("AT");
delay(1000);
mySerial.println("AT+CMGF=1");
delay(1000);
mySerial.println("AT+CMGS=\"YOUR_PHONE_NUMBER\"");
delay(1000);
}
void loop() {
while (GPSSerial.available() > 0) {
gps.encode(GPSSerial.read());
}
int flameValue = analogRead(flamePin);
if (flameValue > 500) {
String message = "Fire detected, evacuate the building! ";
if (gps.location.isValid()) {
message += "Location: ";
message += gps.location.lat(), 6;
message += ", ";
message += gps.location.lng(), 6;
}
mySerial.println(message);
mySerial.println((char)26);
delay(1000);
Serial.println("SMS Sent!");
}
}