Introduction: Wii Remote IR Camera Hack With Arduino Interface

Picture of Wii Remote IR Camera Hack With Arduino Interface

We'll physically extract the IR camera from the Wii remote and interface it with an arduino controlling a servo.

The Wii IR camera is a beautiful thing. It has an integrated processor which outputs the X and Y positions and size of the 4 brightest IR points that is sees. This can be very useful for tracking in robotics or human interfaces. Enjoy!

Step 1: Extract the Wii IR Camera

Picture of Extract the Wii IR Camera

You'll need a Wii remote or "Wiimote" to start with. Normally they are about $40, in the end that is not too bad for a pretty awesome sensor. Otherwise you can check out ebay or elsewhere for used or broken Wii remotes.

You'll need to rip apart the case. It has some crazy three pronged screws. I didn't want to completely trash the case so I made a small tool to take it apart.

Now you need to desolder the 8 pins and the 2 struts holding the camera on the board. I used some desoldering braid. It wicks the solder away and makes it easy to get the camera out. Be careful, don't break the camera!

How to use desoldering braid: http://www.youtube.com/watch?v=AcbezX8TrOU

You might want to keep the rest of the parts. You might be able to scrap other parts. Also, If you decide later to use the Wiimote again, you could always put the camera back in.

Step 2: Interface Circuitry

Picture of Interface Circuitry

We'll need a small circuit to interface the IR camera to the arduino. I got all my information from other sources. Here is an exhaustive list:

This fellow (kako) seems to be the first. Here are his pages translated. (Please note that the various translation services online all give slightly different results. It is useful to try several of them.)
http://translate.google.com/translate?u=http%3A%2F%2Fwww.kako.com%2Fneta%2F2008-009%2F2008-009.html&hl=en&ie=UTF-8&sl=ja&tl=en
http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-home&trurl=http%3A%2F%2Fwww.kako.com%2Fneta%2F2007-001%2F2007-001.html&lp=ja_en&btnTrUrl=Translate

Johnny Lee did his part as well and he has some good information:
http://procrastineering.blogspot.com/2008/09/working-with-pixart-camera-directly.html

But the most useful information came from Stephen Hobley. He is going to supply us with the arduino Wii camera library which we will use while programming.
http://www.stephenhobley.com/blog/2009/02/22/pixart-sensor-and-arduino/
http://www.stephenhobley.com/blog/2009/02/24/all-in-one/
http://www.stephenhobley.com/blog/2009/03/01/pixartwiimote-sensor-library-for-arduino/

Ok, to the circuit. We need the clock circuitry and the i2c interface. Do you want to undertand i2c? Don't ask me: http://en.wikipedia.org/wiki/I%C2%B2C

Here is a direct link to the schematic shown below (so you can actually read it.) http://stephenhobley.com/blog/wp-content/uploads/2009/02/wiicam_schem.gif

The clock is pretty simple. You need two capacitors, a 25 MHz crystal, a 1 Meg Ohm resistor and a 74AC04 inverter logic gate. These are all pretty standard parts, you can get them all from Digikey.com or other online electronics sites.

We'll handle the i2c circuit in the next step.

Step 3: I2c Circuit

Picture of I2c Circuit

This part is a little trickier. The i2c chip is a tiny surface mount chip, so you'll need to solder that. First you need the surface mount to DIP board. This will allow us to work with the tiny chip in a prototyping circuit. This chip is the communication device between the 5 volt arduino and the 3.3 volt Wii camera.

The chip:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=LTC4301LCMS8%23PBF-ND

The surface mount to DIP adapter:
http://cimarrontechnology.com/msop-8sot-23-8to8-pindipadapterpn030502.aspx

Here is a great video, which explains, far better than I can, how to solder those darn surface mount chips.
http://www.youtube.com/watch?v=3NN7UGWYmBY

Step 4: Attach It All to the Arduino

Picture of Attach It All to the Arduino

All of the IR camera to i2c and clock connections are shown in the Stephen Hobley schematic (check out the previous steps.) http://stephenhobley.com/blog/wp-content/uploads/2009/02/wiicam_schem.gif

You'll need to connect the arduino to the i2c chip, (also shown in the schematics) and connect the servo to the arduino (I have mine on pin 9, just like in the arduino servo example.)

The arduino chip requires +5 volts and the camera requires +3.3 volts. I had a multiple output power supply, so I gave each part of the circuit what it needed. If you only have a +5v power supply you could add a 3.3 volt voltage regulator to drive the camera.

Step 5: Program the Arduino

Picture of Program the Arduino

This is pretty easy and the fellas who I've linked to worked out most of the details. Good thing, we can get straight to playing around with it.

If you need information about arduino's, just google it. I found all of my info there easily. Here is the main arduino page: http://www.arduino.cc/

First thing, get the servo working. Run the servo example code in the arduino programmer to get your feet wet.

Second, download Stephen Hobley's Wii camera library and example code. Here: http://www.stephenhobley.com/arduino/PVision.zip

Connect the arduino to the same pins that he used. Make sure your i2c circuit and clock are all connected and the power is on and then run the code. You may need to insure that the Pvision.h file is in your arduino library so that is it properly reference when compiling.

Once running, in the serial I/O stream in the arduino programmer you should see data coming in as long as the camera sees some IR light.

I first used a match to check the camera. It worked fine. Later I used an IR led since I needed something a little more steady (and less burny.) You can use a digital camera to see if your IR LED's are working. The camera image sensor picks up the IR light that your eyes cannot see. This is a reassuring way to truly know if the LED's are working.

Step 6: Using the Camera to Control Something.

Picture of Using the Camera to Control Something.
Finally we can run the combined code, actuating the servo with the Wii IR camera output. This is the proof of concept type of project. After proving that this is possible we can go on to building more complicated projects with confidence that we can utilize the Wii IR camera.

I have attached the arduino code files.



The system responds very quickly, even to fast, small movements. Now, we can use the Wii camera directly in all our projects. Look for cheap busted Wii remotes on ebay to salvage.

If you are getting too much noise in the system (i.e. the camera is seeing too many extraneous light sources) you can use the IR filter from the Wii remote. This will filter the lights which are disrupting the camera.

Comments

robotgirl24 (author)2017-03-08

Has anyone had success with the purchased camera from http://www.robotshop.com/en/ir-tracking-camera.htm...? If so, I have a question about what it is capable of.

What hardware is built into the camera? The picture on this product's Wiki makes it seem like it plugs straight into the VCC, GND, SLA, and SDA of the Arduino with absolutely no hardware or circuits required, but I feel like this might be too good to be true.

Is it true that you don't use a 25 MHz crystal, an LTC4301L 3.3-to-5 V converter, a surface mount to DIP adapter, a hex inverter IC, or any resistors/capacitors?

Thank you!

LonniePope (author)2017-02-24

I know this is an old post but I'm sure this is an easy question many could answer for me. The entire circuit described is for the clocking and i2c functionality and interfacing of the cam. Instead of making this circuit I found an adafruit board I believe will do the trick. Could someone help me out and verify this board does the same as the circuit and could be wired up with the camera.

https://www.adafruit.com/products/2045

-Never hunt around for another crystal again, with the Si5351A clock generator breakout from Adafruit! This chip has a precision 25MHz crystal reference and internal PLL and dividers so it can generate just about any frequency, from <8KHz up to 150+ MHz.

The Si5351A clock generator is an I2C controller clock generator. It uses the onboard precision clock to drive multiple PLL's and clock dividers using I2C instructions. By setting up the PLL and dividers you can create precise and arbitrary frequencies. There are three independent outputs, and each one can have a different frequency. Outputs are 3Vpp, either through a breadboard-friendly header or, for RF work, an optional SMA connector.

We put this handy little chip onto it's own breakout board PCB, with a 3.3V LDO regulator so it can be powered from 3-5VDC. We also put level shifting circuitry on the I2C lines so you can use this chip safely with 3V or 5V logic.

cercem (author)2016-10-18

Hi,

great project. I try to attach one more servo for the vertical axis adding new lines in the sketch but the second servo spins continually. I try different pwm pins but still the same result. Can you tell me where and what should add to modify it for the second vertical axis?

Thanks.

AndreaP38 (author)2016-02-01

Hi, I have to use a similar technology for a work. There is the possibility to buy the camera on line (without it is necessary to disassemble the Wiimote).

Thank you

AndreaP38 (author)AndreaP382016-02-03

I'm sorry, I formulated in a wrong way my post. I want to know if there is the possibility to buy the camera on line?

Sorry again

NandoC2 (author)AndreaP382016-02-03

I have found this:
http://www.robotshop.com/en/ir-tracking-camera.htm...

Reading the comments, it seems the Wii IR Camera.

NandoC2 (author)AndreaP382016-02-01

Could you link me where have you bought the ir camera? Thanks in advance :)

chas.sheppard (author)2015-10-03

Hiya, great project!

It's my first time working with arduino, and I was wondering if I could just use the 3.3v output from the arduino to the camera as I only have a 9v supply

nojo127 (author)2015-06-26

Would be usefull for a sentry gun project. :D

thalass (author)nojo1272015-08-06

I was thinking the same thing. With a laser designator!

mathies.gielen (author)2015-02-11

hello

i have a problem. I have build the circuit but the camera gives only an x and y coordinate of 1023.

can anyone help me?

mtarek16 (author)2014-01-20

Why is the inverter needed?

BToby (author)mtarek162015-01-25

I realize this is way after you posted this, but just in case anyone is wondering:

The camera has some onboard processing that requires a clock signal. The inverter, crystal, two capacitors, and resistor are a simple oscillator circuit (called a Pierce Oscillator) that generate that clock signal. There's some decent material online about these circuits, but this application note from TI might be a good start! http://www.ti.com/lit/an/szza043/szza043.pdf

Dittop (author)2014-12-04

Hi, how can I get this 8 pin pixart camera? I bought one wii remote and the camera in that was 12 pin. So can you please help me to get the exact one?

mrdodobrain (author)2014-11-22

Hi, I actually followed your post and I was able to make it. There are things I changed though such as the I2C bus voltage converter shield. LTC4301L is not available in our region so I managed to make a voltage converter using mosfets. I tried using a 25Mhz oscillator, run the program but strangely enough it can control the servo motor but does not output the x, y coordinates. I always get zero values. So, I tried using a 16Mhz oscillator with 4800 baud rate, surprisingly though, everything went smoothly. I can control the servo motor and acquire the right coordinates. But the problem I am experiencing right now is that it only works for a limited time, after only 30 seconds, i can no longer control the servo as well as output the right coordinate. I have to reset it again to make it work. Does it involve running out of memory?

cjameson (author)2014-07-01

I just removed the camera from one of mine WiiMotes to try this.

Unfortunately I mangled some of the copper leads on the camera. they appear to be kinda 'spring locking' pins that were designed to come out [of the camera package] easily. Are these a standard pin that I might be able to buy replacements for? or would pushing solid core wire into their slots work? any other ideas on how i might salvage this?

Eric Jacob (author)cjameson2014-07-06

Sorry, I don't know. I was just really careful with mine and was lucky none of them broke.

aws alnabulsi (author)2012-10-11

Great work!! you've done a great job explaining details...thanks for that :)
i have one question though,,how is the IR camera calibrated?or what is the x,y reference?the origin (0,0) point
Thanks again,
Aws

pavel.s (author)2012-07-27
I bought Wiimote at the MiniInTheBox, disassembled it, but camera inside is different:



Who know something about this? It has the same interface or it's completely different?
pavel.s (author)pavel.s2012-07-27
criticaldefect (author)2012-05-21

You can now buy the camera's pre soldered onto a clock circuit from this place:

http://rocketbrandstudios.com/store/pcb-s-and-boards

He's even got some video and code examples for using it in a followme setup on a bot.

I'm not sure if you would still need to run it through a converter circuit to use it with a 5v board like the arduino but it looks to be running fine interfacing to an arduino nano in the video

Either way it makes for a much neater little package than unsoldering and proto boarding your own :-)

mmalluck (author)2012-01-31

I'm wondering if a 3.3v to 5v logic converter is necessary. Some folks have had luck with disabling the internal pull-up resistors used in wire library and installing their own pull-up resistors to 3.3v source.

http://www.varesano.net/blog/fabio/how-disable-internal-arduino-atmega-pullups-sda-and-scl-i2c-bus

No converter necessary.

evolvingtech (author)2011-12-26

I imagine that the IR camera is a custom made component made only for Nintendo. Does anybody know if there is an equivalent product that can be purchased from an third party company be it Pixart or anyone else?

EvilChip (author)2011-12-11

Hi. You know which is the range of IR that the WiiMote detect?

Eric Jacob (author)EvilChip2011-12-11

I think that the IR LED's that I was using were in the 940-950 nm range. I imagine that the camera is sensitive to a range around that.

Gonazar (author)2010-05-20

OK, so i'm new to the use of inverting logic gates and i don't understand the schematic. After reading wikipedia i see that the logic gate has 6 inverters in it. Does it matter which you two you use? And as far as i can tell from the photos, your using using the VDD (pin1) and NC (pin16) but what are they connected to?

Also, would you be able to make a list of recommended digikey parts for the standard parts? I'm not quite familiar with the logic gates and don't know which to pick. I'm also not sure about the crystal either.

Eric Jacob (author)Gonazar2010-05-31

 It has been a while since I made this, so I had to scratch my brain.

I used the 74AC04 inverter chip. Pin 1 is not Vcc. It is weird like that. here is the data sheet:
www.datasheetcatalog.org/datasheet/nationalsemiconductor/DS009913.PDF

Pin 7 is ground and Pin 14 is Vcc. The gates are all the same, use any two.

As far as digikey is concerned. You'll probably want a 14 pin DIP package. We are running the chip at 3.3V, so we need to check that it'll work with that, but it looks like they all do. Otherwise, you'll want to buy something that has a minimum quantity of 1 and is available. I see 4 options with that, they are all good, buy the cheapest. Get a few (they are cheap) in case you blow one out.

The crystal is easy too. Filter with 'through hole' and 25 Mhz. After that you'll get a bunch. I forget which one I got, but they are pretty much all the same. We are not too concerned with the stability and tolerance. Sometimes I like to get a few different ones in case. It is cheaper to buy a few than to ship stuff again.

The caps can be annoying to buy because there are a million of them. Again, get a through hole with the right capacitance. We are not dealing with high voltage, so they will all work. Just find the cheapest then. Maybe get a few different ones if you are not sure. That is what I do.

Just get the cheapest 1/4 watt 1.0 Mohm resistor. 


questionman (author)Eric Jacob2011-10-05

Hi there. Is 74LS04 ok with this circuit? Thanks buddy. :)

Eric Jacob (author)questionman2011-10-05

I am not sure. A quick look at the 74LS04 datasheet shows that it runs at a minimum of 4.75 volts, but the logic will run at 3.4V so I have no idea. I would wire up the clock part and make sure it is working correctly before connecting it to the Wii IR Camera.

questionman (author)2011-10-04

Hi there. That is a very interesting project you have. I am wondering if instead of using that voltage converter shield, can we use this instead:
http://www.sparkfun.com/products/8745
It has the same purpose though, which is to convert voltages.
Forgive my knowledge about this, since I am just a beginner as a hobbyist.
Thanks a lot buddy! :)

Eric Jacob (author)questionman2011-10-04

Yeah, I have looked at that too. I don't know for sure if it will work, but it says that it can do i2c conversion, so it seems like it will do. If it does it would be cheaper and easier to work with. Thanks for the comment!

questionman (author)Eric Jacob2011-10-05

Hi. Sorry for this newbie question but, is the theory behind the circuit of
http://www.sparkfun.com/products/8745
same as this?
http://i52.tinypic.com/2niprtz.png
I am trying to work your on your project and I followed all the circuits,
except for the voltage converter shield. It seems that the i2c scanner:
http://todbot.com/blog/2009/11/29/i2cscanner-pde-arduino-as-i2c-bus-scanner/
cannot detect the i2c device, which is the pixart camera.
I would really appreciate if you can help me on this. Thanks again. :)

bskaloud (author)2011-08-26

Hi, I am having problems getting this circuit to work. I've tried replacing all the components, different wii IR cameras, and still I get a continuous output of all blobs with a size of 0. I lowered the pull-up resistance on the SDA-in and SCL-in to 1.5k ohms, and this worked for a bit, but then after a few days it stopped working again. I've also tried soldering all the components instead of using a breadboard, but this had no effect. Do you know what the problem might be? This is driving me nuts. My next step is to vary the pull-up resistor values and see if something works. Thanks for your time.

Eric Jacob (author)bskaloud2011-08-29

It is hard for me to say without working with your setup. I did burn out a camera at one point by accidentally cranking up the voltage on it. I have had no problems on a breadboard. If you have access to an oscilloscope, check the output pins to see if you are getting any action. This may help you isolate the problem. I am going to be working with this again soon. If I come across anything I will let you know.

bskaloud (author)Eric Jacob2011-08-29

Thanks for the reply. Turns out it was a grounding issue. I was only connecting pin 2 of the camera to ground, and when I connected pin 3 also, it worked. I don't quite understand it because the pins are connected internally... Also, one of the cameras I was trying to use was burnt out, so that just added to the frustration.

ameenyousuf (author)2010-11-24

nice work. I was wondering whether similar circuitry could be used to detect finger movements? I am working on an optical projection keyboard project and was planning to use the Wiimote IR sensor for the purpose of detecting finger movements when a user hits a key. I think what you have made could be applied to some extent to my project also?Is that possible? Thanks

pspittle (author)ameenyousuf2011-05-18

You may find it a lot easier if you were to do something like what is in this video for your project. Doesn't require such lengthy amounts of work, and you can keep the wiimote in one piece

Beenay25 (author)2011-04-16

Brilliant instructable.

Do you know how to change the pins that the camera uses on the arduino? I think it defaults to 6 and 5, but I'd like to change these and can't figure out where they are set...

Eric Jacob (author)Beenay252011-04-17

I don't know offhand, but I would assume that it is defined in the Pvision.h library. I haven't had to change it myself.

marcwolf (author)2011-04-02

Very interesting project and also thanks - I have been curious about the 'speed' of processing.
I do animatronics as a hobby and one of the 'holy grails' is real time Lip Syncing where the mask will move it's lips in time with yours.

If one thinks of the lips as a flexible circle with points every 90 degree's then it's easy to put reflective points on the lips at that location/ Then it's easy to work out how open, cloded, or wide the mouth is and du0plicate it on the puppet.

Using an industrual face mask (for dusting) you can make a fully self contain system complete with camera and IR 'spotlight' that will protect the eyes and provice a dark environment.

Take Care

Marcwolf

razstec (author)2010-10-24

Anyone can help with building a smaller controler so i can attach it laptop screen side and use a pen as a mouse?

the wiimote its just too big, any sugestion?
A way to power it by usb would came in handy too.
thanks

jamwaffles (author)2010-09-22

Does anyone know where you can buy the camera on it's own?

Also, thanks for the cool instructible - that servo is incredibly responsive!

Eric Jacob (author)jamwaffles2010-09-23

Thanks, glad to help. The servo is very responsive. It is fun to just sit and watch it move.

I do not know where to find the camera on it's own. As far as I know this is the company that makes it,

http://www.pixart.com.tw/about.asp

If you find them I'd really like to know where you can get them alone.

Lance Mt. (author)2010-04-17

 Could you mount to the servo and cut movement back to a 1:1 movement ratio?

Eric Jacob (author)Lance Mt.2010-05-31

 Absolutely. I've been playing with this method. It works better for tracking. You can also use two servos and track with both the X and Y axes.

Lance Mt. (author)Eric Jacob2010-06-06

Miniature Mech Fighting toys, here we come.

thalass (author)2009-11-24

This is great. I wonder if you could use it to track the sun? There are cheaper and simpler ways to do that, I suppose, but the wiimote ir camera mounted in the middle of a group of solar panels, or a reflector dish for solar thermal, with the arduino programmed to return the array to a pre-determined position when an ambient light sensor determines it's dark outside (or the solar panel output goes below a threshold, or an internal clock determines it is close to sunset, or a combination). You could even alter the morning position based on the date, so the panels are in the right spot in the morning.

Very flexible, I like.

Eric Jacob (author)thalass2009-11-24

Yes, that would absolutely work. It would really be powerful in a moving platform where you might need some more dynamic sun tracking.

You can take this idea further. If I know the time of day and my position on the earth (longitude, latitude and possibly altitude as well) then I know where the sun should be. Then, by using a IR camera (or several of of them), you can measure where the sun is. Then, working backwards, I know (within some error) what the angular orientation of the cameras and therefore the orientation of the robot, airplane, etc as well.

This gives you a fixed orientation measurement that doesn't require integration as apposed to inertial navigation systems which builds up error over time.

Of course that would only work during the day. I wonder what IR signal the moon has?

thalass (author)Eric Jacob2009-11-24

I don't think the moon has much of an IR signal. Not enough for the wiimote camera, probably. It'd be easy to test, though. With cwiid or another wiimote program for pc. Point it at the sky and see what the output looks like.

For orientation, that method would work great, except at around midday. Especially if your vehicle is on a tilt. That can be compensated for, though. But then again you can get hall effect compass systems for fairly cheap nowdays, which also have no accumulative errors or anything.

Now if your vehicle was on a body without any magnetic field, like the moon or something, then that would work very well. Especially if you could use the earth as a second reference point for when the sun is directly overhead.

thalass (author)thalass2009-12-04

I just tried this out, with wmgui on my laptop. The sun is much too bright for the wiimote to register it! Even with two polerised sunglasses lenses at various angles (crossed at 90 degrees you can't see through them, though the sun still shines through) I got no output - though reflections of the sun on various things produced a myriad of points the wiimote will track.

I also tried the moon the other night, being a full moon, and I think that it wasn't bright enough either. Though I didn't try putting my sunglasses in front of the lense to test that out.