PARKcore - ECE 4180 Final Project

By Hannah Blankenship and Eric Hsieh
Georgia Tech Spring 2019


PARKcore

/media/uploads/hblankenship3/blackbox.jpg

A parking assistance tool utilizing ultrasonic sensors to detect when the front of a vehicle is approaching the end of a parking space. Data from the sensors is displayed in a smartphone app connected through bluetooth using an Adafruit Bluefruit LE chip. Completed as a project for ECE 4180 - Embedded Systems Design.


Basic Instructions

  • Before using PARKcore, download the modified Adafruit Bluefruit app from github.
  • Attach the two sonar sensors to the hood of your car. The closer to front the better. Angle them so they are pointed horizontally forward.
  • Secure the black box in between the two sonar sensors.
  • Connect the Bluefruit App on your Android phone to the Adafruit Bluefruit LE bluetooth connection.
    • Select UART.
  • Begin Parking.

Usage

The two sonar sensors relay information to the Mbed, which in turn relays the information through the Bluetooth app. The car represents your car, and displays the relative distance to the closest object in front of it. As the distance to object in front of it changes, the app will change as well.

The Sonar Sensors are not optimal for edges nor oddly shaped objects. They are most optimally used pointed towards a flat wall. Failure to do so will result in inaccurate readings.


Parts Used

/media/uploads/hblankenship3/mbed.jpg

/media/uploads/hblankenship3/ble1.jpg

/media/uploads/hblankenship3/hcsr04.jpg


Wiring

/media/uploads/hblankenship3/mbedpinout1.png


Mbed Code

This code reads distance values from the ultrasonic sensors to determine the distance of the car from the end of the parking space. When ran with the updated Bluefruit smartphone app (github link on this page), the user can connect to the app via bluetooth, and it will give a visual of how close the user is to the edge of the parking space.

#include "mbed.h"
#include "ultrasonic.h"

Serial blue(p28, p27);
 
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
DigitalOut d1led(p21);
DigitalOut d2led(p22);
 
 int d1 = 0; //Distance 1
 int d2 = 0; //Distance 2
 float avgd = 0; //Average Distance
 bool startup = true;
 bool d1Error = false;
 bool d2Error = false;
 
 void dist1(int distance1)
{
    //code to execute when the distance has changed
    if (startup) {
        d1 = distance1;
    }
    else if (distance1 < distance1 + 2150 && distance1 > distance1 - 2150 && distance1 < 10000 && distance1 > 10) { //limiter to remove extremes. 2150 mm/s == 5 mph, appropriate when parking
        d1 = distance1;
        d1led = 0;
    }
    else if(distance1 > 10000 || distance1 < 10) {    //Feature: If the sonar sensors returns a value over 10000 (likely an error)
        d1Error = true;             //the display will be the last distance recorded
        d1led = 1;                  //and will set an error flag, as well as turn an LED on.
    }
}

 void dist2(int distance2)
{
    //code to execute when the distance has changed
    if (startup) {
        d2 = distance2;
    }
    else if (distance2 < distance2 + 2150 && distance2 > distance2 - 2150 && distance2 < 10000 && distance2 > 10) {
        d2 = distance2;
        d2Error = false;
        d2led = 0;
    }
    else if(distance2 > 10000 || distance2 < 10) {
        d2Error = true;
        d2led = 1;
    }
}
 
ultrasonic mu1(p6, p7, .1, 1, &dist1);      //Set the trigger pin to p6 and the echo pin to p7
                                        //have updates every .1 seconds and a timeout after 1
                                        //second, and call dist when the distance changes
ultrasonic mu2(p12, p13, .1, 1, &dist2);
 
int main()
{
    mu1.startUpdates();//start measuring the distance
    mu2.startUpdates();
    mu1.checkDistance();
    mu2.checkDistance();
    wait(3); //Tends to error if read immediately.
    startup = false;
    while(1)
    {
        mu1.checkDistance();     //call checkDistance() as much as possible, as this is where
                                //the class checks if dist needs to be called.
        mu2.checkDistance();
        avgd = (d1+d2) / 2;    //averages distance values
        if(avgd < 300){ //less than 1 ft, should brake. 1 light
            led1 = 1;
            led2 = 0;
            led3 = 0;
            led4 = 0;
        } else if(avgd < 900 & avgd >= 300) { //1ft to 3 ft, slow down. 2 lights
            led1 = 1;
            led2 = 1;
            led3 = 0;
            led4 = 0;
        } else if(avgd < 2700 & avgd >= 900) { //3 ft to 9 ft, got room. 3 lights
            led1 = 1;
            led2 = 1;
            led3 = 1;
            led4 = 0;
        } else if(avgd >= 2700) { //9f+, keep moving - 4 lights
            led1 = 1;
            led2 = 1;
            led3 = 1;
            led4 = 1;
        }
        blue.printf("%f", avgd/1000); // prints value
        wait(1);
    }
}

https://os.mbed.com/users/hblankenship3/code/final_project/


Bluefruit Application

The app shows 4 different screens to indicate how far the car is from the edge of the parking space.

  • Screen 1:

/media/uploads/hblankenship3/car111.jpg

The front of the car is 9+ feet away from the edge of the parking space. It is safe to proceed forward.

  • Screen 2:

/media/uploads/hblankenship3/car222.jpg

The front of the car is in the 3-9 foot range from the edge of the parking space.

  • Screen 3:

/media/uploads/hblankenship3/car333.jpg

The front of the car is 1-3 feet away from the edge of the parking space. The driver should begin slowing.

  • Screen 4:

/media/uploads/hblankenship3/car444.jpg

The front of the car is less than 1 foot from the edge of the parking space. The driver should brake and put the car in park.

Adafruit Bluefruit LE Connect Android App

The Android App can be found here and must be opened with Android Studio.

The app is a modified version of the original Bluefruit LE Connect app, found here.

The modifications were done to the UART page, which normally displays the serial input from the Mbed. It was modified by first finding the UART page in its corresponding XML file and adding an imageview into the display. The imageview takes in the path of a resource image, and will display a picture. In the corresponding .java file for the UART, find the variable that holds the serial data being input, which in our case would be the average distance from the Mbed. The serial data coming in is the average distance from the sonar sensors, and is sent as a float. The serial data will come in as a spammableStringBuilder, so we converted to a string, and then use float.parsefloat() to convert it into a float. Textview is used to display the average distance coming from the Mbed, and has a string appended to it.

The Mbed output is an average distance. In order to make the different images appear with different average distances, thresholding is used. For each threshold, the current image is changed by changing the imageview with imageiew.setresource, and using the R.drawable.car# method call to change the car pictures.

The pictures start with car0, which has no distance, and immediately jumps to the current thresholded distance.


Demo

/media/uploads/hblankenship3/img-3713.jpg /media/uploads/hblankenship3/img-3715.jpg


Special thanks to Elissa Huang for Android Studio assistance.


Please log in to post comments.