venerdì 28 dicembre 2012

How to interface Arduino Mega 2560 to Weburban WiFi board

First you need an Arduino Mega 2560 board ( and a Weburban WiFi board ( This board uses standard connectors over SPI to an Arduino compatible Microchip 802.11b/g/n MRF24WB0MA.
In this example I use ArduinoIDE version 0021.

                                                          Arduino Mega 2560

                                                          Weburban WiFi board

                                                       Weburban WiFi board pin mapping

The WiFi board uses the WiShield library, available at

How to connect Arduino to WiFi board:

Just follow this schema:

WiFi (pin)       Function        Arduino (pin)

1                GND             Power GND (left side, power supply connector)
2                +3.3V           +3.3V (left side, power supply connector)
3                Reset           Reset(left side, power supply connector)
4                CLOCK (SPI)     52 (lower side)
5                MISO (SPI)      50 (lower side)
6                MOSI (SPI)      51 (lower side)
7                CS (SPI)        53 (lower side)
8                Interrupt       2 (digital pin 0)

Then you need to modify the apps-conf.h file to include the header file for the application(s) you use in your project. For example, if you want to use "wiserver" in your sketch, you must modify the file like this:

//#define APP_SOCKAPP
//#define APP_UDPAPP

Finally, to make the WiShield work on Arduino Mega 2560 make the following changes to spi.h file (see at

#define SPI0_SS_BIT      BIT0            
#define SPI0_SCLK_BIT    BIT1
#define SPI0_MOSI_BIT    BIT2
#define SPI0_MISO_BIT    BIT3

#define SPI0_Init()      PRR0 = 0x00;\
                         DDRB  |= SPI0_SS_BIT|SPI0_SCLK_BIT|SPI0_MOSI_BIT|LEDConn_BIT;\
                         DDRB  &= ~SPI0_MISO_BIT;\
                         PORTB = SPI0_SS_BIT;\
                         SPCR  = 0x50;\
                         SPSR  = 0x01

#define ZG2100_CS_BIT    BIT0

#define LEDConn_BIT      BIT5

Here is the complete modified spi.h file:

Here you can find some examples from Asynclabs:

ATTENTION:  Arduino IDE new versions need some  modifications in the WiShield library.

                          For Arduino IDE version 1.0.3 I'm using this one: