ESP8266 Peripherals: Indoor Positioning with IR Camera

The sensor I’m going to talk about here is a very powerful one. And you actually might have a very similar one in your home somewhere. The DF Robot Positioning IR Camera uses the same or similar module that is built into the Nintendo Wiimote controller. The sensor module is capable of simultaneously detect up to four sources of IR light and make them accessible through a I2C interface.

DF Robot IR Camera Sensor

DF Robot IR Camera Sensor



  • Operating voltage: 3.3-5v
  • Interface: I2C
  • Detecting distance: 0~3m
  • Horizontal detecting angle: 33 degrees
  • Vertical detecting angle: 23 degrees
  • Dimensions: 32mm x 16mm(1.26×0.63″)
  • Resolution is 128×96 pixel, with 8 sub pixels, so 1024×768
  • track four objects (IR emitting or reflecting objects)
  • Cost: USD ~$23.55


How does it work? 

The chip in the sensor module does all the hard work for you: filtering the noise and figuring out the strongest sources of light that passed through the IR filter in front of the camera. It will send then 4 pairs of x and y coordinates through the I2C interface to your ESP8266 (or any other MCU). If no IR source was detected the pair will just return the maximal value for 2^10 = 1023. If a source has been detected it will return the coordinates with a resolution of 1024×768 pixels to you.


How to wire it to the ESP8266? How to program?

Just connect the RED pin to 3.3V, the BLACK to GND and the GREEN (e.g. D6) and YELLOW (e.g. D5) to a free GPIO pin. Then use the following script, adapt the GPIO pins if necessary and upload the script to your ESP8266:

How to visualize the results?

Related:  WeatherStation & 3D Printing: striving for seamless integration

I used Processing to visualize the data points the ESP8266 returns over  the serial line. Here is the Processing script:


Then I used an IR bar I still had from my Nintendo Wii and waved it in front of the camera.

Wireless IR Bar from my Wii

Wireless IR Bar from my Wii

And here is the result:


What can you use the sensor for?

I bought it because I plan to help my robot navigate indoor with the help of the IR Camera. I’m not yet sure if then the camera should be on the robot and the IR sources all over the room or if several cameras should track the IR sources on the Robot and send its coordinates to the robot.

You could also build a whiteboard or a head tracker. Just search for Wiimote hack on Google and you’ll get plenty of ideas what you can do with the sensor!

Where to buy?


Where can I get more resources?

Now a beer! Did you like this post? It often takes me several hours of my free time to write one. If I was your neighbour would you offer me a beer for the hard work I did for you? The beauty is: beers can be teletransported with a painless donation using Paypal. A beer in a Swiss bar costs about USD $4.80. Or use this affiliate link if you order something on Banggood and I'll get a small kickback. Thank you!