Pixart/Wiimote sensor library for Arduino

by Stephen Hobley on March 1, 2009

I just finished the first pass of the C++ object library for accessing the WiiMote/Pixart sensor from an Arduino. A simple example included with the library.

(With a quick appearance by my daughter…)

You do need to desolder the sensor and hook up a control circuit for I2C before you can use it. Like this.

The seeing Arduino type thing…

Just a first pass – all feedback greatly appreciated.

Download Library


{ 46 comments… read them below or add one }

johnnyonthespot March 25, 2009 at 1:38 am

yay, I look-ith, and then I find-ith. Have you posted the schematic for the oscillator that you have used?

good work,

shobley March 25, 2009 at 7:38 am

I have something somewhere, it’s pretty simple – mine has 4 pins, Gnd, Pwr, output and enable (unconnected). I just use the 3.3v for the Pwr.

Eveything on the Pixart side is 3.3v – if you are using USB to power your arduino then you can use the 3.3v output from the FTDI chip.

johnnyonthespot March 25, 2009 at 11:54 am

Well, I’m trying to hook this up to the arduino duemilinove. (Im guessing this arduino outputs 5v for I2C)

I need to know how to hook up the 25MHZ oscillator (what components are used) because it’s not so obvious on the block diagrams found online at kako.

OR: can I get away with using the 16MHz oscillator off the arduino?

anyway, a schematic or explanation of components used would be helpful to my cause

thanks [making a robotic arm to be controlled by your own movements]

(I can be reached here)

shobley March 25, 2009 at 12:10 pm

If you get the datasheet for the timer I used, there is an example circuit in there.


I just used this circuit to hook up the oscillator, then connected the output line straight to the input of the Pixart sensor.

johnnyonthespot March 25, 2009 at 12:16 pm

and for the I2C level conversion, how did you set that one up?

Thanks for your speedy replies!!

shobley March 25, 2009 at 12:44 pm

Take a look here:


top left image shows the pins to the pixart, and to the arduino, along with the pullup resistors.

johnnyonthespot March 25, 2009 at 3:46 pm

Checked out the manufacture site, they didnt have the data sheet for the 25 MHz.

Do you think that just any oscillator would do. I have a 18Mhz oscillator that I found.

It looks like you hooked up 2 inverters to your oscillator, I’m guessing that came from the data sheet? Do you know why those were there?


shobley March 25, 2009 at 7:33 pm

XO-54B is the series, all the oscillators have the same hook up.


shobley March 25, 2009 at 7:35 pm

I know someone has used a 20Mhz osc, but don’t know about lower, maybe it will work. But at 3.3v, NOT 5v – so you can’t use the Arduino.

johnnyonthespot March 26, 2009 at 1:15 am

Ok, I am going to try out the 18MHz oscillator.

“so you can’t use the Arduino.”
-My arduino has a 3.3V regulated output pin. Why do you say I cannot use the arduino?

Tell me if I’m wrong here:
1. I want to replace your 25MHz oscillator with my 2pin 18MHz oscillator.
2. I will replace your 2 inverter selection with some other type I find laying around…
[I don’t understand what a hex inverter is…]

Then I should be able to use the arduino to communicate via I2C with the pixart right?

I have already successfuly communicated the arduino to the wii nunchuck. Powered the nunchuck at 3.3 V ,but did not regulate the arduino I2C (works like a charm), operating at 100KHz.

johnnyonthespot March 26, 2009 at 1:33 am

About inverters:
Ok, forgive my newbie-ness. Could you explain the inverters in the oscillator circuit. I think I’m mistaking the crystal for the oscillator itself?

Mravier March 30, 2009 at 5:01 am

Hello !
It’s an very interesting idea. and it’s work well ! 😀
Just a question, PixArt sensor using 25Mhz Oscillator so your arduino processor too ?
With Arduino 3,3V – 8Mhz, I Have to use 25Mhz additional oscillator or just plug the sensor on 8Mhz ?

Thanks a lot.

shobley March 30, 2009 at 7:47 am

Basically the Arduino runs at 5v, and the Pixart runs at 3.3v. I would not try to connect the Arduino oscillator to the Pixart as the voltages are not compatible.

I know people have run the Pixart at 20Mhz, but not sure about lower than this.

Mravier March 30, 2009 at 10:15 am

Hi again,
Thanks for your recommandation.
I’ll try with 25Mhz oscillator for the PixArt sensor and an Arduino Pro mini(3.3v – 8Mhz).
Great laser harp by the way.

johnnyonthespot April 3, 2009 at 1:21 pm

Hi again…Just got my 24MHz oscillator in the mail…but then it occured to me
-Why do I want to take this IR camera out of it’s already convenient package.

I’ve tested the SDL, SCL, and GND line of the IR camera, and they are connected directly to the extension port on the wiimote…the only 2 things to worry about are Vc(power) and the CLK. I can just use the old cable I’ve already chopped off of a nunchuck to use the IR camera.

I did some more poking around, and I noticed that the CLK line is not directly connected to the onboard oscillator…

Either way, if there is a problem with adding the new oscillator to that line, I can de-solder that pin only, and re-connect it to the new osc.

All i have to do is add a power switch, oscillator, and power source to the pkg…

wish me luck

shobley April 3, 2009 at 2:28 pm

There might be a problem doing it that way – there is already an I2C master on that bus – and it might steal away the connection to your I2C master.

If you remove the camera completely then you are sure that there is no one competing for the camera.

johnnyonthespot April 3, 2009 at 2:54 pm

aha…But if I don’t supply power to the wiimote (only to the IRcam) then there would be no competition…

Dr. Horrible August 22, 2009 at 9:48 pm

Wait, can it run entirely on the Arduino, or does it have to be connected to the PC to run?

Sorry for what is probably a question with an obvious answer, but I just need clarification.


-Dr. Horrible

shobley August 23, 2009 at 7:56 am

Yes it is possible to have the Arduino be the “brains” behind an embedded solution. The PC is just requesting the coordinates and then plotting them on a screen.

Dr. Horrible August 23, 2009 at 11:58 am

Another question:

Would it be possible in the programming to invert the sensor? as in, make it track dark objects rather than light? If so, where would this modification be made?

Thanks again,

-Dr. Horrible

shobley August 23, 2009 at 1:35 pm

Not really, it’s designed to track up to 4 finite blobs of increased illumination. That is hard coded into the chip.

Your best bet for arbitrary image processing is to use a conventional camera and either a PC/Mac/Linux platform.

Dr. Horrible August 23, 2009 at 7:56 pm

Oh, I was hoping it was part of the Arduino’s programming. Even still, I only wanted to track anything other than light (I’d test against a white background).

In any case, I suppose this isn’t the sensor I need. You wouldn’t happen to know any other blob-tracking-sensors, would you?

I’m trying my best to create a security system that doesn’t require a laptop, only an Arduino. I still need a sensor capable of detecting an anomaly and tell a servo the scaled coordinate/degree to move to.

Thanks for all your help (again),

-Dr. Horrible

Gerald March 7, 2010 at 12:07 am

Hi Guys,

I’m trying to interface the camera to my PIC24F, which is 3.3V

When I send 0xB0, the camera just won’t toggle the SDA pin low to acknowledge the address. This is from looking on the scope. Anyone ever have this issue? Is there something I’m missing?

SeatT March 12, 2010 at 3:20 am

I’m trying to get this running on a PIC32, so if you get your project working, I’m interested.

My camera wouldn’t generate an acknowledge. Turns out I’d forgotten to pull the reset pin on the camera high, which I believe fixed it.

Have you found any other instructions on how to do this with a PIC?

Gerald March 13, 2010 at 2:43 am

Hi there,

I was able to get the camera running on my PIC24F yesterday!

I fixed the nack issue by just sending a stop and start sequence to reset the address transmission.

I followed the steps from Johnny Chung here:


Follow his pseudo code, BUT SEND 0X38 instead of 0x37, as mentioned by some of the responses. I haven’t tried 0x37 though.

Let me know if you want my source code.

Gerald March 13, 2010 at 3:09 am

btw, I just cut off the board and soldered wires to the pcb traces like this:


kurt March 14, 2010 at 3:22 pm

Is it directly connected to the ATMEL CHIP without any I2C level conversion?

Gerald March 14, 2010 at 5:13 pm


I am using the PIC24F, not Atmel. The PIC24F operates on 3.3V, so no voltage level conversion is necessary.

Refer to my website for source code and how I mounted the camera. If you want the complete project, post your email and I will send it to you and help you if you have problems.


wisemen July 5, 2010 at 10:19 am

does the libary will work with pic18?

Joy Holmes July 25, 2010 at 4:37 am


I used the same hardware configuration as mentioned here. Howver, I have run in to this problem;

I read it somewhere, that the Pixart camera returns any value only when it sees a IR Blob. So, accordingly, the Pixart Library mentioned here should also return values only when the camera sees any IR blob, right?

But, in my setup, as soon as I power Arduino, my serial port monitor starts displaying,

Blob 1 detected x=0, y=0, size=0
Blob 2 detected x=0, y=0, size=0
Blob 3 detected x=0, y=0, size=0
Blob 4 detected x=0, y=0, size=0

I dont show it any IR source, yet I keep getting this. When I give it an IR source, it doesn’t track it and still I keep getting the same result!

Please help, I dont seem to be getting to the root of problem.

Thank You

shobley July 25, 2010 at 11:06 am

I had this problem too, your communications are not working. Either the sensor is bad or your line level conversion is not working.

You will need to attach a scope to find out which.

James July 31, 2010 at 12:36 pm


Great Library indeed!

I wanted to know, Will the library work only for the Pixart Sensor?

Can’t any other similar camera work with it, with similar results?


shobley July 31, 2010 at 1:23 pm

James: No it will only work with the Pixart sensor

James July 31, 2010 at 2:06 pm


Joy Holmes August 6, 2010 at 10:50 am


I reviewed all the connections.

I’m still getting the same error

Blob 1 detected x=0, y=0, size=0
Blob 2 detected x=0, y=0, size=0
Blob 3 detected x=0, y=0, size=0
Blob 4 detected x=0, y=0, size=0

This happens even when I place an IR pass filter in front of the camera and also when I close the lens with my finger.

I cannot seem to understand where the problem exactly can be. Can it happen, due to some damage to the Pixart Sensor while removing from the Wiimote? (Anything to do with the heat of the De-Solder?)

Can you please help?

Would be grateful.

Joy Holmes August 6, 2010 at 11:04 am

…to add on to my previous comment. Something funny is happening here!
When I power off my both 5 V and 3.3V supply, I still get the output (Arduino is powered via USB)

shobley August 6, 2010 at 11:11 am

I need to update the library to explicitly return “no connection to camera” when this happens.

I have only ever seen this problem when the communication with the Pixart sensor has failed. Either the sensor is bad, or the communication level converter is not doing it’s job correctly.

You did not mention if you have scoped the input and response to and from the Pixart sensor.

It is equally likely that Nintendo has changed the programming on their chips to prevent people from using them – I bought my Wiimotes all at the same time, and so far I’ve not had a problem with the sensors.

Joy Holmes August 6, 2010 at 11:44 am

“if you have scoped the input and response to and from the Pixart sensor” – I’m sorry but I don’t know how could I do this. I am a newbie. Would be glad if you can help.

shobley August 6, 2010 at 12:32 pm

I think I need to revisit this project – I get enough email about it that maybe I should make some more movies that show some of the debugging procedures you can use.

I’ll post an update on my blog when I get them done.

Adam MacDonald September 14, 2010 at 1:49 pm

I’m trying to use the Pixart camera in my helicopter project. I have an 8mhz Arduino Mini Pro 3.3v, and some questions:

1. Can I wire the SDA/SCL pins directly to the Arduino without the buffer in between, since they both work at 3.3V?
2. Can the Pixart work with a clock of 8Mhz? How about 4Mhz? Is there a lower bound, and why?
3. Once I write code so the Arduino outputs a high frequency (maybe 8Mhz) PWM signal on a digital pin, can I use this as a clock input?

If the answers are yes, yes, and yes, I won’t need any of the circuitry described in these posts, correct?


Stephen Hobley September 14, 2010 at 3:15 pm


I would say

1. Not sure, I would try it and see what happens
2. See 1
3. See 2

Personally I would try and get the Pixart sensor working correctly using a known configuration first – just so that you know what a “good” configuration is like.

But do let me know what you discover.

Adam MacDonald September 21, 2010 at 12:37 pm


I managed to get an 8Mhz signal by setting the fuse bytes on the Arduino to output the clock signal on a digital pin. Voltmeter shows 1.7V but I don’t have an oscilloscope to double-check the frequency.

After hooking everything up, I am getting the 0,0,0 output described above. No idea if it’s the clock or the I2C lines, and unfortunately I don’t have much else around to test with.

Any other debugging advice you could give? I suppose I could order a bunch of parts and build a 25Mhz clock, but it seems to me it should work like this…


Adam MacDonald September 21, 2010 at 12:52 pm

Well, I realized I should be using Analog 4 and 5, not digital, for I2C. Changed that, and it works!

So it works without any extra components, just the Pixart and an Arduino Mini 3.3V on an 8Mhz clock.

Thanks for your help!

Stephen Hobley September 22, 2010 at 2:01 pm

Adam : Thanks for letting us know – that’s really good information. I have a Cortex ARM dev board that works on a 12Mhz clock and 3.3V native.

I’ll be trying to hookup one of my sensors to that.

Tara Moore July 3, 2011 at 2:56 pm

I have watched the video and learned something from it. Thanks for sharing.

Anacleto November 21, 2011 at 8:37 pm

It’s working! It’s WORKING!!!!!! Man this is huge! Thanks a lot to both you and Kako! Many many thanks!

Leave a Comment

Comments links could be nofollow free.

{ 4 trackbacks }

Previous post:

Next post: