├── .gitattributes ├── GPS_Tracker_with_Call___SMS ├── utilities.h └── GPS_Tracker_with_Call___SMS.ino └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /GPS_Tracker_with_Call___SMS/utilities.h: -------------------------------------------------------------------------------- 1 | #define IP5306_ADDR 0x75 2 | #define IP5306_REG_SYS_CTL0 0x00 3 | 4 | bool setPowerBoostKeepOn(int en) 5 | { 6 | Wire.beginTransmission(IP5306_ADDR); 7 | Wire.write(IP5306_REG_SYS_CTL0); 8 | if (en) { 9 | Wire.write(0x37); // Set bit1: 1 enable 0 disable boost keep on 10 | } else { 11 | Wire.write(0x35); // 0x37 is default reg value 12 | } 13 | return Wire.endTransmission() == 0; 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GPS Tracker via GSM using TTGO TCALL Module 2 | This is the code for the project called "GPS Tracker with call & SMS feature". The project was made using following Components 3 | 4 | 1. TTGO TCALL Module(https://www.youtube.com/watch?v=bFm8Pb_M-dE) 5 | 2. Neo6M GPS Module 6 | 3. Battery 7 | 4. ON/OFF Switch 8 | 5. Push buttons 9 | 6. 10k Resistors 10 | 11 | To know more about this project kindly watch out it's full tutorial video uploaded on my YouTube channel(http://www.youtube.com/techiesms) 12 | 13 | -------------------------------------------------------------------------------- /GPS_Tracker_with_Call___SMS/GPS_Tracker_with_Call___SMS.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This is the code for the project 4 | 5 | "GPS Tracker using TTGO TCALL Module" 6 | 7 | The full tutorial video of this project is 8 | uploaded on "techiesms" YouTube Channel. 9 | 10 | Code Written by - Sachin Soni 11 | 12 | Link of tutorial video - message_with_data 13 | 14 | * */ 15 | 16 | 17 | 18 | 19 | // TTGO T-Call pin definitions 20 | #define MODEM_RST 5 21 | #define MODEM_PWKEY 4 22 | #define MODEM_POWER_ON 23 23 | #define MODEM_TX 27 24 | #define MODEM_RX 26 25 | #define I2C_SDA 21 26 | #define I2C_SCL 22 27 | 28 | 29 | 30 | 31 | #include //https://github.com/mikalhart/TinyGPSPlus 32 | #include // https://github.com/bxparks/AceButton 33 | 34 | #define BLYNK_PRINT Serial 35 | #define BLYNK_HEARTBEAT 30 36 | #define TINY_GSM_MODEM_SIM800 37 | 38 | #include // https://github.com/vshymanskyy/TinyGSM 39 | #include //https://github.com/blynkkk/blynk-library 40 | 41 | #include 42 | // #include 43 | #include "utilities.h" 44 | 45 | 46 | using namespace ace_button; 47 | 48 | //Buttons 49 | #define SMS_Button 34 50 | #define Call_Button 35 51 | 52 | // Emergency Number and Message 53 | String message = "It's an Emergency. I'm at this location "; 54 | String mobile_number = "Mobile Number with country code"; 55 | 56 | String message_with_data; 57 | 58 | // Variables for storing GPS Data 59 | float latitude; 60 | float longitude; 61 | float speed; 62 | float satellites; 63 | String direction; 64 | 65 | // Switch 66 | ButtonConfig config1; 67 | AceButton call_button(&config1); 68 | ButtonConfig config2; 69 | AceButton sms_button(&config2); 70 | 71 | void handleEvent_call(AceButton*, uint8_t, uint8_t); 72 | void handleEvent_sms(AceButton*, uint8_t, uint8_t); 73 | 74 | // Set serial for GPS Module 75 | #define SerialMon Serial 76 | 77 | // Hardware Serial for builtin GSM Module 78 | #define SerialAT Serial1 79 | 80 | const char apn[] = "www"; 81 | 82 | const char user[] = ""; 83 | const char pass[] = ""; 84 | 85 | // You should get Auth Token in the Blynk App. 86 | // Go to the Project Settings (nut icon). 87 | const char auth[] = "YOUR_AUTH_TOKEN"; 88 | 89 | //static const int RXPin = 4, TXPin = 5; 90 | static const uint32_t GPSBaud = 9600; 91 | 92 | TinyGPSPlus gps; 93 | WidgetMap myMap(V0); 94 | 95 | //SoftwareSerial ss(RXPin, TXPin); 96 | BlynkTimer timer; 97 | 98 | 99 | 100 | TinyGsm modem(SerialAT); 101 | 102 | unsigned int move_index = 1; 103 | 104 | void setup() 105 | { 106 | // Set console baud rate 107 | Serial.begin(9600); 108 | delay(10); 109 | 110 | // Keep power when running from battery 111 | Wire.begin(I2C_SDA, I2C_SCL); 112 | bool isOk = setPowerBoostKeepOn(1); 113 | SerialMon.println(String("IP5306 KeepOn ") + (isOk ? "OK" : "FAIL")); 114 | 115 | // Set-up modem reset, enable, power pins 116 | pinMode(MODEM_PWKEY, OUTPUT); 117 | pinMode(MODEM_RST, OUTPUT); 118 | pinMode(MODEM_POWER_ON, OUTPUT); 119 | 120 | 121 | pinMode(SMS_Button, INPUT); 122 | pinMode(Call_Button, INPUT); 123 | 124 | 125 | digitalWrite(MODEM_PWKEY, LOW); 126 | digitalWrite(MODEM_RST, HIGH); 127 | digitalWrite(MODEM_POWER_ON, HIGH); 128 | 129 | // Set GSM module baud rate and UART pins 130 | SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX); 131 | delay(3000); 132 | 133 | // Restart takes quite some time 134 | // To skip it, call init() instead of restart() 135 | SerialMon.println("Initializing modem..."); 136 | modem.restart(); 137 | 138 | String modemInfo = modem.getModemInfo(); 139 | SerialMon.print("Modem: "); 140 | SerialMon.println(modemInfo); 141 | 142 | // Unlock your SIM card with a PIN 143 | //modem.simUnlock("1234"); 144 | 145 | SerialMon.print("Waiting for network..."); 146 | if (!modem.waitForNetwork(240000L)) { 147 | SerialMon.println(" fail"); 148 | delay(10000); 149 | return; 150 | } 151 | SerialMon.println(" OK"); 152 | 153 | if (modem.isNetworkConnected()) { 154 | SerialMon.println("Network connected"); 155 | } 156 | 157 | SerialMon.print(F("Connecting to APN: ")); 158 | SerialMon.print(apn); 159 | if (!modem.gprsConnect(apn, user, pass)) { 160 | SerialMon.println(" fail"); 161 | delay(10000); 162 | return; 163 | } 164 | SerialMon.println(" OK"); 165 | // ss.begin(GPSBaud); 166 | Blynk.begin(auth, modem, apn, user, pass); 167 | timer.setInterval(5000L, checkGPS); 168 | 169 | config1.setEventHandler(handleEvent_call); 170 | config2.setEventHandler(handleEvent_sms); 171 | 172 | call_button.init(Call_Button); 173 | sms_button.init(SMS_Button); 174 | } 175 | 176 | void checkGPS() 177 | { 178 | if (gps.charsProcessed() < 10) 179 | { 180 | //Serial.println(F("No GPS detected: check wiring.")); 181 | Blynk.virtualWrite(V4, "GPS ERROR"); 182 | } 183 | } 184 | 185 | void loop() 186 | { 187 | while (Serial.available() > 0) 188 | { 189 | if (gps.encode(Serial.read())) 190 | displayInfo(); 191 | } 192 | 193 | Blynk.run(); 194 | timer.run(); 195 | sms_button.check(); 196 | call_button.check(); 197 | } 198 | 199 | void displayInfo() 200 | { 201 | 202 | if (gps.location.isValid() ) 203 | { 204 | 205 | latitude = (gps.location.lat()); //Storing the Lat. and Lon. 206 | longitude = (gps.location.lng()); 207 | 208 | //Serial.print("LAT: "); 209 | //Serial.println(latitude, 6); // float to x decimal places 210 | //Serial.print("LONG: "); 211 | //Serial.println(longitude, 6); 212 | Blynk.virtualWrite(V1, String(latitude, 6)); 213 | Blynk.virtualWrite(V2, String(longitude, 6)); 214 | myMap.location(move_index, latitude, longitude, "GPS_Location"); 215 | speed = gps.speed.kmph(); //get speed 216 | Blynk.virtualWrite(V3, speed); 217 | 218 | 219 | direction = TinyGPSPlus::cardinal(gps.course.value()); // get the direction 220 | Blynk.virtualWrite(V4, direction); 221 | 222 | satellites = gps.satellites.value(); //get number of satellites 223 | Blynk.virtualWrite(V5, satellites); 224 | 225 | 226 | } 227 | 228 | 229 | //Serial.println(); 230 | } 231 | 232 | void handleEvent_sms(AceButton* /* button */, uint8_t eventType, 233 | uint8_t /* buttonState */) { 234 | switch (eventType) { 235 | case AceButton::kEventPressed: 236 | // Serial.println("kEventPressed"); 237 | message_with_data = message + "Latitude = " + (String)latitude + "Longitude = " + (String)longitude; 238 | modem.sendSMS(mobile_number, message_with_data); 239 | message_with_data = ""; 240 | break; 241 | case AceButton::kEventReleased: 242 | //Serial.println("kEventReleased"); 243 | break; 244 | } 245 | } 246 | void handleEvent_call(AceButton* /* button */, uint8_t eventType, 247 | uint8_t /* buttonState */) { 248 | switch (eventType) { 249 | case AceButton::kEventPressed: 250 | // Serial.println("kEventPressed"); 251 | modem.callNumber(mobile_number); 252 | break; 253 | case AceButton::kEventReleased: 254 | //Serial.println("kEventReleased"); 255 | break; 256 | } 257 | } 258 | --------------------------------------------------------------------------------