Parkingc

From Hackerspace Brussels
Jump to: navigation, search


Parkingc
[[Image:{{{picture}}}|200px]]
What:
a captor to detect a free parking on a map.
Tagline:
easy parking detection.
Maintainer(s):
Thibault Ahn
Archived:
yes


Project ParkingC[edit]

Goal[edit]

"Make a low cost, fully automatic available parking detector framework."

Goals

  • User friendly android app
  • cheap captor
  • open source project


Why[edit]

It is a good solution to solve the problems of parking in the big cities and especially in Brussel.

This project will go through 3 phases:[edit]

Phase 1: Make a working prototype[edit]

Phase 2: Create an Android Software[edit]

Phase 3: Link the prototype captor and the app[edit]

We are now at the beginning of phase 1.

Description[edit]

Hardware[edit]

Captor[edit]

Arduino prototype+GPS+Ultrasound captor

http://xv4y.radioclub.asia/2013/04/12/mesure-de-distances-avec-un-capteur-ultrason-et-un-arduino/

A solution with one CPU and a battery of captors can be developed later.

Arduino and electronics[edit]

http://playground.arduino.cc/Tutorials/GPS

Hardware mods still to do[edit]

...

Software[edit]

The android app is developed with Eclipse Java and the plug-in for android. The lay-out is written in XML.

Software to do[edit]

  • Application on Android with Eclipse to detect on an API google map the free parking.
  • Software with Arduino to detect a free parking with a captor with gps and ultrasound.

Results[edit]

A car will park on the place and the detector will detect if the place is available or not. The user in the car will use on an android phone to check the availability of parking place around the car with a map app.

Java code[edit]

Arduino code[edit]

GPS

#include <string.h>
#include <ctype.h>
int ledPin = 13;                  // LED test pin
int rxPin = 0;                    // RX PIN 
int txPin = 1;                    // TX TX
int byteGPS=-1;
char linea[300] = "";
char comandoGPR[7] = "$GPRMC";
int cont=0;
int bien=0;
int conta=0;
int indices[13];
void setup() {
  pinMode(ledPin, OUTPUT);       // Initialize LED pin
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  Serial.begin(4800);
  for (int i=0;i<300;i++){       // Initialize a buffer for received data
    linea[i]=' ';
  }   
}
void loop() {
  digitalWrite(ledPin, HIGH);
  byteGPS=Serial.read();         // Read a byte of the serial port
  if (byteGPS == -1) {           // See if the port is empty yet
    delay(100); 
  } else {
    // note: there is a potential buffer overflow here!
    linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
    conta++;                      
    Serial.print(byteGPS, BYTE); 
    if (byteGPS==13){            // If the received byte is = to 13, end of transmission
      // note: the actual end of transmission is <CR><LF> (i.e. 0x13 0x10)
      digitalWrite(ledPin, LOW); 
      cont=0;
      bien=0;
      // The following for loop starts at 1, because this code is clowny and the first byte is the <LF> (0x10) from the previous transmission.
      for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
        if (linea[i]==comandoGPR[i-1]){
          bien++;
        }
      }
      if(bien==6){               // If yes, continue and process the data
        for (int i=0;i<300;i++){
          if (linea[i]==','){    // check for the position of the  "," separator
            // note: again, there is a potential buffer overflow here!
            indices[cont]=i;
            cont++;
          }
          if (linea[i]=='*'){    // ... and the "*"
            indices[12]=i;
            cont++;
          }
        }
        Serial.println("");      // ... and write to the serial port
        Serial.println("");
        Serial.println("---------------");
        for (int i=0;i<12;i++){
          switch(i){
            case 0 :Serial.print("Time in UTC (HhMmSs): ");break;
            case 1 :Serial.print("Status (A=OK,V=KO): ");break;
            case 2 :Serial.print("Latitude: ");break;
            case 3 :Serial.print("Direction (N/S): ");break;
            case 4 :Serial.print("Longitude: ");break;
            case 5 :Serial.print("Direction (E/W): ");break;
            case 6 :Serial.print("Velocity in knots: ");break;
            case 7 :Serial.print("Heading in degrees: ");break;
            case 8 :Serial.print("Date UTC (DdMmAa): ");break;
            case 9 :Serial.print("Magnetic degrees: ");break;
            case 10 :Serial.print("(E/W): ");break;
            case 11 :Serial.print("Mode: ");break;
            case 12 :Serial.print("Checksum: ");break;
          }
          for (int j=indices[i];j<(indices[i+1]-1);j++){
            Serial.print(linea[j+1]); 
          }
          Serial.println("");
        }
        Serial.println("---------------");
      }
      conta=0;                    // Reset the buffer
      for (int i=0;i<300;i++){    //  
        linea[i]=' ';             
      }                 
    }
  }
}

Ultrasound

/* Prototype mesures ultrason avec affichage LCD By Yannick DEVOS - XV4Y

http://xv4y.radioclub.asia/

Copyright 2013 Yannick DEVOS under GPL 3.0 license Any commercial use or inclusion in a kit is subject to author approval

The display is on a 16x2 LCD Display with HD44780 compatible driver, use the traditional 4 bits interface on pins 10, 9, 8, 7, 6, 5

In order to compile this program with Arduino 1.0.1, you will need to install 2 libraries : - New LiquidCrystal

https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

- NewPing ultrasound sensor library

https://code.google.com/p/arduino-new-ping/

Revision history : v1.00 2013-04-11

        First release


  • /
  1. include <Wire.h>
  2. include <LiquidCrystal.h>
  3. include <NewPing.h>

// **** // Here some Parameters you may change // ****

  1. define ULTRA_TRIGGER A2 // What pin we have connected the Ultrasonic range sensor Trigger pin
  2. define ULTRA_ECHO A3 // What pin we have connected the Ultrasonic range sensor Echo pin
  3. define MAX_DISTANCE 350 // Maximum distance we want to ping for (in centimeters). Most sensor are rated at 400-500cm.

// Variables unsigned long duration=0; long int distance=0;

LiquidCrystal lcd(5, 6, 7, 8, 9, 10); // You can change this settings to your convenance, please see the library documentation NewPing sonar(ULTRA_TRIGGER, ULTRA_ECHO, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

void setup() {

 lcd.begin(16,2);
 lcd.home ();

 lcd.print("Ultraçon");

 pinMode(ULTRA_TRIGGER, OUTPUT);
 pinMode(ULTRA_ECHO, INPUT);

 delay(1000);
 lcd.clear();
 lcd.setCursor ( 0, 0 );
 lcd.print("Distance"); 

}

void loop() {

 // The speed of sound is 340 m/s or 29 microseconds per centimeter.
 // The ping travels out and back, so to find the distance of the
 // object we take half of the distance travelled.
   duration = sonar.ping_median(5);  // We do 5 measurements to have a good average and filter bad measurements
   distance = ((340 * duration) / 1000)/2;

   lcd.setCursor ( 0, 1 );
   lcd.print("              mm");
   lcd.setCursor ( 0, 1 );
   lcd.print(distance);
   delay(500);

}