Project Introduction
Railway accidents due to broken or cracked tracks are one of the major safety issues in rail transport. To solve this problem, we design a Smart Broken Track Detection System using Arduino, GSM, GPS, LCD and IoT technologies.
This system continuously checks the continuity of railway tracks. If any crack or break occurs, the system instantly detects it and sends alert messages to railway authorities with the exact GPS location.
📝 2. Detailed Article
The Broken Track Detection System is an advanced railway safety project designed to prevent train accidents caused by damaged or cracked tracks. Railway tracks can develop faults due to environmental conditions, heavy load, or poor maintenance. These faults are difficult to detect manually, especially in remote areas. This project provides an automated and reliable solution.
The system is built using an Arduino microcontroller, which continuously monitors the electrical continuity of the railway track. Under normal conditions, current flows through the rails. When a crack or break occurs, the circuit gets interrupted, and the Arduino detects the change immediately.
Once a fault is detected, the system activates multiple safety actions. A buzzer alert and red LED are turned on to indicate danger. At the same time, a GSM module sends an SMS alert to railway authorities. The message includes the exact location using GPS module, which helps in quick maintenance response.
A 16x2 LCD display is used to show real-time track status, such as "Track Safe" or "Track Broken". Additionally, the system can send data to IoT cloud platforms like ThingSpeak or Blynk, enabling remote monitoring of railway track conditions.
This project is low-cost, efficient, and easy to implement on real railway lines. It significantly reduces human effort and improves safety by providing real-time fault detection and communication.
Overall, this system demonstrates how embedded systems and IoT technology can be used to enhance railway safety and prevent accidents.
🎯 3. Objectives of Project
-
Detect broken railway tracks automatically
-
Prevent train accidents
-
Send real-time alert to authorities
-
Provide exact GPS location
-
Enable remote monitoring using IoT
🔧 4. Components Required
| Component | Quantity |
|---|---|
| Arduino Uno | 1 |
| SIM800L GSM Module | 1 |
| NEO-6M GPS Module | 1 |
| 16x2 LCD Display | 1 |
| Buzzer | 1 |
| Red LED | 1 |
| Green LED | 1 |
| Resistors | 5 |
| Jumper wires | As required |
| Breadboard | 1 |
| Power Supply | 5V |
| Track Model (metal strip) | 1 |
Arduino Pin Connections
🟢 Basic Components
Component Arduino Pin Track Detection Wire D4 Green LED (+) D7 Red LED (+) D6 Buzzer (+) D8
| Component | Arduino Pin |
|---|---|
| Track Detection Wire | D4 |
| Green LED (+) | D7 |
| Red LED (+) | D6 |
| Buzzer (+) | D8 |
👉 All LED (-) and Buzzer (-) → GND
📟 LCD 16x2 Connection (4-bit mode)
LCD Pin Arduino RS D9 EN D10 D4 D11 D5 D12 D6 D13 D7 A0 VSS GND VDD 5V RW GND VO Potentiometer
| LCD Pin | Arduino |
|---|---|
| RS | D9 |
| EN | D10 |
| D4 | D11 |
| D5 | D12 |
| D6 | D13 |
| D7 | A0 |
| VSS | GND |
| VDD | 5V |
| RW | GND |
| VO | Potentiometer |
📲 GSM SIM800L
GSM Pin Arduino TX D2 RX D3 GND GND VCC 4V External Supply ⚠️
| GSM Pin | Arduino |
|---|---|
| TX | D2 |
| RX | D3 |
| GND | GND |
| VCC | 4V External Supply ⚠️ |
📍 GPS NEO-6M
GPS Pin Arduino TX D5 RX D6 ⚠️ (use voltage divider) VCC 5V GND GND
| GPS Pin | Arduino |
|---|---|
| TX | D5 |
| RX | D6 ⚠️ (use voltage divider) |
| VCC | 5V |
| GND | GND |
🌐 ESP8266 (IoT)
ESP8266 Arduino TX A1 RX A2 VCC 3.3V GND GND
| ESP8266 | Arduino |
|---|---|
| TX | A1 |
| RX | A2 |
| VCC | 3.3V |
| GND | GND |
💻 2. Full Arduino Code (All Features)
/*
🚆 SMART BROKEN TRACK DETECTION SYSTEM
Features:
✔ Track Detection
✔ LCD Display
✔ GSM SMS Alert
✔ GPS Location
✔ IoT Cloud Output
*/
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
// Pin Setup
#define trackPin 4
#define greenLED 7
#define redLED 6
#define buzzer 8
LiquidCrystal lcd(9,10,11,12,13,A0);
// GSM
SoftwareSerial gsm(2,3);
// GPS
SoftwareSerial gps(5,6);
// ESP8266
SoftwareSerial wifi(A1,A2);
String latitude = "";
String longitude = "";
void setup()
{
pinMode(trackPin, INPUT);
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
gsm.begin(9600);
gps.begin(9600);
wifi.begin(9600);
lcd.begin(16,2);
lcd.print("Railway Safety");
delay(2000);
lcd.clear();
}
void loop()
{
int track = digitalRead(trackPin);
if(track == HIGH)
{
// SAFE CONDITION
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
digitalWrite(buzzer, LOW);
lcd.setCursor(0,0);
lcd.print("Track Status:");
lcd.setCursor(0,1);
lcd.print("SAFE ");
sendToCloud("SAFE");
delay(1000);
}
else
{
// BROKEN TRACK
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
digitalWrite(buzzer, HIGH);
lcd.setCursor(0,0);
lcd.print("TRACK BROKEN!");
lcd.setCursor(0,1);
lcd.print("Sending Alert");
getGPS();
sendSMS();
sendToCloud("BROKEN");
delay(5000);
}
}
// 📍 GPS Function
void getGPS()
{
while(gps.available())
{
String data = gps.readStringUntil('\n');
if(data.indexOf("$GPGGA") >= 0)
{
int latIndex = data.indexOf(",")+1;
int lonIndex = data.indexOf(",", latIndex+1);
latitude = data.substring(latIndex, latIndex+9);
longitude = data.substring(lonIndex, lonIndex+9);
}
}
}
// 📲 GSM SMS Function
void sendSMS()
{
gsm.println("AT+CMGF=1");
delay(1000);
gsm.println("AT+CMGS=\"+91XXXXXXXXXX\"");
delay(1000);
gsm.print("ALERT! TRACK BROKEN ");
gsm.print("Lat:");
gsm.print(latitude);
gsm.print(" Lon:");
gsm.print(longitude);
gsm.write(26);
delay(5000);
}
// 🌐 IoT Cloud Function
void sendToCloud(String status)
{
Serial.println("Uploading to IoT");
// Example ThingSpeak API
/*
wifi.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80");
delay(2000);
String url = "GET /update?api_key=YOUR_API_KEY&field1=" + status;
wifi.print("AT+CIPSEND=");
wifi.println(url.length()+2);
delay(2000);
wifi.println(url);
*/
}
🚆 SMART BROKEN TRACK DETECTION SYSTEM
Features:
✔ Track Detection
✔ LCD Display
✔ GSM SMS Alert
✔ GPS Location
✔ IoT Cloud Output
*/
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
// Pin Setup
#define trackPin 4
#define greenLED 7
#define redLED 6
#define buzzer 8
LiquidCrystal lcd(9,10,11,12,13,A0);
// GSM
SoftwareSerial gsm(2,3);
// GPS
SoftwareSerial gps(5,6);
// ESP8266
SoftwareSerial wifi(A1,A2);
String latitude = "";
String longitude = "";
void setup()
{
pinMode(trackPin, INPUT);
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
gsm.begin(9600);
gps.begin(9600);
wifi.begin(9600);
lcd.begin(16,2);
lcd.print("Railway Safety");
delay(2000);
lcd.clear();
}
void loop()
{
int track = digitalRead(trackPin);
if(track == HIGH)
{
// SAFE CONDITION
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
digitalWrite(buzzer, LOW);
lcd.setCursor(0,0);
lcd.print("Track Status:");
lcd.setCursor(0,1);
lcd.print("SAFE ");
sendToCloud("SAFE");
delay(1000);
}
else
{
// BROKEN TRACK
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
digitalWrite(buzzer, HIGH);
lcd.setCursor(0,0);
lcd.print("TRACK BROKEN!");
lcd.setCursor(0,1);
lcd.print("Sending Alert");
getGPS();
sendSMS();
sendToCloud("BROKEN");
delay(5000);
}
}
// 📍 GPS Function
void getGPS()
{
while(gps.available())
{
String data = gps.readStringUntil('\n');
if(data.indexOf("$GPGGA") >= 0)
{
int latIndex = data.indexOf(",")+1;
int lonIndex = data.indexOf(",", latIndex+1);
latitude = data.substring(latIndex, latIndex+9);
longitude = data.substring(lonIndex, lonIndex+9);
}
}
}
// 📲 GSM SMS Function
void sendSMS()
{
gsm.println("AT+CMGF=1");
delay(1000);
gsm.println("AT+CMGS=\"+91XXXXXXXXXX\"");
delay(1000);
gsm.print("ALERT! TRACK BROKEN ");
gsm.print("Lat:");
gsm.print(latitude);
gsm.print(" Lon:");
gsm.print(longitude);
gsm.write(26);
delay(5000);
}
// 🌐 IoT Cloud Function
void sendToCloud(String status)
{
Serial.println("Uploading to IoT");
// Example ThingSpeak API
/*
wifi.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80");
delay(2000);
String url = "GET /update?api_key=YOUR_API_KEY&field1=" + status;
wifi.print("AT+CIPSEND=");
wifi.println(url.length()+2);
delay(2000);
wifi.println(url);
*/
}
✅ Final Output Working
When track is safe
🟢 Green LED ON
📟 LCD = SAFE
When track breaks
🔴 Red LED ON
🔔 Buzzer ON
📲 SMS sent
📍 GPS location sent
🌐 IoT updated
📟 LCD shows alert
🎯 Your Project is Now 10Arduino Pin Connections
🟢 Basic Components
| Component | Arduino Pin |
|---|---|
| Track Detection Wire | D4 |
| Green LED (+) | D7 |
| Red LED (+) | D6 |
| Buzzer (+) | D8 |
👉 All LED (-) and Buzzer (-) → GND
📟 LCD 16x2 Connection (4-bit mode)
| LCD Pin | Arduino |
|---|---|
| RS | D9 |
| EN | D10 |
| D4 | D11 |
| D5 | D12 |
| D6 | D13 |
| D7 | A0 |
| VSS | GND |
| VDD | 5V |
| RW | GND |
| VO | Potentiometer |
📲 GSM SIM800L
| GSM Pin | Arduino |
|---|---|
| TX | D2 |
| RX | D3 |
| GND | GND |
| VCC | 4V External Supply ⚠️ |
📍 GPS NEO-6M
| GPS Pin | Arduino |
|---|---|
| TX | D5 |
| RX | D6 ⚠️ (use voltage divider) |
| VCC | 5V |
| GND | GND |
🌐 ESP8266 (IoT)
| ESP8266 | Arduino |
|---|---|
| TX | A1 |
| RX | A2 |
| VCC | 3.3V |
| GND | GND |
💻 2. Full Arduino Code (All Features)
/*
🚆 SMART BROKEN TRACK DETECTION SYSTEM
Features:
✔ Track Detection
✔ LCD Display
✔ GSM SMS Alert
✔ GPS Location
✔ IoT Cloud Output
*/
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
// Pin Setup
#define trackPin 4
#define greenLED 7
#define redLED 6
#define buzzer 8
LiquidCrystal lcd(9,10,11,12,13,A0);
// GSM
SoftwareSerial gsm(2,3);
// GPS
SoftwareSerial gps(5,6);
// ESP8266
SoftwareSerial wifi(A1,A2);
String latitude = "";
String longitude = "";
void setup()
{
pinMode(trackPin, INPUT);
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
gsm.begin(9600);
gps.begin(9600);
wifi.begin(9600);
lcd.begin(16,2);
lcd.print("Railway Safety");
delay(2000);
lcd.clear();
}
void loop()
{
int track = digitalRead(trackPin);
if(track == HIGH)
{
// SAFE CONDITION
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
digitalWrite(buzzer, LOW);
lcd.setCursor(0,0);
lcd.print("Track Status:");
lcd.setCursor(0,1);
lcd.print("SAFE ");
sendToCloud("SAFE");
delay(1000);
}
else
{
// BROKEN TRACK
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
digitalWrite(buzzer, HIGH);
lcd.setCursor(0,0);
lcd.print("TRACK BROKEN!");
lcd.setCursor(0,1);
lcd.print("Sending Alert");
getGPS();
sendSMS();
sendToCloud("BROKEN");
delay(5000);
}
}
// 📍 GPS Function
void getGPS()
{
while(gps.available())
{
String data = gps.readStringUntil('\n');
if(data.indexOf("$GPGGA") >= 0)
{
int latIndex = data.indexOf(",")+1;
int lonIndex = data.indexOf(",", latIndex+1);
latitude = data.substring(latIndex, latIndex+9);
longitude = data.substring(lonIndex, lonIndex+9);
}
}
}
// 📲 GSM SMS Function
void sendSMS()
{
gsm.println("AT+CMGF=1");
delay(1000);
gsm.println("AT+CMGS=\"+91XXXXXXXXXX\"");
delay(1000);
gsm.print("ALERT! TRACK BROKEN ");
gsm.print("Lat:");
gsm.print(latitude);
gsm.print(" Lon:");
gsm.print(longitude);
gsm.write(26);
delay(5000);
}
// 🌐 IoT Cloud Function
void sendToCloud(String status)
{
Serial.println("Uploading to IoT");
// Example ThingSpeak API
/*
wifi.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80");
delay(2000);
String url = "GET /update?api_key=YOUR_API_KEY&field1=" + status;
wifi.print("AT+CIPSEND=");
wifi.println(url.length()+2);
delay(2000);
wifi.println(url);
*/
}
✅ Final Output Working
When track is safe
🟢 Green LED ON
📟 LCD = SAFE
When track breaks
🔴 Red LED ON
🔔 Buzzer ON
📲 SMS sent
📍 GPS location sent
🌐 IoT updated
📟 LCD shows alert






0 comments:
Post a Comment