can any one help me?
(i am using a arduino promini (small size) to be fit inside the car with other sensors.)
My project is about smart road to prevent accidents in which i am developing a toy car with a dummy inside it.the dummy is connected with a adxl 345 accelerometre so that if any irregular movement of head occurs it may sense it and also if piezo electric sensor(for vibration purpose) value greater than threshold then accident detected it will activate my gps module and send the data to my app(prepared using mit app inventor i will add the screenshot later) throgh hc 06 bluetooth module .it has four levels i,e lattitude,longitude,date and time.
Also i have attached other sensor like alchohol sensor(mq3) ,16*2 lcd display ,a led and a buzor to test whether the driver is drunk or not.if the sensor detect it then the led will glow and buzor will make sound and alert the driver through lcd pannel that the driver is drunk please stop.
i
what i have achieved - :
(i)when i am using bluetooth module, with gps only i am getting the output on phone but using with other sensor i am not getting any data on phone.(my first language is not english so please bear with my arrogance ).
"data on phone means" i have developed an app with will shows the data on any android phone.
what my problem -:
(i) i am not getting any output on phone as soon as i connect a third sensor like accelerometre or alchohol sensor.( indivisually all sensor work like charm together my gps module not sending any value to phone).
(ii) i am using tiny gps plus library (one problem i notice that if the accelerometere/piezo value is greater than thershold the the loop is not entering inside gps.encode function (may be it returning false). whatever please help me.
below is my code please help me i am stuck here.(THIS CODE IS NOT COMPLETED BUT WORKS ).
#include <TinyGPS++.h>//importing libraries (gps)
#include<LiquidCrystal.h>//
#include <SoftwareSerial.h>//
float lath; //to store latitude value
float longh; //to store longitude value
#include <Wire.h> //importing libraries (accelerometer library)
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
/* Assign a unique ID to this sensor at the same time */
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345); //
float x,y,z; //to store the x,y,z axis value of accelerometre.
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // define rs,rw,enable pin of lcd
/* various pin assigned to pro mini */
const int buzr_pin=6,alcohole_pin=A6, led_pin=7 ,pizo_pin=A3, theshold=100;
SoftwareSerial softserial(8, 9); // using this as rx(8) tx(9) for bluetooth.
int GPSBaud = 9600;
// Create a TinyGPS++ object called "gps"
TinyGPSPlus gps;
void setup()
{
pinMode(led_pin,OUTPUT);
pinMode(buzr_pin,OUTPUT);
pinMode(alcohole_pin,INPUT);
softserial.begin(9600);
// Start the Arduino hardware serial port at 9600 baud
Serial.begin(9600);
lcd.begin(16,2);
// Start the software serial port at the GPS's default baud
Serial.begin(GPSBaud);
lcd.setCursor(0,0);
/* to print message on screen of LCD(ignore it)*/
lcd.print("Welcome To");
lcd.setCursor(0,1);
lcd.print("Tracking System");
delay(5000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Project By");
lcd.setCursor(0,1);
lcd.print("XYZ");
delay(2000);
lcd.setCursor(0,1);
lcd.print("ABC");
delay(2000);
lcd.clear();
/* Initialise the accelerometer sensor( it digital and using i2c protocol) */
//to check whether acelerometre is sendind data or not
if(!accel.begin())
{
Serial.println("Ooops, no ADXL345 detected ... Check your wiring!"); //to check whether aceler
while(1);
}
}
void loop()
{
/* to store and print accelerometre value to serial monitor */
sensors_event_t accelEvent;
accel.getEvent(&accelEvent);
x=accelEvent.acceleration.x;
y=accelEvent.acceleration.y;
/* alchohol sensor work starts*/
float adcValue=0;
for(int i=0;i<10;i++) // it will loop 10 times and return a value(int) to check with thershold.
{
adcValue+= analogRead(alcohole_pin);
delay(10);
}
float v= (adcValue/10) * (5.0/1024.0);
float mgL= 0.67 * v;
Serial.print("Alcohol_val :");// print alchohol value on screen
Serial.println(mgL);
/* print accelerometre value on screen for checking purpose.*/
Serial.print("Accel_x :");Serial.print(x); Serial.print(" ");Serial.print("Accel_y :");
Serial.print(y); Serial.print(" "); Serial.println();Serial.println();
/* condition to check the value of accelerometre and and alchohol sensor*/
if((x>=0.1 && x<=0.5) || (x>=-0.1 && x<=-0.5) ||(y>=0.1 && y<=0.5) || (y>=-0.1 && y<=-0.5)||mgL>2.5)
{
lcd.print("driver is drunk"); // prints on LCD
digitalWrite(buzr_pin,HIGH);
digitalWrite(led_pin,HIGH);
delay(900);
digitalWrite(buzr_pin,LOW);
digitalWrite(led_pin,LOW);
delay(100);
lcd.clear();
}
else
{
lcd.print("Normal ");
Serial.println(" Normal");
digitalWrite(buzr_pin, LOW);
digitalWrite(led_pin, LOW);
delay(500);
lcd.clear();
}
int pizo_value=analogRead(pizo_pin); // read the piezo value.
Serial.print("Piezo_val :");
Serial.println(pizo_value); //print piezo value
Serial.println();
Serial.println();
if(pizo_value>=theshold) // i have given thershold as 100 if greater than it will enter the loop.
{
while (Serial.available() > 0)
{
//THIS IS WHERE THE PROBLEM IS OCCURS HERE THE LOOP DOES NOT ENTER.
if (gps.encode(Serial.read()))
displayInfo();
}
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected"));
while(true);
}
}
}
/* predefined function of tiny gps*/
void displayInfo()
{
if (gps.location.isValid())
{
lath=gps.location.lat();
longh=gps.location.lng();
softserial.println(lath,5); // SENDS LATITUDE VALUE APP
}
}