Google Glass and Arduino Via Bluetooth

Hello to all,

In one of my projects, I get data from sensors and I send them with a system composed of an Arduino Nano 33 BLE Sense and a Bluetooth HC-05 module. The data are sent as a string of characters. The first step was to make an Android application on the phone to acquire the data by Bluetooth and display them (this application works).

The second step is to convert this application to work on Google Glass (first edition). I manage to convert the application but I run into a simple pairing problem.

Indeed, the Google Glass behaves like a Bluetooth headset or wireless headphones (pairing by clicking on a window appearing on a phone) and does not propose to pair via the HC-05 PIN code. This is problematic because I can't pair my glasses with my HC-05 and thus test my application.

But I know it's possible because I saw on Youtube people doing it with OBD2 adapters (on their car) so I guess an SPP communication is possible:
https://www.youtube.com/watch?v=VOsbwaNHrx8
https://www.youtube.com/watch?v=Q2yX1ZkR2JI

I also managed to find an article on a down website:


I give you my Arduino code :

/*---------------------------------------*/
/*********** Librairies ******************/
/*---------------------------------------*/

#include "Arduino.h" 
#include <math.h> 
#include <Arduino_LPS22HB.h>
#include <Arduino_HTS221.h>
#include <Arduino_LSM9DS1.h>
#include <Arduino_APDS9960.h>
#include <SparkFun_Ublox_Arduino_Library.h>
#include <Wire.h>

/*---------------------------------------*/
/************ Classes  *******************/
/*---------------------------------------*/

SFE_UBLOX_GPS myGPS ;
UART hc05(digitalPinToPinName(4), digitalPinToPinName(3), NC, NC) ;

/*---------------------------------------*/
/*********** Variables  ******************/
/*---------------------------------------*/

boolean BT_STATE = true ;

float static_pressure = 0.0 ;
float temperature = 0.0 ;
float humidity = 0.0 ;
float dew_point = 0.0 ;
float altitude_baro = 0.0 ;
float angle_to_north = 0.0 ;
float xmag = 0.0 ;
float ymag = 0.0 ;
float zmag = 0.0 ;

const int xmin = -26 ;
const int xmax = 15 ;
const int ymin = 18 ;
const int ymax = 58 ;
int xmagc = 0 ;
int ymagc = 0 ;

float xacc = 0.0 ;
float yacc = 0.0 ;
float zacc = 0.0 ;
float xgyr = 0.0 ;
float ygyr = 0.0 ;
float zgyr = 0.0 ;
int current_time = 0 ;
float latitude = 0 ;
float longitude = 0 ;
float speed = 0 ;
long altitude_GPS = 0;
int hour_UTC = 0 ;
int min_UTC = 0 ;
float cap_GPS = 0.0 ;
long heading = 0 ;
byte satellites = 0;
int timeout = 50 ;
float roll = 0.0 ;
float pitch = 0.0 ;
float mean_altitude = 0.0 ;
int numberFrame = 0 ;

int r, g, b, a; 

String string_status ;
String string_numberFrame ;
String string_current_time ;
String string_hour_UTC ;
String string_min_UTC ;
String string_temperature ;
String string_humidity ;
String string_static_pressure ;
String string_dew_point ;
String string_latitude ; 
String string_longitude ; 
String string_speed ; 
String string_G ; 
String string_cap ;
String string_roll ;
String string_pitch ;
String string_mean_altitude ;
String string_angle_to_north ;

String string_final ;

/*---------------------------------------*/
/*********** Prototypes  *****************/
/*---------------------------------------*/

float dewPoint(float celsius, float humidity) ;
float calcAltitudeBaro(float pressure) ;

/*---------------------------------------*/
/*********** SETUP SYSTEM  ***************/
/*---------------------------------------*/

void setup() 
{
  Serial1.begin(9600); // UART to GPS
  hc05.begin(9600);
  pinMode(3, INPUT);
  pinMode(4, OUTPUT);
   
  if (IMU.begin() && HTS.begin() && BARO.begin() && APDS.begin() && myGPS.begin(Serial1)) 
  {
    string_status = "OK" ;
  }
  else 
  {
    string_status = "NOK" ;
    //Rajouter des codes erreurs et led pour erreur Bluetooth
  }
}

/*---------------------------------------*/
/*********** LOOP SYSTEM  ****************/
/*---------------------------------------*/

void loop() 
{
  if (BT_STATE == true) 
  {
    current_time = millis()/1000 ; //s
  
    static_pressure = BARO.readPressure()*10 ; //kPa to hPa
    temperature = HTS.readTemperature(); //°C
    humidity = HTS.readHumidity() ; //%
    altitude_baro = calcAltitudeBaro(static_pressure) ; //ft
    IMU.readMagneticField(xmag, ymag, zmag); //uT
    IMU.readAcceleration(xacc, yacc, zacc); //G
    IMU.readGyroscope(xgyr, ygyr, zgyr); // °/s
    latitude = myGPS.getLatitude(timeout)*0.0000001 ; //°
    longitude = myGPS.getLongitude(timeout)*0.0000001 ; //°
    speed = myGPS.getGroundSpeed(timeout)*0.0036 ; //km/h
    altitude_GPS = myGPS.getAltitudeMSL(timeout)/1000*3.281 ; //ft
    hour_UTC = myGPS.getHour(timeout);
    min_UTC = myGPS.getMinute(timeout);
    heading = myGPS.getHeading(timeout)*0.00001 ; //°
    dew_point = dewPoint(temperature, humidity) ; //°C
    roll = 0.25 * (roll + float(xgyr) * 0.1) + 0.75 * atan2((double)yacc, (double)zacc) * 180 / PI; //X
    pitch = 0.25 * (pitch + float(ygyr) * 0.1) + 0.75 * atan2((double)xacc, (double)zacc) * 180 / PI; //Y

    if(altitude_GPS == 0) //réception GPS ou non.
    {
      mean_altitude = altitude_baro ;
    }
    else 
    {
      mean_altitude = (altitude_baro + altitude_GPS)/2 ;
    }
    
    cap_GPS = heading ; 
    APDS.readColor(r, g, b, a) ; //à utiliser 
  
    xmagc = map(xmag, xmin, xmax, -1000, 1000) ;
    ymagc = map(ymag, ymin, ymax, -1000, 1000) ;
    angle_to_north = atan2(ymagc, xmagc) * 180 / PI ; //Magnetic North in ° par rapport à x (heading)
    if (angle_to_north > 360.0) angle_to_north -= 360.0 ;
    if (angle_to_north < 0.0) angle_to_north += 360.0 ;
  
    string_numberFrame = String(numberFrame) ;
    string_current_time = String(current_time) ;
    string_hour_UTC = String(hour_UTC);
    string_min_UTC = String(min_UTC);
    string_temperature = String(temperature) ;
    string_humidity = String(humidity) ;
    string_dew_point = String(dew_point) ;
    string_static_pressure = String(static_pressure) ;
    string_latitude = String(latitude) ; 
    string_longitude = String(longitude) ; 
    string_speed = String(speed);
    string_G = String(zacc) ;
    string_cap = String(cap_GPS);
    string_roll = String(roll) ;
    string_pitch = String(pitch) ;
    string_mean_altitude = String(mean_altitude) ;
    string_angle_to_north = String(angle_to_north) ;
  
    numberFrame++ ;
  
    string_final = string_numberFrame + "/" + string_current_time + "/" + string_hour_UTC + ":" + string_min_UTC
    + "/" + string_temperature + "/" + string_humidity + "/" + string_dew_point + "/" + string_static_pressure
    + "/" + string_latitude + "/" + string_longitude + "/" + string_speed + "/" + string_G 
    + "/" + string_cap + "/" + string_roll + "/" + string_pitch + "/" + string_mean_altitude 
    + "/" + string_angle_to_north + "/" ;
  
    hc05.println(string_final);
  }
  
  delay(100) ; //Délai pour GPS
}

/*---------------------------------------*/
/*********** DECLARATION  ****************/
/*---------------------------------------*/

float calcAltitudeBaro(float pressure) //Faire calibration thermique et vérifier (param en hPa) 
{  
   pressure = pressure * 100 ;
   float A = pressure/101325;
   float B = 1/5.25588;
   float C = pow(A,B);
   C = 1 - C;
   C = C /0.0000225577;
   return C*3.281; //conversion en ft
}

float dewPoint(float celsius, float humidity)
{
  const float a = 17.27;
  const float b = 237.7;
  float temp = (a * celsius) / (b + celsius) + log(humidity * 0.01);
  return (b * temp) / (a - temp);
}

Do you have any ideas or some advices?

I thank you in advance.

this seems definitely a google API question and not an arduino question...

also you already posted that question here a while back

please don't double post. I re-opened the other topic.

Thank you, I will move in the other topic.