An homebrew DIY breakout board for the ITG3200 gyroscope: tested with Arduino and Processing

Last updated on Tue, 2012-01-31 12:57. Originally submitted by fabio on 2010-11-08 16:21.

Some days ago I posted about my first homebrew DIY breakout board for the ADXL345 accelerometer. That was pretty ugly but worked very good.

Today, after some other tests, I show you my new homebrew DIY breakout board: this time it is for an ITG3200 gyroscope. And you'll see that I really improved a lot!

Some changes between the previous breakout board:

  • I'm now using an FR4 board instead of a bekelite one. Bakelite is easy to drill and really light weight but it can't handle the reflow process temperature: it burns. FR4 instead is really better: after the reflow it doesn't have any signs of damage.
  • I'm now using smd capacitors instead of through hole. This helps keeping the size of the board small.
  • The board has now two sides: top and bottom. This also helps keeping the size small and making everything more polished.

In the attachment you find the kicad sources, the printer ready PDF, and the Arduino and Processing programs. The processing programs need to be executed on the Processing IDE, available for download from
Remember to adjust the serial port configuration in the Processing code to match your connection to the Arduino in your system. Here I use /dev/ttyUSB9, if you are under windows you'll probably have to use something like COM3 or something like that. See in the Arduino IDE under Tools->Serial Port to get the exact value you have to use.

In the next days I will create some more breakout boards for the ADXL345 and the HMC5843 ICs. Stay tuned!

Breakout board designs printer ready (PDF)22.64 KB
Kicad sources for the Breakout board designs100.33 KB
ITG3200 Processing Code23.71 KB
ITG3200 Arduino Code2.89 KB
ITG3200 breakout board Schematics11.41 KB

expected values of this

Submitted by Anonymous (not verified) on Tue, 2013-11-12 10:18.

expected values of this sensor??

urgent ;);)

Extra Offset getting added to ITG3200 output after spurious osc.

Submitted by Vinay (not verified) on Thu, 2013-01-24 15:35.

Hi Fabio,
First of all, a lot of appreciation for creating an awesome piece of code for interfacing the ITG3200 with the Arduino and the Processing code for displaying the Gyro output graphically.. Has helped me a lot :-)

I'm building a Self balancing robot using ITG3200 and an Accelerometer (MMA7361L). I'm using your code on the TI MSP430 Launchpad with Energia ( -- Arduino port for MSP430).

With the use of the ITG3200, given some basic offset, the raw values/readings are well around '0' (zero).. But if I move the ITG3200 breakout board, to and fro, at a faster rate, the raw values have an added offset and show a higher reading, even when the Gyro is at rest..

The raw values are like this :
in the beginning --
X: 0 Y: -2 Z: 1

after strong movement, the values are like this (values keep oscillating around this value; they are not fixed):
X: -228 Y: -301 Z: -87
(once the values go to this level, even small oscillations/movements cause a large fluctuation in the values )

If I reset the micro-controller (Texas Instruments MSP430G2553), then the values are back to normal ie.. Zero (0)..

Why is that so? How can it be fixed?

remove wrinkles instantly

Submitted by jerrysamon (not verified) on Fri, 2012-10-26 19:03.

Bye-Bye Wrinkles Instantly. Wrinkles are not visible. What the eye sees is actually the shadow made by the wrinkle.

remove wrinkles instantly

Submitted by jerrysamon (not verified) on Sun, 2012-10-07 09:41.

Dermatologist-recommended LifeCell is the world's first ALL-IN-ONE cream. What exactly does LifeCell do to make it an "All-in-One" cream? Let's look at all the benefits below.

ITG3200 breakout board and Arduino UNO connection circuit

Submitted by julio menezes (not verified) on Tue, 2012-01-31 18:23.

Hi all,

I bought a sparkfun ITG3200 breakout board.
I wanna connect it to an Arduino UNO.

As some here have one, I woudl like to get some help.

a) Do I need pull-up resistores for I2C lines SDA and SDL to conect to Arduino UNO A4 and A5 ?
b) Do I need a time delay to connect Vlogic to UNO 3v3 ?
If so, could it be done with two 10K resistores and a capacitor between them ? What type and value for the capacitor. Do I need a diodo too ?
c) I see 2 resistores on Fabios's protoboard but I could figure out where they are used.

tks in advanced,

julio menezes

temperature problem !

Submitted by konfafal (not verified) on Thu, 2011-12-15 10:11.

i read all axis and that works great:

void update_ITG3200(char * gyro_buff)
for(int i=0; i<8; i++)
read_ITG3200(0x1B+i, &gyro_buff[i]);

gyro_temperatura = ((int16_t)gyro_buff[0] << 8) | gyro_buff[1];
gyro_x = ((int16_t)gyro_buff[2] << 8) | gyro_buff[3];
gyro_y = ((int16_t)gyro_buff[4] << 8) | gyro_buff[5];
gyro_z = ((int16_t)gyro_buff[6] << 8) | gyro_buff[7];

but the temperature is still the same "2048"

what is wrong ?

ITG 3200 raw data example

Submitted by Faitie (not verified) on Tue, 2011-05-10 10:50.

Hi there ,
I'm working on a school project that uses the ITG 3200. But instead of the arduino board i have to use a PIC32MX board. However i still had alot of help from your code. But with the ITG3200 i still have some unsolved anwsers. I used the same init as you.
WriteTo(0xD0,0x15,0x07); // EB, 50, 80, 7F, DE, 23, 20, FF
WriteTo(0xD0,0x16,0x1E); // +/- 2000 dgrs/sec, 1KHz, 1E, 19

but when i watch the output values they fail miserably. i get like.
Xas_gyro : 65473,000
Yas_gyro : 65457,000
Zas_gyro : 65517,000

Would u know where my mistake could be made. If u want i can mail u my code.
Thanks in advance.

made a mistake the output

Submitted by Faitie (not verified) on Tue, 2011-05-10 10:55.

made a mistake the output data is like this when the breakout board is still
Xas_gyro : 65473,000
Yas_gyro : 6,000 or a 7,000
Zas_gyro : 65517,000

Usually such output is a

Submitted by fabio on Tue, 2011-05-10 12:20.

Usually such output is a consequence of a non happening communication. Have checked that you are actually communicating with your device? You can do this by reading one of the expected values registers.

yes i am communicating with

Submitted by Faitie (not verified) on Tue, 2011-05-10 13:10.

yes i am communicating with the device, i can get the data from the Who_am_i register perfectly. I now tried reading from a single output register. The GYRO_XOUT_H register and i get a 255 when the gyro is lying still and on the GYRO_XOUT_L i get 0 when lying still. btw i use the 9 Degrees of Freedom - Sensor Stick from sparkfun.

Can't help you much more on

Submitted by fabio on Tue, 2011-05-10 14:00.

Can't help you much more on this. If you are able to communicate with the device there could be something wrong in the axis reading code or you may have gotten a faulty gyroscope (sometime it happens).

Don't you have access to an Arduino compatible board? This way you may simply use my code to test your device.

Figured it out, the problem

Submitted by Faitie (not verified) on Wed, 2011-05-11 10:01.

Figured it out, the problem was IDE related, code was correct. MPLAB made my variable look like a 32bit number, while in fact it should have been a 16 bit number.

Thanks anyway for trying to help me out ;)


Submitted by Tex (not verified) on Sat, 2011-03-19 11:31.

Hi Fabio! A question about calibration: for the ADXL when i've motionless device i should read 0 0 256 from it. About GYRO i should attend 0 0 0 right? Thanks

Ideally, yes. You can average

Submitted by fabio on Sat, 2011-03-19 11:54.

Ideally, yes. You can average some readings at your program initialization and then simply use them as offsets. A more advanced approach is this.

Did you managed to get your board assembled? I'd like to see a picture of it!

Ok. Yes... i've just send

Submitted by Tex (not verified) on Sat, 2011-03-19 13:38.

Ok. Yes... i've just send mail to u. Have good lunch. Tex

one question for you

Submitted by Tex (not verified) on Sat, 2011-03-05 14:00.

Hi Fabio! I've received my sensors from sparkfun after one month... and now i become to enjoy with them.
Reading your code, i've one question about this lines of code:

  Gyro ITG-3200 I2C
  temp MSB = 1B, temp LSB = 1C
  x axis MSB = 1D, x axis LSB = 1E
  y axis MSB = 1F, y axis LSB = 20
  z axis MSB = 21, z axis LSB = 22

  int regAddress = 0x1B;
  int temp, x, y, z;
  byte buff[TO_READ];
  char str[50]; // 50 should be enough to store all the data from the gyro
  readFrom(GYRO_ADDR, regAddress, TO_READ, buff); //read the gyro data from the ITG3200
  temp = (buff[0] << 8) | buff[1];
  x = ((buff[2] << 8) | buff[3]) + offx;
  y = ((buff[4] << 8) | buff[5]) + offy;
  z = ((buff[6] << 8) | buff[7]) + offz;

The "readFrom()" command as is written should read only data from register 0x1B (regAddress) that's the TEMP register (relative to the first 8bit, MSB). Right? I don't understand how this code can read data about gyro.
Can u help me? Thanks Tex


Submitted by fabio on Sat, 2011-03-05 17:07.
readFrom(GYRO_ADDR, regAddress, TO_READ, buff);

This call means, read from the device GYRO_ADDR, starting from regAddress for TO_READ bytes and put them inside buff.

As TO_READ = 8, this means that you will read 8 bytes from the ITG3200 and, as the gyro will automatically increment its internal pointer it will read from the 0x1B to 0x22 registers address which contains all the data you are interested.

Hope this helps,


ok but...

Submitted by Tex (not verified) on Sat, 2011-03-05 19:10.

Thanks reply me Fabio.
Ok, after your explanation, i understand what u want to say, and is right and logic because the ITG-3200 sends data about temperature and gyros. Reading the ITG3200 datasheet's and your code i didn't find about incrementation of pointer. I knew i must read from 8 data registers, 2 for temperature, 2 for x axis, 2 for y axis and 2 for z axis but i didn't see anything about incrementetion of pointer. Neither into the declaration of readFrom() function:

//reads num bytes starting from address register on device in to buff array
void readFrom(int device, byte address, int num, byte buff[]) {
  Wire.beginTransmission(device); //start transmission to device 
  Wire.send(address);        //sends address to read from
  Wire.endTransmission(); //end transmission
  Wire.beginTransmission(device); //start transmission to device
  Wire.requestFrom(device, num);    // request 6 bytes from device
  int i = 0;
  while(Wire.available())    //device may send less than requested (abnormal)
    buff[i] = Wire.receive(); // receive a byte
  Wire.endTransmission(); //end transmission

Into the datasheet, about Sensor Registers (pg. 27 of 39), this is not explain.
If u don't tell me that, where can i read about the incrementation of pointer? :) Sorry but im not good in programming.
Thanks Tex

See page 20 of the datasheet,

Submitted by fabio on Sat, 2011-03-05 19:43.

See page 20 of the datasheet, last phrase.

This is however a common behavior you'll find in most I2C devices.

thanks Fabio

Submitted by Tex (not verified) on Sat, 2011-03-05 19:50.

True! Thanks a lot Fabio.

my first I2C connection

Submitted by Tex (not verified) on Sat, 2011-03-05 19:51.

As title: it's my first experience with I2C conenction. Thanks

No problem. We all had this

Submitted by fabio on Sat, 2011-03-05 19:53.

No problem. We all had this questions when we started.

Take care,


Thank you!!

Submitted by Anonymous (not verified) on Sat, 2011-02-26 22:00.

Our gyro is working well ... thanks to your code :)

Arduino BT and ITG3200

Submitted by Kris2010 (not verified) on Tue, 2011-02-22 23:51.

Hi Fabio,
Im using the following soursecode
on my arduino BT atmega 328.
I get Datas but I think the datas are not exact it seems like the sensor is more sensitive compared to a very similiar sourcecode ((its from which I m using on my arduino dumilanove.It only takes a short move of the sensor and the Z axis shows a full scale of 2000 degrees per sec. I power the board with two 1,5 V batteries.
thx greets Kris

Hi Fabio, I tried ur

Submitted by Kris2010 (not verified) on Wed, 2011-02-23 02:05.

Hi Fabio,

I tried ur ITG3200.pde and it works!I put the Itg3200 on a rotor and I got for the Z Axis (during the rotor ran with 5 rounds per sec.) the value 22422 degrees per sec.I guess I need to put a komma like 2242,2 ?

My code, if I remember

Submitted by fabio on Wed, 2011-02-23 09:22.

My code, if I remember correctly, prints out raw values from the gyroscope. In order to get the true deg/sec value you have to divide everything by 14.375.

Btw, did you get a fixed value from it? It should change when you move the gyro..

Did u mean my sketch? When I

Submitted by kris (not verified) on Wed, 2011-02-23 16:21.

Did u mean my sketch? When I move the Sensor the values are changing!
But the Values are wrong.only a short move causes a full scale range.
I extend ur sketch with the /14.375. do i need to put a comma to the output console datas?

Nope, the Serial.print()

Submitted by fabio on Wed, 2011-02-23 16:33.

Nope, the Serial.print() method should take care of that for you.

gooood !

Submitted by kris (not verified) on Wed, 2011-02-23 17:37.

gooood !

I tested your code and it

Submitted by fabio on Wed, 2011-02-23 00:24.

I tested your code and it works here. Please post example output you get.
Have you tried my code above? Is it working?

compatibility with the Arduino-Pro Mini

Submitted by Windell Jones (not verified) on Thu, 2011-01-06 23:10.

Hi Fabio, By what I've come up with it seems that your example code for the ITG3200 is Arduino type independent as long as there is a serial port and an I2C port. Is this correct?

I'm working on downsizing my previous implementation from the Arduino Mega to the Arduino-Pro Mini. Do you forsee any problems with this?


that should work

Submitted by fabio on Thu, 2011-01-06 23:24.

Hi Windell, nice to see you kept hacking ;-)

I don't think you should have any problem porting that to the Pro Mini. The micro-controllers are just the same so that should work.

The only thing I can think of is that I never used an 8Mhz board (which some of the ProMini) are so I'm not sure on how I2C works there.

Do you have a 16 Mhz or a 8 Mhz Pro-Mini?

Btw, if you are up to downsizing things keep an eye on my last project: Femtoduino, an ultrasmall 20.7x15.2 mm Arduino compatible board.

Thanks for the reply Fabio.

Submitted by Windell Jones (not verified) on Thu, 2011-01-06 23:59.

Thanks for the reply Fabio. I'm thinking about using the 16Mhz Pro Mini Here:

When is your Femtoduino being released? I love the name!

Ok, then you shouldn't have

Submitted by fabio on Fri, 2011-01-07 00:40.

Ok, then you shouldn't have any problem with the 16Mhz Pro Mini.

I'm happy you liked the name ;-) ... It will require at least 3 weeks to get some prototypes out so don't hold your breath .. just keep an eye on my site as I'll post here as soon as I have updates!

Take care!

I want to use your processing

Submitted by Anonymous (not verified) on Mon, 2010-12-20 20:09.

I want to use your processing software to display 3D box through COM1,Could you tell me the syntax of COM.So I can input the data from my microcontroller directly,thank you very much.

Just replace /dev/ttyUSB0

Submitted by fabio on Tue, 2010-12-21 17:01.

Just replace /dev/ttyUSB0 with COM1 in the line (from this source):

myPort = new Serial(this, "/dev/ttyUSB0", 9600);

Let me know if you still have problems ;-)

ITG 3200 freez randomly

Submitted by Paolo Mosna (not verified) on Sun, 2010-12-19 15:05.

Hy Fabio,

I'm using your code to manage a ITG 3200 gyro.
I'm using an Arduino BT , with full logic to 3.3v.
I do not use pull-up resistors on i2c SDA and SCL lines.

When I start the application arduino works correctly for a while sending the correct data via bluetooth; then randomly the arduino freezes and stops sending data on bluetooth connection.
This behavior seems to happen randomly.

Could this behavior be caused by missing pull-up resistors?

Any suggestion is welcome.

Hi Paolo, yeah, that's a

Submitted by fabio on Sun, 2010-12-19 22:05.

Hi Paolo,

yeah, that's a known problem which popups occasionally on the online discussions on this chip.

I also experienced occasional hangs with it but I personally think that's more of an hardware problem (high noise on the lines) than a bug in the software.. It's also known that Arduino Wire library is quite not really tolerant on the quality of the channel.. It expects a quite perfect channel while most of the time it isn't.

I discussed this at

I somehow fixed this using an external voltage regulator to convert from 5V to 3.3V and added a 100nF cap on the input voltage to the regulator and a 10uF on its output. I also changed my 10K Ohm pullup resistors (which you should use as this chip doesn't have one integrated) to 2.2K Ohm.

With this configuration I can run my FreeIMU code for days without hangs on the UNO while every 2 o 3 hours with the same circuit on the Duemilanove it would hangs.

I currently don't have a solution for you. I planned to dive into modifying Wire to make it more elastic on the channel quality but I've been taken into something else so I still did not do that. Moreover I currently don't have a logic analyzer nor an oscilloscope at home so I can't debug it right now (this should change in the near future).

Let me know what you think about this.. got any idea?


Submitted by ThanhTran (not verified) on Mon, 2010-12-13 10:35.

Hey Fabio,

Just want to say thanks. I used your Arduiono code and your processing script to test my ITG3200 board. Your code works great!

Thanks again.


I'm happy you have been

Submitted by fabio on Mon, 2010-12-13 11:29.

I'm happy you have been successful with it. Keep an eye on my website as I'm continuing working on these chips so you'll probably find more things useful.

Take care,


Itg3200 data are not changing

Submitted by ThanhTran (not verified) on Mon, 2011-01-03 11:33.

Hi Fabio

Hope you have a Great & Happy New Year!
Today I'm running the ITG test code that I downloaded from your site last time. However, this time it doesnt run correctly. All the printed out data is unchanged. They all look like this:


though I tried to twist the gyro board, but those data are not changing.

I'm wondering if you have any suggestion what I should do?

I remember the first time when I tried your code, it also showed similar problem, but then it somehow went away when I tried to compile and upload the ITG3200.pde file to the Arduino. This time it stays. I did redownload the file from your site to check to see if I've modified anything. I didn't do anything to the file other than using 0x68 as the address instead of 0x69.

Any suggestion?



It's strange

Submitted by ThanhTran (not verified) on Mon, 2011-01-03 13:33.

I decided to put an oscilloscope the SCL and SDA pins to see what's going on. When I did so, the Arduino rebooted, and then when it came back up, it was working just fine. I verified the response from your processing script and everything seemed fine. I'm using 6.8K pull up resistors, are they too large?



let's see...

Submitted by fabio on Mon, 2011-01-03 21:17.

Hi Thanh,

6.8k Ohm resistor looks quite right. Personally I used values between 2.2k to 10k Ohm. Bigger values are bad if you have long wires and/or a noisy connection, smaller values are better in such cases. 4.7K Ohm should be the advised resistor value in the Philips official I2C specifications.

The fact that you are reading fixed values is usually a symptom of a bad communication. Basically the Arduino tries to read something but receive nothing so the value of the input variable never gets changed so you get those garbage values.

Check your connections again, you'll probably find something bad there. If you can't, just upload a picture to a service like Imageshack and then link it here. I will have a look at your connections.


Submitted by ThanhTran (not verified) on Tue, 2011-01-04 09:14.

Hi Fabio

Thanks very much for your help.
Here are the images:

Gyro board:

Connection to Arudino board

It could be my arduino board has problem. I've seen a cap went loose on that cheap Arduino board before.




Submitted by fabio on Tue, 2011-01-04 09:40.

Yeah! You are also into homebrew PCB breakout board development! Really funny stuff!

Unfortunately, debugging homebrew boards is pretty impossible! I had a look at your connections and everything looks good. I can't understand the PCB at 100% from the picture but what I checked seems pretty good.

Are you able to test your board on a original Duemilanove/UNO board? That would helps removing the bad Arduino possibility you thought.


Submitted by Thanh Tran (not verified) on Tue, 2011-01-04 15:20.

Hi Fabio
thanks for looking at those photos. I tried to put somnpressure on the atmel 328 on the arduino board and the gyros stop responding to motion. Push the atmel chip some more and it worked again. So I resoldered all the pins around the atmel chip on the Arduino board and now it seems everything is fworking ine no matter what I do: stressing twisting the board, etc.
So you were right that the connections were bad. :)

thanks again Fabio


ps. I saw that you have a branch of of itg-3200-driver on google code (or maybe Filippe, the owner of that code Lehrer with your code and created a branch under your name). I don't know much if at all about Arduino development environment, but I Think you or Filippe needs to provide the file keyword.txt so that the library could be used in Arduino libraries.

I'm trying to get this itg3200 gyro working with an MSP430 though. My PCB's schematic is almost a replicate of the schematic in the datasheet. I was trying to test my board using your code so that I have a working base line to compare with :). Thanks Fabio!

good news!

Submitted by fabio on Tue, 2011-01-04 17:57.

Yeah, I made some big patches on Felipe code so he created a branch for me to hack around.. Now everything has been incorporated into the main trunk so my branch is now outdated and to be removed. For more informations you can have a look at

So, in the end, was your Arduino clone faulty? That sucks! I always bought original Arduinos because fighting with such problems can really get you crazy!

May I ask what are you up to? We may share efforts in the future.. Currently I'm working with orientation filtering in the field of Tangible User Interfaces and HCI in general.. basically "smart" prototypes of next gen mice/mouses.

If you are into Orientation Filtering you might want to have a look at the FreeIMU project, a 9DOM/DOF board which I developed and I'm now offering for buying. This is a pretty cool project as it will come with a robust set of library which will make orientation filtering really easy!

Also, check out my other project: Femtoduino an ultrasmall (20.7x15.2 mm) Arduino compatible board


Submitted by ThanhTran (not verified) on Wed, 2011-01-05 11:05.

Hi Fabio

Yes, the problem was actually the clone Arduino board. It didn't reflow properly I believe.

Thanks for the info on the itg3200 driver branch. Like I mentioned, I'm pretty clueless at Arduino development environment. I wasn't sure how to use that driver in the Arduino IDE. I copied the driver into a directory under Arduino: C:\arduino-0022\libraries\ITG3200 but when I tried to compile the example project (the pde file, it couldn't find itg3200.h file.) I guessed the keyword.txt file was missing (compared to other libraries under Arduino).

I'm trying to make a small & stable flying platform. Here is what I got so far:

Your FreeIMU project might fit my objective perfectly :). Currently, my flying platform only uses gyro, no accelerometer. I will have to spend sometime reading that. I've heard about DCM, but don't really know how it works.

The Femtoduino looks great. Really small.



On DCM and sensor fusion in

Submitted by fabio on Wed, 2011-01-05 14:43.

On DCM and sensor fusion in general you can have a look at my 9DOM/DOF sensor fusion algorithm implementation. It's capable of running directly on your uC and works pretty well.

On DCM have a look at this:

Btw, your small quad copter looks really cool!

Hi Fabio, Just tried your

Submitted by Windell Jones (not verified) on Mon, 2010-12-13 03:44.

Hi Fabio, Just tried your suggestion to include 10K pullup resistors on the SCL and SDA lines, however, still the same problem.

Here is what the stream reads...

I also tried the 2.2K option just for grins, but still the same result.
The code I'm running is the _12_ITG3200 file.

Pictures of my setup is here.

Any ideas? I really appreciate your time and patience.