Smart Accident Prevention System using Internet of Things

Smart Accident Prevention System using Internet of Things

Smart Accident Prevention System using Internet of Things. The following project is concerned with the speed of the vehicle using a transmitter and receiver with the integration of accident prevention and alcohol consumption detection. Road accidents are increasing in our day to day lives. Most of the accidents occur due to over-speeding, drunken driving and careless driving. Though we cannot stop accidents, we can reduce the accidents by taking necessary safety measures. Therefore, there must be a smart accident avoiding system that includes automatic speed control at restricted areas, alcohol consumption detection and the vehicle’s distance from other vehicles on the road to prevent accidents.

Components Used

  • MQ3 Gas Sensor
  • GPS receiver module
  • Mg2639 GSM module
  • Ultra-sonic sensor
  • Node MCU

Working:

The RF transmitting circuit consists of a RF transmitter module. When the RF transmitter is turned on, the data set by the user is encoded and sent to the Receiver module. The receiver module decodes the data. If the speed of the vehicle is less than the limit zone, then no action is taken and the speed of the vehicle remains the same. If the speed exceeds the set speed limit, then the speed limit is set according to the zone.

Pi project
Pi project

Ultrasonic sensors transmit ultrasonic waves from its sensor head and again receives the ultrasonic waves reflected from an object. By measuring the length of time from the transmission to reception of the sonic wave, it detects the position of the object. In case of any accident about to happen by dashing on any obstacle or any other vehicle, the ultrasonic sensor detects it and automatically reduces the velocity of the car.

Hopping data
Hopping data

The alcohol sensor being used will detect the alcohol consumption through the breath of the driver and will notify police about the driver’s condition along with location.

Flow chart of Pi project
Flow chart of Pi project
Pi project1
Pi project1

Code for project

Code: const int trigPin = D1; //D4
const int echoPin = D2; //D3
const int trigPin1 = D6; //D4
const int echoPin1 = D8; //D3
int buzzer = 10;
long duration;
int distance;
long duration1;
int distance1;
typedef struct test_struct {
String VehicleNo;
} test_
test_struct myData;

void OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
memcpy(&myData, incomingData, sizeof (
Serial print ((“Bytes received:
Serial println (
Serial println (myData.
Serial println
void setup ()
Serial pr intln (buzzer, OUTPUT
pinMode (trigPin, OUTPUT ); // Sets the trigPin as an Output
pinMode (echoPin, INPUT ); // Sets the echoPin as an Input
pinMode (trigPin1, OUTPUT ); // Sets the trigPin as an Output
pinMode (echoPin1, INPUT ); // Sets the echoPin as an Input
display begin (SSD1306_
display .
Serial begin (
delay (
if (esp_now_init() != 0)
Serial println ((“Error initializing ESP NOW”
return
esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);
esp_now_register_recv_cb(OnDataRecv);
void loop ()
int distance;
display setCursor (30, 0); //oled display
display setTextSize (
display .setTextColor(
display println ((“SPEED
displaydisplay..setCursorsetCursor(10, 20); (10, 20); //oled display//oled display displadisplayy..setTextSizesetTextSize(2);(2); displaydisplay.setTextColor(WHITE);.setTextColor(WHITE); displaydisplay..printlnprintln(distance_cm);(distance_cm); displaydisplay..setCursorsetCursor(90, 20);(90, 20); displaydisplay..setTextSizesetTextSize(2);(2); displaydisplay..printlnprintln((“cm””cm”);); displaydisplay..setCursorsetCursor(10, 45); (10, 45); //oled display//oled display displaydisplay..setTextSizesetTextSize(2);(2); displaydisplay.setTextColor.setTextColor(WHITE);(WHITE); displaydisplay..printlnprintln(distance_in);(distance_in); displaydisplay..setCursorsetCursor(90, 45);(90, 45); displaydisplay..setTextSizesetTextSize(2);(2); displaydisplay..printlnprintln((“in””in”);); displaydisplay..displaydisplay();(); delaydelay(500);(500); displaydisplay.clearDisplay();.clearDisplay(); SerialSerial..printlnprintln(distance_cm);(distance_cm); SerialSerial..printlnprintln(distance_in);(distance_in); digitalWritedigitalWrite(trigPin1, (trigPin1, LOWLOW); ); //// digitalWritedigitalWrite(trigPin1, (trigPin1, HIGHHIGH);); delayMicrosecondsdelayMicroseconds(10);(10); digitalWritedigitalWrite(trigPin1, (trigPin1, LOWLOW);); duration1 = duration1 = pulseInpulseIn(echoPin1, (echoPin1, HIGHHIGH);); distance_cm1 = (duration1 / 2) / 29.1;distance_cm1 = (duration1 / 2) / 29.1; distance_in1 = (duration1 / 2) / 73.914;distance_in1 = (duration1 / 2) / 73.914; displaydisplay.set.setTextColor(WHITE);TextColor(WHITE); displaydisplay..printlnprintln(distance_cm1);(distance_cm1); displaydisplay..setCursorsetCursor(90, 20);(90, 20); displaydisplay..setTextSizesetTextSize(2);(2);
displaydisplay..printlnprintln((“cm””cm”);); displaydisplay..setCursorsetCursor(10, 45); (10, 45); //oled display//oled display displaydisplay..setTextSizesetTextSize(2);(2); displaydisplay.setTextColor(WHITE);.setTextColor(WHITE); displaydisplay..printlnprintln(distan(distance_in1);ce_in1); displaydisplay..setCursorsetCursor(90, 45);(90, 45); displaydisplay..setTextSizesetTextSize(2);(2); displaydisplay..printlnprintln((“in””in”);); displaydisplay..displaydisplay();(); delaydelay(500);(500); displaydisplay.clearDisplay();.clearDisplay(); SerialSerial..printlnprintln(distance_cm1);(distance_cm1); SerialSerial..printlnprintln(distance_in1);(distance_in1); displaydisplay..printlnprintln(myData.VehicleNo);(myData.VehicleNo); ifif (distance_cm <= 10)(distance_cm <= 10) {{ digitalWritedigitalWrite(buzzer, (buzzer, HIGHHIGH);); delaydelay(1000);(1000); }} elseelse {{ digitalWritedigitalWrite(buzzer, (buzzer, LOWLOW);); delaydelay(1000);(1000); }} }}

Conclusion

Using above steps we can create a smart accident prevention system.

Also read here for more

https://eevibes.com/hardware-devices/raspberry-pi/what-is-the-raspberry-pi-model/

What is the Raspberry Pi Model ?

Leave a Reply

Your email address will not be published. Required fields are marked *