0%
0%

# ESP8266 meets Wii_Mote Camera

The Wii mote camera can track 4 Infra Red point sources, this project show how the information can be used to calculate joint angles.

Similar projects worth following
2.8k views
Its basically a Nintendo WiiMote camera which is able to track 4 infra red leds/laser giving XY coordinates and also the size of the blob seen.

The WiiMote camera is kinda an i2c device however its a little dum as you have to kickstart it with a separate 25mhz clock. (deadbug style coz its easier to solder)

In this current application I am sending the received Blobs via a parsed SVG packet to the w3.org web site....which inturn sends me back a neat SVG graphic which is displayed to my phone via webpage.

The video shows how the Wii mote can pick up three Infra Red Leds (it can pick up 4) .

The X,Y positions of the 3 IR leds can be used to calculate the resulting angle made by them.

This is the meaty part of the code :-

result = ircam.read(); // call the Wii mote camera for some data
p1x=ircam.Blob1.X;
p1y=ircam.Blob1.Y;
p2x=ircam.Blob2.X;
p2y=ircam.Blob2.Y;
p3x=ircam.Blob3.X;
p3y=ircam.Blob3.Y;
angle=atan2(p2y - p1y, p2x - p1x) - atan2(p3y - p1y, p3x - p1x); // simple calculation reveals the angle

This calculates the angle in radians which can be converted to degrees by multiplying by 57.2958

What is show here is a mini version, however the Wii camera is not shy to bigger constructions and stepping way back into the room for bigger ideas.

The idea is to place 4 IR leds onto a robots shoulder ,elbow, wrist and finger and use it for remote motion capture, as it uses the ESP8266 then this data can be relay over WifI to a processing network.

• ### SVG Code

Here is a snippet of code out-laying the SVG Wrapper which is sent to w3.org

```String out = "";
char temp[200];
out += "\n";
out += "<g >\n";               // Start our data string

sprintf(temp, "<circle cx=\"%d\" cy=\"%d\" r=\"%d\" stroke=\"black\" />\n" ,ircam.Blob1.X,ircam.Blob1.Y,ircam.Blob1.Size*5); out +=temp;
sprintf(temp, "<circle cx=\"%d\" cy=\"%d\" r=\"%d\" stroke=\"red\"   />\n"  ,ircam.Blob2.X,ircam.Blob2.Y,ircam.Blob2.Size*5); out +=temp;
sprintf(temp, "<circle cx=\"%d\" cy=\"%d\" r=\"%d\" stroke=\"green\" />\n",ircam.Blob3.X,ircam.Blob3.Y,ircam.Blob3.Size*5); out +=temp;
sprintf(temp, "<circle cx=\"%d\" cy=\"%d\" r=\"%d\" stroke=\"blue\"  />\n" ,ircam.Blob4.X,ircam.Blob4.Y,ircam.Blob4.Size*5); out +=temp;
out += "</g>\n</svg>\n";                   // close the SVG wrapper
server.send ( 200, "image/svg+xml", out);  // and send it to http://www.w3.org/2000/svg\
delay(100); //If you have a Sizable graphic then allow time for the response from w3.org before polling the site again (else things will break)```

• ### Scalable Vector Graphics (SVG)

The Data from the Wiimote camera is parsed into a SVG request and the esp8266 sends this over its Wifi link to the w3.org website, w3.org sends back a nicely wrapped SVG graphic which echos to anything you have listening into the ESP8266 IP

Share

## Discussions

Maksim Surguy wrote 03/25/2016 at 18:00 point

I see. Perhaps this roundtrip could be avoided by using WebSockets to maintain direct connection with your client (phone) and rendering a page in the browser (and updating via Javascript using the data from the websockets)? That way you would have your data update within 2-10 ms, practically real time

Are you sure? yes | no

Maksim Surguy wrote 03/25/2016 at 17:24 point

Hi! Very cool project!

I have a silly question, but what is the purpose of sending data to W3.org

Are you sure? yes | no

chiprobot wrote 03/25/2016 at 17:50 point

Basically if you send the ScalableVectorGraphic "Data" to W3.org it creates and sends back a graphic of your data. It a simple way of creating a pseudo screen for the esp. However this method is memory hungry.

Are you sure? yes | no

# Does this project spark your interest?

Become a member to follow this project and never miss any updates