Package Exports
- mpu6050-gyro
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mpu6050-gyro) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mpu6050-gyro
A node driver for the MPU-6050 IMU. Tested and working on Raspberry pi.
Installation
npm install mpu6050-gyroUsage
var gyro = require("mpu6050-gyro");
var address = 0x68; //MPU6050 address
var bus = 1; //i2c bus used
var gyro = new gyro( bus,address );
async function update_telemetry() {
var gyro_xyz = gyro.get_gyro_xyz();
var accel_xyz = gyro.get_accel_xyz();
var gyro_data = {
gyro_xyz: gyro_xyz,
accel_xyz: accel_xyz,
rollpitch: gyro.get_roll_pitch( gyro_xyz, accel_xyz )
}
console.log(gyro_data);
setTimeout(update_telemetry, 500);
}
if ( gyro ) {
update_telemetry();
}Hardware setup
This driver reads MPU-6050 datas over I2C.
Plug VCC to 3.3V ( pin #1 ),
GND to GROUND ( pin #6 ),
SDA to SDA ( pin #3 / GPIO 2 ),
SCL to SCL ( pin #5 / GPIO 3 ).

Available Methods
gyro.get_gyro_xyz()
Returns JSON object with raw x,y,z datas from gyroscope.
gyro.get_accel_xyz()
Returns JSON object with raw x,y,z datas from accelerometer.
gyro.get_roll_pitch( gyro_xyz, accel_xyz )
Returns JSON object with roll and pitch in degrees.
Contributions
Pull requests welcome.
License
MIT
