Car Speed Detector

by abdulibra_85 in Circuits > Arduino

422 Views, 1 Favorites, 0 Comments

Car Speed Detector

صورة التوصيل.jpg
GPS to nextion display with Arduino UNO connection
GPS to nextion display with Arduino UNO connection
GPS to nextion display with Arduino UNO connection
GPS to nextion display with Arduino UNO connection
GPS to nextion display with Arduino UNO connection

Hi There everyone, This is my first Instructables publication. I am going to go through list of steps to perform car speed detector experiment as my graduation project.

Required Components

Nextion LCD screen.jpg
Arduino UNO.jpg
Ublox.jpg
USB cable.jpg

1- Arduino UNO

2- One Serial GPS Module.

3- One Nextion Serial 3.5 inch NX4832T035_011Display (any other Nextion Display is fine)

4- Female-Female jumper wires to program the Display.

5- Few jumper wires to connect the components together.

Setting Up Nextion Editor

FCLY56AIWWFJ9WH.jpg
FBEZTE5IWWFYI8R.png
nextion display.png

To program the Nextion Display, you will need to Download and Install the Nextion Editor.
1- Start the Nextion EditorFrom the Menu select |File|New|

2- In the "Save As" dialog, type project file name, and select a location to save the project

3- Click on the "Save" button

4- In the "Settings" dialog, select the Display type

5- Click on the "DISPLAY" tab on the left to show the Display settings

6- Select Horizontal orientation for the display

7- Click on the "OK" button to close the dialog

HARDWARE CONNECTIONS

GPS module connection.png
Nextion LCD screen.jpg

BETWEEN Arduino AND NEXTION WE WILL connect it directly to a pc with a usb power supply with Rx cable to Tx in an Arduino UNO

BETWEEN GPS AND Arduino TX OF GPS TO Rx PIN OF Arduino VCC TO VCC GND TO GND

Coding Preview

code preview.png

here is the required code for starting up the circuit and display GPS data on display.

"I will attach it at the end of this report"

code:

/*
* connect gps module GY-NEO6M * tx of gsm to pin 3 of arduino Rx of GPS to pin 2 of arduino

*/ #include

#include

TinyGPS gps; SoftwareSerial ss(3, 2); /// rx of arduino , tx of arduino

static void smartdelay(unsigned long ms); static void print_float(float val, float invalid, int len, int prec); static void print_int(unsigned long val, unsigned long invalid, int len); static void print_date(TinyGPS &gps); static void print_str(const char *str, int len);

void setup() { Serial.begin(9600); ss.begin(9600); }

void loop() { float flat, flon; unsigned long age, date, time, chars = 0; unsigned short sentences = 0, failed = 0; gps.f_get_position(&flat, &flon, &age); //////////////get latitude,long and data from GPS Serial.print("t6.txt="); //////////////////////////// send Latitude data to NEXTION LCD Serial.write('"'); print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6);/////latitude Serial.write('"'); Serial.write(255);Serial.write(255);Serial.write(255);

Serial.print("t7.txt="); ////////////////////////// send Longitude data to NEXTION LCD Serial.write('"'); print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6); /////longitude Serial.write('"'); Serial.write(255);Serial.write(255);Serial.write(255);

Serial.print("t8.txt="); /// send date and time to nextion lcd Serial.write('"'); print_date(gps); Serial.write('"'); Serial.write(255);Serial.write(255);Serial.write(255);

Serial.print("t10.txt="); ///////// send altitude to nextion lcd Serial.write('"'); print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 7, 2); //// altitude Serial.write('"'); Serial.write(255);Serial.write(255);Serial.write(255);

Serial.print("t11.txt="); ////////////////////send speed to nextion lcd Serial.write('"'); print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);///////////////speed Serial.write('"'); Serial.write(255);Serial.write(255);Serial.write(255);

gps.stats(&chars, &sentences, &failed); smartdelay(1000); }

static void smartdelay(unsigned long ms) { unsigned long start = millis(); do { while (ss.available()) gps.encode(ss.read()); } while (millis() - start < ms); }

static void print_float(float val, float invalid, int len, int prec) { if (val == invalid) { while (len-- > 1) Serial.print('*'); Serial.print(' '); } else { Serial.print(val, prec); int vi = abs((int)val); int flen = prec + (val < 0.0 ? 2 : 1); // . and - flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1; for (int i=flen; i

static void print_int(unsigned long val, unsigned long invalid, int len) { char sz[32]; if (val == invalid) strcpy(sz, "*******"); else sprintf(sz, "%ld", val); sz[len] = 0; for (int i=strlen(sz); i 0) sz[len-1] = ' '; Serial.print(sz); smartdelay(0); }

static void print_date(TinyGPS &gps) { int year; byte month, day, hour, minute, second, hundredths; unsigned long age; gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age); if (age == TinyGPS::GPS_INVALID_AGE) { Serial.print("**********"); Serial.write('"'); Serial.write(255);Serial.write(255);Serial.write(255); Serial.print("t9.txt="); Serial.write('"'); Serial.print("**********"); } else { char sz[32]; sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d ", month, day, year, hour, minute, second); for(int x=0;x<11;x++)Serial.print(sz[x]); Serial.write('"'); Serial.write(255);Serial.write(255);Serial.write(255); Serial.print("t9.txt="); Serial.write('"'); for(int x=11;x<32;x++)Serial.print(sz[x]); //Serial.print(sz); } //print_int(age, TinyGPS::GPS_INVALID_AGE, 5); smartdelay(0); }

static void print_str(const char *str, int len) { int slen = strlen(str); for (int i=0; i