Languages

Menu
Sites
Language
I want to get gyroscope sensor values
X: <div id="gyroX"></div>
Y: <div id="gyroY"></div>
Z: <div id="gyroZ"></div>
var gyroscopeSensor = tizen.sensorservice.getDefaultSensor("GYROSCOPE");
function onGetSuccessCB(sensorData) {
document.getElementById("gyroX").innerHTML = sensorData.x;
document.getElementById("gyroY").innerHTML = sensorData.y;
document.getElementById("gyroZ").innerHTML = sensorData.z;
}
function onsuccessCB() {
gyroscopeSensor.getGyroscopeSensorData(onGetSuccessCB);
}
gyroscopeSensor.start(onsuccessCB);
The x, y and z are fixed at 1 or -1, not change.
 

 

 

Edited by: ahjin lee on 17 Sep, 2020

Responses

3 Replies
Erik van Gompel

This worked OK for me on my Galaxy Watch Active.

    	window.addEventListener('devicemotion', function(e) {
			var gyroX = e.accelerationIncludingGravity.x;
			var gyroY = e.accelerationIncludingGravity.y;
			var gyroZ = e.accelerationIncludingGravity.z;

			document.getElementById('gyroX').innerHTML = gyroX;
			document.getElementById('gyroY').innerHTML = gyroY;
			document.getElementById('gyroZ').innerHTML = gyroZ;
		}, true);
Rajan singh

Below steps apply for Arduino. After all the hardware connection follow the below steps

1.  Download the IMU library from Github.

2. Paste the below code on Arduino's new page.

3. After uploading the code, you should see the results appear. It should look something like this:

 

void setup() {
  // join I2C bus (I2Cdev library doesn't do this automatically)
  Wire.begin();
 
  // initialize serial communication
  // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
  // it's really up to you depending on your project)
  Serial.begin(38400);
 
  // initialize device
  Serial.println("Initializing I2C devices...");
  accelgyro.initialize();
 
  // verify connection
    Serial.println("Testing device connections...");
    Serial.println(accelgyro.testConnection() ? "MPU9250 connection successful" : "MPU9250 connection failed");
    delay(1000);
    Serial.println("     ");
 
 //Mxyz_init_calibrated ();
}
 
void loop()
{   
    getAccel_Data();
    getGyro_Data();
    getCompassDate_calibrated(); // compass data has been calibrated here
    getHeading();               //before we use this function we should run 'getCompassDate_calibrated()' frist, so that we can get calibrated data ,then we can get correct angle .                    
    getTiltHeading();           
 
    Serial.println("calibration parameter: ");
    Serial.print(mx_centre);
    Serial.print("         ");
    Serial.print(my_centre);
    Serial.print("         ");
    Serial.println(mz_centre);
    Serial.println("     ");
 
 
    Serial.println("Acceleration(g) of X,Y,Z:");
    Serial.print(Axyz[0]);
    Serial.print(",");
    Serial.print(Axyz[1]);
    Serial.print(",");
    Serial.println(Axyz[2]);
    Serial.println("Gyro(degress/s) of X,Y,Z:");
    Serial.print(Gxyz[0]);
    Serial.print(",");
    Serial.print(Gxyz[1]);
    Serial.print(",");
    Serial.println(Gxyz[2]);
    Serial.println("Compass Value of X,Y,Z:");
    Serial.print(Mxyz[0]);
    Serial.print(",");
    Serial.print(Mxyz[1]);
    Serial.print(",");
    Serial.println(Mxyz[2]);
    Serial.println("The clockwise angle between the magnetic north and X-Axis:");
    Serial.print(heading);
    Serial.println(" ");
    Serial.println("The clockwise angle between the magnetic north and the projection of the positive X-Axis in the horizontal plane:");
    Serial.println(tiltheading);
    Serial.println("   ");
    Serial.println("   ");
    Serial.println("   ");
    delay(300);
}

 

finder koy

This worked OK for me on my mobile active.!