Hi I am working on a project in which I am supposed to tell if a person is running/standing/walking and going upstairs/downstairs or he is on straight road. The person will carry a arduino uno module to which gps,bluetooth and altitude sensor is attached. Also I am trying to send my phone his speed and current altitude he is experiencing using HC-05 bluetooth module. I am sure that there is no problem with altitude sensor. Also I must note that my gps module(GY_NE06MV2) is not acting proper when it comes to speed of the person. I believe this is because I experimented in my house and not outside. The problem is that I cannot see speed and altitude data on bluetooth terminal app"ArduTooth" on my phone. It is just like a blank space which should have been my data. I am presenting my code which is not very long and I hope you could help me get through this.
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
TinyGPSPlus gps; //gps object to be used
SoftwareSerial BTserial(10, 11); //bluetooth serial connection
SoftwareSerial gps_serial(4,3); //gps serial connection
Adafruit_BME280 bme; //altitude measuring sensor object
#define SEALEVELPRESSURE_HPA (1011) //sea level pressure in Turkey/Eskisehir
double speed = 0; //speed of a moving body
double current_altitude = 0;
double previous_altitude = 0;
void setup() {
Serial.begin(115200); // serial connection to computer
BTserial.begin(9600);
gps_serial.begin(9600);
bme.begin(0x76);
delay(3000);
previous_altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
}
void loop() {
//data from gps device is fed to gps object
while (gps_serial.available() > 0){
gps.encode(gps_serial.read());
}
if(gps.speed.isValid()){
speed = gps.speed.kmph();
BTserial.write(speed); // this is where the problem-1 is, this data is not shown on mobile phone
bluetooth terminal application
BTserial.write(",");
if(speed <= 5 && speed > 0.5){
BTserial.write("walking");
BTserial.write(",");
}
if(speed <= 0.5){
BTserial.write("standing");
BTserial.write(",");
}
if(speed > 5){
BTserial.write("running");
BTserial.write(",");
}
}else{
BTserial.write("m.s.n.n"); //stands for "moving status not known"
BTserial.write(",");
}
current_altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
BTserial.write(current_altitude); //this is where problem-2 is, this data also is not displayed
on phone
BTserial.write(",");
//this part determines either the body goes upstairs or downstairs or he is on straight road
if(current_altitude - previous_altitude >= 0.7){
BTserial.write("going ups.");
previous_altitude = current_altitude;
}
if(previous_altitude - current_altitude >= 0.7){
BTserial.write("going downs.");
previous_altitude = current_altitude;
}
if((current_altitude - previous_altitude <= 0.3) || (previous_altitude - current_altitude <=
0.3)){
BTserial.write("on s.r");
previous_altitude = current_altitude;
}
BTserial.write(";");
delay(1000);
}
I must note that purpose of BTserial.write(","); is that every seperate entry sent to phone via bluetooth must be seperated by ",".