Course Content
IoT Engineering Course using ESP32 with 12 Real-World Projects

Bridge Health Monitoring Using Flex Sensor

  • ESP32 inbuilt Bluetooth (Classic)

  • Bluetooth Terminal app (like Serial Bluetooth Terminal)

  • Same flex sensor logic

📡 Bridge Health Monitoring Using Flex Sensor (Bluetooth Version)

// Bridge Health Monitoring System
// Using ESP32 + Flex Sensor + Bluetooth

#include "BluetoothSerial.h"

BluetoothSerial SerialBT; // Create Bluetooth object

const int flexPin = 34; // Analog pin connected to flex sensor
int flexValue = 0; // Variable to store analog value
int threshold = 2500; // Bending limit (Adjust after calibration)

void setup() {
Serial.begin(115200); // Serial Monitor
SerialBT.begin("BridgeMonitor"); // Bluetooth device name
pinMode(flexPin, INPUT);

Serial.println("Bluetooth Started! Connect to BridgeMonitor");
}

void loop() {

// Read flex sensor
flexValue = analogRead(flexPin);

// Send to Serial Monitor
Serial.print("Flex Sensor Value: ");
Serial.println(flexValue);

// Send to Bluetooth Terminal
SerialBT.print("Flex Sensor Value: ");
SerialBT.println(flexValue);

// Compare with threshold
if (flexValue > threshold) {
Serial.println("⚠️ BEND DETECTED - Bridge Under Stress!");
SerialBT.println("⚠️ BEND DETECTED - Bridge Under Stress!");
} else {
Serial.println("✅ No Bend - Bridge is Safe.");
SerialBT.println("✅ No Bend - Bridge is Safe.");
}

Serial.println("-----------------------------");
SerialBT.println("-----------------------------");

delay(1000);
}

🧠 Code Explanation (Bluetooth Added Part)

1️⃣ Include Bluetooth Library

 
 
#include “BluetoothSerial.h”
 

This library enables ESP32 Bluetooth Classic communication.


2️⃣ Create Bluetooth Object

 
 
BluetoothSerial SerialBT;
 

This object is used to send and receive Bluetooth data.


3️⃣ Start Bluetooth

 
 
SerialBT.begin(“BridgeMonitor”);
 

“BridgeMonitor” is the Bluetooth device name.

When you open your mobile Bluetooth, you will see:

👉 BridgeMonitor


4️⃣ Sending Data to Bluetooth

 
 
SerialBT.print(“Flex Sensor Value: “);
SerialBT.println(flexValue);
 

This sends data directly to the Bluetooth Terminal App.

Same as Serial Monitor, but wireless.


📱 How to Connect Bluetooth Terminal App

Step 1:

Install Serial Bluetooth Terminal (Play Store)

Step 2:

Turn ON mobile Bluetooth

Step 3:

Open app → Devices → Pair new device

Select:

👉 BridgeMonitor

Step 4:

Connect

Now you will see live data like:

 
 
Flex Sensor Value: 1800
✅ No Bend – Bridge is Safe.
—————————–

Flex Sensor Value: 2950
⚠️ BEND DETECTED – Bridge Under Stress!
—————————–

 

📊 How Result Appears in Bluetooth App

When bridge is straight:

 
 
Flex Sensor Value: 1700
✅ No Bend – Bridge is Safe.
—————————–
 

When bridge bends:

 
 
Flex Sensor Value: 3100
⚠️ BEND DETECTED – Bridge Under Stress!
—————————–
 

It updates every 1 second.


🔎 Complete System Logic (For Viva – Bluetooth Version)

  1. Flex sensor changes resistance when bridge bends.

  2. Voltage divider converts resistance change into voltage.

  3. ESP32 ADC converts voltage to digital value (0–4095).

  4. ESP32 compares value with safety threshold.

  5. If value > threshold → Stress detected.

  6. Warning message sent to:

    • Serial Monitor (wired)

    • Bluetooth Terminal (wireless)

  7. Engineer can monitor bridge health remotely using mobile.


🎓 Extra Viva Questions (Very Important)

❓ Why use Bluetooth instead of only Serial Monitor?

✔ Remote monitoring
✔ No USB cable required
✔ Real-time field monitoring


❓ Why GPIO 34 is used?

✔ It is an ADC-only pin
✔ Suitable for analog sensors


❓ What is ADC resolution of ESP32?

✔ 12-bit
✔ Range: 0 – 4095

Scroll to Top