Pages: [1] 2   Go Down
Author Topic: Ardwiino: bluetooth + accelerometer for 40 USD  (Read 4038 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there!  This is my first post to the Arduino forums; I wanted to share my elation in (finally!) succeeding at my first Arduino project.  And, since the Arduino BT board costs 70-100 USD more than the Arduino NG, I thought others might also be interested in this as a cost-saving measure.  smiley

In case you've been out of touch with the gaming industry lately: Nintendo's new game system, the "Wii", comes with a distinctive controller called the "Wii Remote" (or "wiimote").  It runs on two AA batteries, communicates over bluetooth, and sports 12 buttons, a 3-axis accelerometer, a tiny speaker, and an IR camera.  But most important of all, it has an "expansion port" where you can plug in other controllers (most famously the "nunchuk").  Hackers all over the world have been reverse engineering the Wiimote, and now there is an expansive set of of scripts and libraries for all operating systems whichi allow your computer to communicate with it.  Here is one of several comprehensive wiki pages on the Wiimote and its communications.

And now, you can (quite simply) use the wiimote to facilitate wireless communications from your Arduino to your PC!  You can also use the accelerometer data or play sounds over the speaker, and progress is being made on decoding the data from the infrared camera.  The protocol over the expansion port is 400kHz ("fast") I2C, with the peripheral at address 0x52.  You write 8-byte packets and they are sent over the bluetooth to the PC.

(If you're inspired by this post and want to run out and by a wiimote from $39.48 or a bluetooth dongle from $2.95, I'll hope you'll consider using these Amazon referral links.)

The connector on the base of the wiimote is a proprietary Nintendo concoction, but has only 6 pins and should be fairly easy to mate with.  (I'm currently using a scavenged Nunchuk.)  One you have broken out the six pins, as numbered here, simply attach Pin 1 to your Arduino's AREF, pin 2 to  Analog In 5, pin 5 to Analog In 4, and pin 6 (or the outside of the connector) to Arduino's GND.   (You can even set the power jumper to EXT and, after programming, disconnect the USB cable and power the Arduino from the wiimote.)

I'm not sure if this part is necessary, but you should also find the file lib/targets/libraries/Wire/utility/twi.o under your Arduino tree, and delete it.  Then make two changes to twi.c (in the same directory) before rebuilding: first, find the line "#define ATMEGA8" and make sure it's uncommented (i.e. no "//" in front); second, change the line defining TWI_FREQ to set it to 400000L.

Now, you can write a simple program like this:
Code:
#include <Wire.h>  

uint8_t outbuf[] = {0xf2, 0x79, 0x2e, 0x7d,
                0x4d, 0x43, 0x01, 0xfd}; // sample data set


void receiveEvent(int howMany) {
  while(Wire.available()) {
    char c = Wire.receive(); // receive byte as a character
  
  }
}
void requestEvent() {
  Wire.send(outbuf, 8);  // send data packet
}

void setup() {
  Wire.begin(0x52);                    // join i2c bus with address 0x52
  Wire.onReceive(receiveEvent); // register event
  Wire.onRequest(requestEvent); // register event
}
 
void loop() {
  delay(100);
}


There are lots of ways to get this data on your pc, for simple python scripts see this wiki page.

Happy Ardwiinoing!
« Last Edit: February 25, 2007, 10:34:47 pm by abliss » Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
since the Arduino BT board costs about 100 USD more than the Arduino NG..
hi

nice hack!

One thing though, I think you have your prices wrong... BT is not stocked in North America yet, but compare these Bluetooth options:

Arduino NG $32 + wiiimote hack $39 = $71USD + time hacking+ wiring

Arduino NG $32USD + BlueSmirf $60USD (both from Sparkfun) = 92USD + wiring + circuit board time

Arduino BT  $103 USD = 77 Euro from PCB Europe. = integrated code and hardware + ready to go.  smiley


D

« Last Edit: February 25, 2007, 10:40:37 pm by Daniel » Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops... I stand corrected.

Sparkfun just posted the price for the BT modules : $139 USD

Yikes.

D
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ouch, wonder why such a large markup over pcbeurope?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

> Ouch, wonder why such a large markup over pcbeurope?

Don't complain. Usually it's the other way round, we Yurpeens usually have to pay twice as much for our imported gadgets as you do.  smiley-razz
I guess the price will go down once they sold their first lot.
Logged

Forum Administrator
Offline Offline
Newbie
*****
Karma: 3
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess it's to avoid competing with other products they sell...
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote

Arduino BT  $103 USD = 77 Euro from PCB Europe. = integrated code and hardware + ready to go.  smiley


If it arrives on time. I paid 3 days ago to pcb-europe for one board, 15euros for the shipping from italy to switzerland, just around the corner. I havent got any confirmation apart from paypals payment, i have tried to contact them pcb-europe asking for my tracking number and i have had no clear response in 2 days.. they got my order is the onyl thing they say...waoo great, internet works! but...

not sure if they are selling things they dont have in stock, i hope to get the board soon, but im a bit dissapointed when you pay fast postal service and the thing just gets delayed by a reason no one tells you.

Im posting this as a heads up for pcb-europe and advice that when you have a project near a deadline ask them in advance if they can really ship the product... remember is winter and "i've been in the door waiting for the postman" smiley

where is my BT arduino?

/a

im sorry if i hijacked a bit the topic of this thread i just needed to let out some of the unrest smiley
actually getting back to the topic, i will like to check out the wiimote against the arduino BT.
« Last Edit: March 08, 2007, 06:08:02 am by armadillo » Logged

Forum Administrator
Offline Offline
Newbie
*****
Karma: 3
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello

Usually pcb-europe is pretty reliable

if you paid only 15EUR from italy to switzerland it means you must have chosen the shipping through the postal service... that's usually more unreliable than the couriers.. (who are also quite unreliable sometimes)

The BT boards are in stock and they are being shipped allover the world.. (daniel got 35... and I'm getting 10 tomorrow...)

smartprojects is run by 2 people... and they are ok with making very little money to let people have arduino for as cheap as possible...

i'm sure parallax that charges $79.00 for a largely obsolete BS2P has a much faster reply time on emails

massimo





Logged

Netherlands
Offline Offline
Sr. Member
****
Karma: 0
Posts: 414
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For me, it turned out that ordering from Sparkfun is much cheaper. I am in The Netherlands and shipping from SFE in the USA to me was much cheaper than shipping from PCB-Europe (Italy?) to me. Shipping took 5 days...
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 81
everywhen
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The BT boards are in stock and they are being shipped allover the world.. (daniel got 35... and I'm getting 10 tomorrow...)

Wow, where do you guys get the funding for so many?!? I wish I could afford to have that many "projects", but money and time both keep me working on what's in front of me.

The wii mod is nice, but does require some assembly. It would be great to see the arduino bt come down in price. I'm sure by now the development costs have been made back (and then some); I could be wrong. I guess having them assembled costs a bit.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

They are obviously teaching at universities or similar institutions and order them for their students and classes. I doubt anyone orders 35 Arduinos for themselves.
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

exactly right.. the University I work at was kind enough to order them for  a class on embodied computing!

D
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 81
everywhen
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I figured such. Sounds like a nice class, arduino is a great learning platform, I find it much more straightforward than doing assembler, plus it has all the mcu's support hardware built in.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

when I use the code posted here, I don't get any requestEvents. Is that something that I just initiate in whatever software I use to communicate with the wiimote? Or should the wiimote be polling connected devices automatically for info?

I do receive a 64,0 message when powering the Wii Remote on.
Logged

http://www.charlie-roberts.com/midiStroke
Free software for MIDI control in OS X.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bigbadotis, that's correct.  After the first handshake packet, the wiimote won't request any more data until it has something to do with it.  So pair up your wiimote to your PC with the appropriate driver (or to your Wii!) and it'll start requesting stuff.

Bear phillips, over at wiire.org, has figured out how to use the wiimote as a two-way bluetooth communications channel.  He's also managed to read the nunchuk ($20 for an accelerometer, analog joystick, and two buttons) data into an arduino.
Logged

Pages: [1] 2   Go Up
Jump to: