DIY Head Tracker 3 – Calibration, Orientation and Resolution

Calibrate to Agitate

Each MPU-6050 chip needs calibrating to ensure drift free fun.


There is an excellent guide here:


Over on the i2c library forums a kind fellow has posted a sketch that will output some values that  you can then plug into the Joystick sketch.

Upload the sketch in the usual way, set the MPU-6050 as flat as possible and run the sketch.  Open up the serial coms window (shift-ctrl-m) and after a few minutes the sketch should output some ‘offset values’.

These can then be used in the joystick sketch


That should ensure drift free operation.

On top or On The Side?

The data sheet for the MPU-6050 talk about ensuring it’s mounted flat and level. This doesn’t mean you can only mount it on top of your head. The chip needs to be flat againt the object you interested in, i.e. RC bugger, glider or your head.  As long as the axis of rotation line up then you can mount on top, on the side and any way up.

My head appears to pitch on the axis through my ears, so I’ve mounted my Head Tracker with the MPU6050 as close to this axis as possible, i.e stuck on the side of my headphone.

Wherever you mount you device it needs to be fixed firmly with no wriggle room. I also tape the USB cable to make sure that can’t pull on or move the device.


The original joystick emulation code used 8 bits for each axis. That only gives 255 distinct head positions in each dimension. The effect is if you move your head slowly you get multi-pixel jumps in the on screenm view.

I’ve updated the HID description and code to now use 16 bit values. This gives sub-pixel head tracking resolution and a much smoother experience.

The updates files also implement a shorter re-calibration time, down from 5 seconds to 2. So if you do need to hit the recal button it’s less of a pain waiting.

ta ta


10 thoughts on “DIY Head Tracker 3 – Calibration, Orientation and Resolution

  1. Pingback: DIY Head Tracker | Mis-adventure in 3d Printing

  2. So I can get things to start working but I have a few questions.

    How do I invert an axis within the code itself and how can I stop the axis from “rolling over.” For instance if I yaw left in a game, if I keep turning, not even a full 360, suddenly I will yaw right in game or in the windows calibration window. Can I set a maximum value or something to stop this?

  3. Hi,

    Sorry for being something of a dunce, but I am new to all of this. Have tried compiling the sketch ‘EDTRACKERIICalibrate.ini’ priior to uploading to Headtracker and a slew of errors are thrown-up, starting with:

    EDTrackerIICalibrate.ino: In function ‘void setup()’:
    EDTrackerIICalibrate:133: error: ‘mpu_read_6050_accel_bias’ was not declared in this scope
    EDTrackerIICalibrate:136: error: ‘mpu_set_dmp_state’ was not declared in this scope
    EDTrackerIICalibrate.ino: In function ‘void loop()’:
    EDTrackerIICalibrate:176: error: ‘dmp_read_fifo’ was not declared in this scope
    EDTrackerIICalibrate.ino: In function ‘void initialize_mpu()’:

    And continuing along the same lines. I realise I’m doing something wrong, but would appreciate some guidance.

    Kind regards,


  4. Hi,

    You are very kind. Compiles properly now. Next step to see if I can upload the sketch and get everything working.

    Thanks again,


  5. Thanks again. All your advice has been spot-on, and somehow I seem to have soldered the device correctly as it works. A bit of drift, but that seems quite common and shall keep a weather-eye for updates.

    Many thanks again to you and to Brumster. As a total noob to this I have been extremely impressed by the sense of community and the generosity exhibited here.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s