LAKSHAY GROVER 1747230
Published

Smart Car – Accident Detection and Notification Using Amazon

A smart car that detects accidents and notifies relatives and health organisations using Alexa, mail, SMS and phone notification services.

AdvancedShowcase (no instructions)499
Smart Car – Accident Detection and Notification Using Amazon

Things used in this project

Hardware components

Arduino Mega 2560 & Genuino Mega 2560
Arduino Mega 2560 & Genuino Mega 2560
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Amazon Echo
Amazon Alexa Amazon Echo
×1
WIZnet W600 ethernet Shield
×1

Software apps and online services

Node-RED
Node-RED
Alexa Skills Kit
Amazon Alexa Alexa Skills Kit
Arduino IDE
Arduino IDE
Raspbian
Raspberry Pi Raspbian
AWS Lambda
Amazon Web Services AWS Lambda

Story

Read more

Schematics

NodeRed gateways

NodeRed is used to connect multiple services that are used to notify health organisations and relatives

Code

Car Control

C/C++
To control the car using HC05 bluetooth module
#define in1 5 //L298n Motor Driver pins.
#define in2 6
#define in3 10
#define in4 11
#define LED 13
int command; //Int to store app command state.
int Speedsec;
void setup() {
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(LED, OUTPUT); //Set the LED pin.
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
}

void loop() {
  if (Serial.available() > 0) {
    command = Serial.read();
    Stop(); //Initialize with motors stoped.
    Serial.println(command);
    switch (command) {
      case 70:
        forward();
        break;
      case 66:
        back();
        break;
      case 76:
        left();
        break;
      case 82:
        right();
        break;
      
    }
    
  }
}

void forward() {
  digitalWrite(in1, HIGH);
  digitalWrite(in3, HIGH);
}

void back() {
  digitalWrite(in2, HIGH);
  digitalWrite(in4, HIGH);
}

void left() {
  digitalWrite(in3, HIGH);
}

void right() {
  digitalWrite(in1, HIGH);
}
void Stop() {
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}



Vibration sensor
int vib_pin=7;
int led_pin=13;
void setup() {
  pinMode(vib_pin,INPUT);
  pinMode(led_pin,OUTPUT);
}

void loop() {
  int val;
  val=digitalRead(vib_pin);
  if(val==1)
  {
    digitalWrite(led_pin,HIGH);
    delay(1000);
    digitalWrite(led_pin,LOW);
    delay(1000);
   }
   else
   digitalWrite(led_pin,LOW);
}

Accident Detection Code

C/C++
Detects accident using VIbration sensor and makes efficient using Acceleratometer. For eg, suppose there is sudden retardation and the vibration sensor goes high, the accident is detected
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);

void displaySensorDetails(void)
{
sensor_t sensor;
accel.getSensor(&sensor);
Serial.println("————————————");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" m/s^2");
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" m/s^2");
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" m/s^2"); 
Serial.println("————————————");
Serial.println("");
delay(500);
}

void displayDataRate(void)
{
Serial.print ("Data Rate: ");

switch(accel.getDataRate())
{
case ADXL345_DATARATE_3200_HZ:
Serial.print ("3200 "); 
break;
case ADXL345_DATARATE_1600_HZ:
Serial.print ("1600 "); 
break;
case ADXL345_DATARATE_800_HZ:
Serial.print ("800 "); 
break;
case ADXL345_DATARATE_400_HZ:
Serial.print ("400 "); 
break;
case ADXL345_DATARATE_200_HZ:
Serial.print ("200 "); 
break;
case ADXL345_DATARATE_100_HZ:
Serial.print ("100 "); 
break;
case ADXL345_DATARATE_50_HZ:
Serial.print ("50 "); 
break;
case ADXL345_DATARATE_25_HZ:
Serial.print ("25 "); 
break;
case ADXL345_DATARATE_12_5_HZ:
Serial.print ("12.5 "); 
break;
case ADXL345_DATARATE_6_25HZ:
Serial.print ("6.25 "); 
break;
case ADXL345_DATARATE_3_13_HZ:
Serial.print ("3.13 "); 
break;
case ADXL345_DATARATE_1_56_HZ:
Serial.print ("1.56 "); 
break;
case ADXL345_DATARATE_0_78_HZ:
Serial.print ("0.78 "); 
break;
case ADXL345_DATARATE_0_39_HZ:
Serial.print ("0.39 "); 
break;
case ADXL345_DATARATE_0_20_HZ:
Serial.print ("0.20 "); 
break;
case ADXL345_DATARATE_0_10_HZ:
Serial.print ("0.10 "); 
break;
default:
Serial.print ("???? "); 
break;
} 
Serial.println(" Hz"); 
}

void displayRange(void)
{
Serial.print ("Range: +/- ");

switch(accel.getRange())
{
case ADXL345_RANGE_16_G:
Serial.print ("16 "); 
break;
case ADXL345_RANGE_8_G:
Serial.print ("8 "); 
break;
case ADXL345_RANGE_4_G:
Serial.print ("4 "); 
break;
case ADXL345_RANGE_2_G:
Serial.print ("2 "); 
break;
default:
Serial.print ("?? "); 
break;
} 
Serial.println(" g"); 
}

void setup(void) 
{
Serial.begin(9600);
Serial.println("Accelerometer Test"); Serial.println("");

if(!accel.begin())
{

Serial.println("Ooops, no ADXL345 detected … Check your wiring!");
while(1);
}


accel.setRange(ADXL345_RANGE_16_G);

displaySensorDetails();
displayDataRate();
displayRange();
Serial.println("");
}

void loop(void) 
{ 
sensors_event_t event; 
accel.getEvent(&event);
Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" ");
Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" ");
Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print(" ");Serial.println("m/s^2 ");
delay(500);
}

Credits

LAKSHAY GROVER 1747230

LAKSHAY GROVER 1747230

1 project • 0 followers

Comments

Add projectSign up / Login