Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO-Based Smart Drowning Detection and Alert System with Bluetooth Connectivity

Image of Arduino UNO-Based Smart Drowning Detection and Alert System with Bluetooth Connectivity

Circuit Documentation

Summary

This circuit integrates multiple sensors and a Bluetooth module with an Arduino UNO to monitor environmental conditions and send alerts. The sensors include a PIR motion sensor, a water level float switch sensor, an MPU-6050 accelerometer and gyroscope, and a DS18B20 temperature sensor. The HC-05 Bluetooth module is used for wireless communication. The Arduino UNO processes the sensor data and sends alerts via Bluetooth when certain conditions are met.

Component List

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0

HC-05 Bluetooth Module

  • Description: A Bluetooth module for wireless communication.
  • Pins: EN, VCC, GND, TXD, RXD, STATE

PIR Motion Sensor

  • Description: A sensor to detect motion.
  • Pins: GND, OUTPUT, VCC

Water Level Float Switch Sensor

  • Description: A sensor to detect water level.
  • Pins: Wire2, Wire1

MPU-6050

  • Description: A 6-axis accelerometer and gyroscope.
  • Pins: VCC, GND, SCL, SDA, XDA, XCL, AD0, INT

DS18B20

  • Description: A digital temperature sensor.
  • Pins: VDD, DQ, GND

Resistor

  • Description: A resistor with a resistance of 4.7 Ohms.
  • Pins: pin1, pin2

Wiring Details

Arduino UNO

  • 5V: Connected to VCC of HC-05, PIR Motion Sensor, DS18B20, and MPU-6050 via a 4.7 Ohm resistor.
  • GND: Connected to GND of HC-05, PIR Motion Sensor, DS18B20, MPU-6050, and Water Level Float Switch Sensor.
  • D0: Connected to TXD of HC-05.
  • D1: Connected to RXD of HC-05.
  • A4: Connected to SDA of MPU-6050.
  • A5: Connected to SCL of MPU-6050.
  • D4: Connected to Wire1 of Water Level Float Switch Sensor.
  • D3: Connected to DQ of DS18B20.
  • D2: Connected to OUTPUT of PIR Motion Sensor.

HC-05 Bluetooth Module

  • VCC: Connected to 5V of Arduino UNO.
  • GND: Connected to GND of Arduino UNO.
  • TXD: Connected to D0 of Arduino UNO.
  • RXD: Connected to D1 of Arduino UNO.

PIR Motion Sensor

  • VCC: Connected to 5V of Arduino UNO via a 4.7 Ohm resistor.
  • GND: Connected to GND of Arduino UNO.
  • OUTPUT: Connected to D2 of Arduino UNO.

Water Level Float Switch Sensor

  • Wire2: Connected to GND of MPU-6050 and Arduino UNO.
  • Wire1: Connected to D4 of Arduino UNO.

MPU-6050

  • VCC: Connected to 5V of Arduino UNO via a 4.7 Ohm resistor.
  • GND: Connected to GND of Arduino UNO.
  • SDA: Connected to A4 of Arduino UNO.
  • SCL: Connected to A5 of Arduino UNO.

DS18B20

  • VDD: Connected to 5V of Arduino UNO via a 4.7 Ohm resistor.
  • GND: Connected to GND of Arduino UNO.
  • DQ: Connected to D3 of Arduino UNO.

Resistor

  • pin1: Connected to 5V of Arduino UNO.
  • pin2: Connected to VCC of PIR Motion Sensor, DS18B20, and MPU-6050.

Documented Code

#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <MPU6050.h>

#define PIR_PIN 2
#define FLOAT_PIN 4
#define ONE_WIRE_BUS 3

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
MPU6050 mpu;

bool motionDetected = false;
unsigned long lastMotionTime = 0;
const unsigned long timeoutPeriod = 5000; // 5 seconds

void setup() {
    Serial.begin(9600); // Initialize serial communication for USB
    Serial1.begin(9600); // Initialize serial communication for Bluetooth (HC-05)
    sensors.begin();
    mpu.initialize();
    pinMode(PIR_PIN, INPUT);
    pinMode(FLOAT_PIN, INPUT);
}

void loop() {
    // Read the PIR sensor
    motionDetected = digitalRead(PIR_PIN);
    
    if (motionDetected) {
        lastMotionTime = millis();
    } else if (millis() - lastMotionTime > timeoutPeriod) {
        sendAlert();
    }

    // Check water level
    if (digitalRead(FLOAT_PIN) == HIGH) {
        Serial.println("Water level is high!");
        Serial1.println("Water level is high!"); // Send to Bluetooth
        sendAlert();
    }

    // Read temperature
    sensors.requestTemperatures();
    float temperature = sensors.getTempCByIndex(0);
    Serial.print("Temperature: ");
    Serial.println(temperature);
    Serial1.print("Temperature: "); // Send to Bluetooth
    Serial1.println(temperature);

    // Optional: Read MPU6050 data for more functionality
    int16_t ax, ay, az;
    mpu.getAcceleration(&ax, &ay, &az);
    Serial.print("Accelerometer: ");
    Serial.print("ax: "); Serial.print(ax);
    Serial.print(" ay: "); Serial.print(ay);
    Serial.print(" az: "); Serial.println(az);
    Serial1.print("Accelerometer: "); // Send to Bluetooth
    Serial1.print("ax: "); Serial1.print(ax);
    Serial1.print(" ay: "); Serial1.print(ay);
    Serial1.print(" az: "); Serial1.println(az);

    delay(1000);
}

void sendAlert() {
    Serial.println("ALERT: Possible drowning detected!");
    Serial1.println("ALERT: Possible drowning detected!"); // Send to Bluetooth
    Serial.println("No motion detected for 5 seconds!");
    Serial1.println("No motion detected for 5 seconds!"); // Send to Bluetooth
}

This code initializes the sensors and the Bluetooth module, reads data from the sensors, and sends alerts via Bluetooth when certain conditions are met. The sendAlert function is called when no motion is detected for 5 seconds or when the water level is high. The temperature and accelerometer data are also read and sent to the Bluetooth module.