StatCounter

Sunday, October 16, 2011

Connecting the MRF24WB0MA to the Arduino

Power to the masses.



With the recent availability of cheap WiFi modules like Microchip's MRF24WB0MA, I find it quite difficult to NOT use them in some way or another, given their essentially limitless potential in remote sensing/control applications.

The word "remote" here retains its full meaning; you can basically turn on that lamp in your room from the other side of the planet, - or anywhere in the world for that matter - provided that you can get access to that thing we call the internet.



In this post, I will show you how to use the MRF24WB0MA on the Arduino platform.

Things you will need:

- MRF24WB0MA WiFi Module. (Available from Farnell here)
- 4x 4.7k Ohm Resistors
- 2x 1.0uF Capacitors.
- Some way of connecting these together. I used a perfboard and some wires.

[Also, check out Farnell's Arduino page for some interesting Arduino-related products. These guys are cool.]

The schematics described below are based on the WiShield 1.0 Arduino shield from AsyncLabs.

First you will have to connect the module as described below to the Arduino shield. The resistors are all 4.7k and the two caps are 1.0uF each.



Remember: Power is at 3.3v. 

The resulting circuit should be something similar to this:



Then you'll just hook this up to your Arduino. Your setup may look similar to this:



The task of connecting the WiFi module to the Arduino is way simpler than the above pictures might suggest. It's really only about connecting the SPI interface (5 wires) and Power + Reset (3 wires).

The hardware setup described is basically equivalent to an Arduino board with a WiShield 1.0 stacked on it.

Therefore, as you might have guessed, things get easier from now on - it's all software.

On your computer:


  1. Download the WiShield library here. [now mirrored on my github]
  2. Put all the files/directories under /libraries/WiShield/ directory.
  3. Restart the Arduino environment, so that the library files get built and the sketches become available.

Done. At this stage you are ready to experiment with the examples included in the WiShield libraries. 

I'll suggest you to start with the "WiShield>Webserver" example. 

This is a screencap of the page you should get when you type in the IP address of the module in your browser:




You'll have to hardcode the IP settings in the Arduino Sketch. The module does NOT support DHCP for automatic IP assignment in the examples. This implies that if you are using infrastructure mode, you will need to set your router to reserve the IP address you set in the Arduino Sketch. 

If you are using adhoc mode, things get simpler. Just make sure you set your computer up for static IP addressing. To use adhoc mode: In the sketch, change the line containing 

unsigned char wireless_mode = WIRELESS_MODE_INFRA;

to 

unsigned char wireless_mode = WIRELESS_MODE_ADHOC;

I noticed that if you use WPA2 authentication, the module will take about 30seconds to authenticate. No need to panic if the LED (shown on the schematic) does not light up right away. 

Also, make sure that you set up the security type properly:



unsigned char security_type = 0; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2



After you've managed to correctly run the examples included in the libraries, check out AsyncLabs' forums for a variety of more interesting, real-life applications. 


17 comments:

Natalia said...

Thanks for this detailed tutorial. I wasn't quite ready to shell out $75 for the DiamonBack when I already have at least 7 different Arduinos lying around. I'd be buying it just for the WiFi functionality, so $24 sounds like a much better deal! I wasn't aware I could get this module alone. Yay! [doing happy dance]

fatmi said...

Nice project, and very clear insrtuctions about Arduino .

Billy said...

Cool, thanks for the info, going to get one. Been looking at the TWINE project and see they are using this module.
Billy
electronicramblings.com

Pedantite said...

This is fantastic, I really wish I'd seen this months ago, I would have saved me a lot of time. I think I've been doing things the hard way:

http://bytecruft.blogspot.com/2012/03/mrf24wb0ma-wifi-board-update.html

Anonymous said...

I think there is a bug in WiShield driver. In file g2100.h there a three registers are defined 0x2F, 0x33 and 0x35. But in library files from Micorchip (MFDriverPrv.h) register 0x33 and 0x35 (in g2100.h) are defined there as 0x31 and 0x33. So I'm surprised that this driver works correctly.

Danny said...

Hi, how did you solder the module to the perfboard?

Manishi Barosee said...

I soldered with a 15w 0.1mm tip soldering iron. I used 1/4w resistor's legs for the wiring from the pcb to the module.

I must agree that this is not quite beginner friendly.

Magic Byte said...

Hello.
I have been trying to do same thing and but not getting results. Can u please me the full code at jayesh.ruchandani@gmail.com.

Also, will this webserver example work if i dont have an internet connection?

Paulo Torrens said...

Man, you just saved my life. This will help me *a lot*! Thank you! =D

CgmFactory said...

Hey guys,

I use this module for a webserver on a 2560 arduino. Everything runs now with javascript / jquery and so on !!
There are modifications to do in the drivers to handle the interupt on the 2560.
Is there any interest for you?

Gerard M

Jason Tay said...

Nowadays, you could just buy the Olimex UEXT MOD-WIFI module, which has this very WiFi module ready soldered to an easy to deploy mini-module that you can connect to whatever project you've got using a bog standard IDCC header. I did.

Anonymous said...

Hello.
Can You post here modifications for
ARDUINO MEGA 2560 please? It will be
very helpfull for me.

"Manis B" said...

For the Arduino Mega 2560, the pins should be remapped as the SPI bus is connected differently.

(UNO pins) -> (Mega pins)
Pin 13 -> Pin 52
Pin 12 -> Pin 50
Pin 11 -> Pin 51
Pin 10 -> Pin 53

Anonymous said...

what are the interfacing commands for this modile

Anonymous said...

Hi,

recent microchip Wifi modules are not compatible anymore with wishield library. Do you have an update?

Anonymous said...

I just bought the MRFWG0MA with the daughter board and connected the pins to an arduino mini pro but I can't ge thte WebServer example to work. Do you have any advice on how to debug this?

Anonymous said...

To get started with the MRF24WB0MA can i use the "WiFi.h" from the Arduino SDK / IDE?

I want to use some code i wrote for the Ethernet shield, (but want to use wireless instead) and just want to add the extra code needed for connecting via WEP or WPA.