With-Zigbee-MRF24J40MA+

From Pinguino-Wiki
Jump to: navigation, search

This extension board has been designed for PIC32-PINGUINO and PIC32-PINGUINO-OTG. It uses a MRF24J40MA Microchip zigbee module and is connected on the UEXT connector.

ZigbeeUEXT.png

The board uses a female HE10 connector. The PCB, drawn with Kicad is shown below.

Zigbee shield.png

Software

The Zigbee library for Pinguino32 uses most of the code from Ian Harris ( www.embeddedadventures.com ). Each module need to be defined with a PAN ID ( personal area network identification ) and an address. To be able to communicate together, the modules need to be part of the same PAN and have a different address. The radio channel must be defined first.

This is an example where the module acts as a Zigbee receiver:

// test zigbee receive
// Jean-Pierre Mandon 2011
// reception
 
#define channel 20			        // channel must be selected between 11 and 26
#define PAN_ID 0xFEAA				// personal area network number ( between 0 and 65535 )
#define Short_Address 0x0002		        // Address of the module ( between 0 and 65535 )
 
unsigned char rxdata[128];			// 128 is the max length
 
void setup()
{
Serial.begin(9600);
ZIG.init(channel,PAN_ID,Short_Address);
}
 
void loop()
{
unsigned char length;
 
length=ZIG.read(rxdata);
if (length>0)
		{
		Serial.printf("Source PAN ID:%04X\n\r",ZIGsrcpan);
		Serial.printf("Destination PAN ID:%04X\n\r",ZIGdestpan);
		Serial.printf("Source address:%04X\n\r",ZIGsrcadd);
		Serial.printf("Destination address:%04X\n\r",ZIGdestadd);
		Serial.printf(rxdata);
		Serial.printf("\n\r");
		}
}

In the following example, the Zigbee module acts as a transmitter:

// test zigbee receive
// Jean-Pierre Mandon 2011
// Tranmission
 
#define channel 20					// channel must be selected between 11 and 26
 
#define PAN_ID 0xFEAA				        // personal area network number ( between 0 and 65535 )
#define Short_Address 0x0001		                // Address of the module ( between 0 and 65535 )
 
#define Dest_Address 0x0002			        // address of a module you want to communicate with
 
void setup()
{
ZIG.init(channel,PAN_ID,Short_Address);
}
 
void loop()
{
ZIG.send(Dest_Address,"TOTO",4);
delay(1000);
}


Links

Zigbee Shield Kicad file
Zigbee Shield Inkscape file

Personal tools