You are on page 1of 18

1

ZigBee PRO Wireless Light-Switch


Aim: To demonstrate the application zigbee-pro light switch.
Hardware: Jennic wireless kit
Software: JN5148 Software Developers Kit with eclipse.
Theory:
Overview:
Three sensor boards from the JN5148-EK010 evaluation kit are used in this application. One sensor board is
used to start the network, the second sensor board acts as the switch and the third sensor board acts as the light.
After the network has started, End Device binding is used to link together the switch and the light. Pressing a
button on the sensor board programmed as the switch then causes an LED to toggle on and off, on the board
programmed as the light.
Network Architecture:
This demonstration application features examples of all three ZigBee PRO device types:
A Coordinator, which starts the network and then binds together endpoints residing on other devices on
the basis of the clusters they possess (this is known both as indirect binding or End Device binding).
In a real application, the Coordinator would be mains-powered.
A Router, which runs the light application. In a real application, the Router would be mains-powered.
An End Device, which runs the switch application. In a real application, the End Device would be
battery-powered.
The possible network topologies are shown below in Figure 1 and Figure 2. The End Device (switch) can join
either the Coordinator or the Router (light). The topology can be forced by enabling joining (pressing button
SW1) on either the Coordinator or Router (light).

Figure 1: Topology with All Devices Joining the Co-ordinator


2


Figure 2: Topology with End Device (Switch) Joining the Router (Light)
Co-ordinator Board:
On the board that is programmed as the Co-ordinator, the software performs the following actions:
Starts the device as a ZigBee PRO Co-ordinator, using channel 17
Illuminates LED D1 when the device is first powered up, and extinguishes it once the network has been
successfully started (this should occur very quickly)
Allows the user to enable network joining for 5-second intervals by pressing button SW1

All of the functions associated with acting as a ZigBee PRO Co-ordinator (such as allowing other devices to
join the network, allocating addresses to those devices and binding endpoints on other nodes) are performed
automatically by the ZigBee PRO stack and are completely transparent to the user. This allows the users
application code to be made as simple as possible.
Light Board:
On the board that is programmed as the light, and which functions as a ZigBee Router, the software performs
the following functions:
Searches for a network and requests to join it when button SW1 is pressed
Sends a request to the Co-ordinator for binding when SW1 is pressed after joining
Once bound, it switches LED D2 on or off when the appropriate command is received from the switch
node
Allows the user to enable network joining for 5-second intervals by pressing button SW1
Switch Board:
On the board that is programmed as the switch, and which functions as a ZigBee End Device, the software
performs the following functions:
After button SW1 is pressed, searches for a network and requests to join it. The switch can join either
the Router (light) or the Co-ordinator, depending on the device on which you have enabled joining by
pressing SW1
Sends a request to the Co-ordinator for binding when button SW2 is pressed
Once bound, it sends Toggle commands to the light node each time button SW2 is pressed
Since the switch is an End Device, all data originating from the switch must always go through its
parent
3

Binding:
The application uses End Device binding to link the light and the switch together via the Coordinator. This
involves pressing button SW2 on both the light node and switch node within five seconds of each other, in
order to send binding requests to the Co-ordinator.
When the ZigBee PRO stack on the Co-ordinator receives the two binding requests, it attempts to match them
together. If successful, the binding tables will be updated on both the switch and light nodes.
Matching is done between endpoints with identical input and output clusters.
If two more requests are then received by the Co-ordinator for the same two endpoints, the entry is removed
from the binding table.
Once a pair of endpoints is bound, data may be sent from either node without a destination address.
Working Instructions:
1. Power on the Co-ordinator.
LED D1 will illuminate and extinguish, once the network has been successfully started (this should occur very
quickly).
2. Power on the switch node.
LED D1 will start flashing.
3. Press button SW1 on the Co-ordinator to allow joining (depending on the desired topology see Figure 1
and Figure 2).
4. Press button SW1 on the switch node to allow it to join the network.
LED D1 will illuminate while the node is joining and will extinguish once it has joined the network. LED D2
will start flashing. If LED D1 starts flashing again, repeat from Step 3.
5. Power on the light node.
LED D1 will start flashing.
6. Press button SW1 on the Co-ordinator to allow joining.
7. Press button SW1 on the light node to allow it to join the network.
LED D1 will illuminate while the node is joining and will extinguish once it has joined the network. LED D2
will start flashing. If LED D1 starts flashing again, repeat from Step 6.
8. Pair (bind) the light and switch by pressing button SW2 on both nodes at the same time.
All LEDs will be extinguished once the light and switch are successfully bound. If LED D2 starts flashing
again, repeat from Step 7.
Note: Here Topology mentioned in figure (1) was used.
Building an Application:
To build the application and load it into the JN5148 boards, follow the instructions below:
4

Ensure that project directory is located in
<JENNIC_SDK_ROOT>\Application
where <JENNIC_SDK_ROOT> is the path into which the SDK was installed.
Start the eclipse platform and import the relevant project files (.project and .cproject) as follows.
a) In Eclipse, follow the menu path File>Import to display the Import dialogue box.
b) In the dialogue box, expand General and select Existing Projects into Workspace.
c) Enable Select root directory and browse to the Jennic Application directory.
d) In the Project box, select the project to be imported.
Build the project. To do this, use the drop-down list associated with the hammer icon in the
Eclipse toolbar to select the relevant build configuration-once selected, the project will automatically
build. The binary files will be created in the relevant build configuration directory.
Load the resulting binary files into the boards from the appropriate build configuration directory. You can
do this directly from Eclipse or using the Jennic JN51xx Flash programmer (described in the JN51xx
Flash programmer User Guide (JN-UG-3007).
Results:
This application is working perfectly and able to control light on sensor node using switch on
another sensor using Coordinator successfully.





















5


JN51xx Flash Programmer User Guide

The JN51xx Flash Programmer application can be used to download binary code to the SPI bus connected
Flash memory chip on a JN51xx module or dongle, or to the on-chip Flash memory of a JN516x
microcontroller. The JN51xx Flash Programmer application is installed as part of the Software
Developers Kit (SDK) Toolchain, available from www.nxp.com/jennic/support.The JN51xx Flash
Programmer is available through a GUI (Graphical User Interface) or a CLI (Command Line Interface).
We worked on GUI interface using Jennic Flash Programmer.

Note: When downloading a binary file to Flash memory (by means of the Flash Programmer GUI or
CLI), you must use the JN51xx UART0 serial interface.
Note: Jennic JN51xx Flash Programmer 1.6.6 is came up with toolchain.

Downloading Binary Code:
The JN51xx Flash Programmer presents the following GUI in order to allow .bin file programming:




6

To use the GUI to download a .bin file to a board or module, follow the procedure given below.

Step 1: Connect your PC to the target board using a USB-to-serial cable from a JN51xx evaluation kit.
Make sure you connect the black wire of the cable to Pin 1 of the on-board UART0 serial connector. At
this point, you may be prompted to install the driver for the cable.

Step 2: Run the Flash programmer application by following the Windows Start menu path:
Start > All Programs > Jennic > Jennic Flash Programmer

Step 3: In the COM Port field of the interface, select the PC serial communications port for the board
connection to identify the relevant port, use Device Manager->Ports.

Step 4: Reset the device and put it into programming mode.
For boards/modules from the kits JN5139-EK000, JN5139-EK010 and JN5148-EK010:
a) Press and hold down the Programming button on the board/module.
b) Press and then release the Reset button on the board/module.
c) Release the Programming button.
For boards/modules from the JenNet-IP EK040 kit, enable the automatic reset and programming mode
signals for the target device. To do this, in the USB Dongle area of the interface, ensure that the checkbox
Automatic Program and Reset is ticked (if this box is not ticked, the target JN51xx device will not enter
programming mode and the download will fail).

Step 5: In the Flash programmer interface, use the Browse button in the Program File area to find and
select the binary file to download. Alternatively, the application remembers previously downloaded files
and these can be selected from the drop-down list (see highlighted part of the above screenshot).

Step 6: Select the baud rate for the download using the Baud Rate drop-down list.

Step 7: Check that the MAC address shown is correct for the device. If it is correct, click the Reuse
existing MAC Address radio button. If it is not correct, or if the MAC address is shown as all zeros.
Note: Click the Refresh button to re-read the existing MAC address from the device.

Step 8: Once the file and baud rate have been selected and the correct MAC address is displayed, click the
Program button to start the download.
The progress of the download can be viewed in the progress box that is displayed while the Flash memory
is being programmed:
When the download has finished, the result will be shown as successful or having errors. If there are
errors, try the download again.

Step 9: Once the download has successfully completed:
a) Disconnect the serial cable or release the serial port.
b) Reset the board or module.
The downloaded code will automatically run.

MAC Address Programming Procedure:

Step 1: Click the Refresh button to read the existing MAC address from the device.

Step 2: Assign a MAC address using one of the following options in the interface:
Use application supplied MAC address: The MAC address embedded in the application binary will be
used. [Not available for JN516x]
7

Reuse existing MAC address: The existing MAC address of the target device (shown in the MAC
Address field) will be used.
Use MAC Address list file: The next available MAC address in the licence file (specified in the Licence
file field) will be used refer to Section 2.2.2. [Not available for JN516x]
Type new MAC address: A new MAC address can be typed into the MAC Address field. A factory
programmed MAC address may be overwritten with another MAC address using this option for
JN516x, see the Caution below.

Caution: For a JN516x device, entering a new MAC address is a 'one-time programmable option and
care should be taken to ensure that the MAC address specified is correct before programming, as it cannot
be modified after programming.




Note: To read MAC address automatically from device, use option Reuse existing MAC address and
click refresh button(it must be connected to deice using cable and board must be powered on then MAC is
updated)
Note: If it is not able to display MAC address from device due to some unexpected reasons, use the
option Type a new MAC address and enter the MAC address manually in the boxes.


8




Application Data in Sector 3
The Flash device used in JN51xx modules has a capacity of 128 Kbytes, but only 96 Kbytes of this are
used for code. This leaves 32 Kbytes (in Sector 3) available for use by the application for data storage.

Preserving the Contents of Sector 3
By default, the Flash programmer will erase the entire contents of Flash memory when a new program is
programmed into the device. If your application uses Sector 3 of the Flash memory for non-volatile
storage of data, you should select the Preserve option in the Sector 3 Programming drop-down list,
illustrated below. When this option is selected, the Flash programmer will back up Sector 3 before erasing
the contents of Flash and will restore the data once the application has been programmed into Flash.



9

Saving the Contents of Sector 3
You can save the contents of Sector 3 to a file for back-up purposes. To do this, click on the Sector 3
Save button, illustrated below.


Save Button
You can later restore your saved application data into Sector 3 by selecting the Restore option in the
Sector 3 Programming drop-down list and then browsing for the back-up file.

Skipping Verification
The default operation of the Flash programmer compares the contents of the Flash memory with the
original file after the Flash has been programmed. However, to speed up the programming operation, you
can choose to skip this verification step. To do this, select the Skip Verification checkbox, illustrated
below.

10

JenNet Home Sensor Demonstration

Aim: To demonstrate JenNet home sensor showing temperature, humidity, light intensity of four
rooms on a LCD panel.

Functional Overview: The demonstration uses a Controller board (featuring an LCD panel) and a
number of Sensor boards from the evaluation kit. All the boards measure temperature, humidity
and light levels. The Sensor boards periodically send their measurements to the Controller board
through a beacon mechanism. The Controller board displays the received data on its built-in
LCD panel. Thus, the Controller board allows each Sensor board to be monitored, and also
allows alarms to be set for temperature and light levels on the Sensor boards. In addition, LEDs
on the Controller board can be controlled using buttons on the Sensor boards.
In this application, the Controller board acts as the Coordinator of a JenNet network. The Sensor
boards act as Routers (boards with SMA connectors) and as End Devices (boards with ceramic
antennae). Separate code is provided for the Coordinator, Routers and End Devices.
The Controller board can be configured to operate on a specific channel to avoid interference on
busy frequencies, and the Sensor boards automatically scan for the controller and synchronize
with it.

Network Formation:
The Controller board should be powered on first. The start-up screen on the LCD panel allows
the radio channel to be selected using the + and - buttons (default is channel 18) and the
network to be started by pressing the Done button.

Figure 1: Start-up Screen
The Sensor boards can then be powered on. When a Sensor board is switched on, it automatically
enters scanning mode:
1. First the Sensor board performs a channel scan. It repeatedly tries until it finds the channel on
which the network is operating.
2. The board then associates with a suitable parent that is operating on this network. Again, this
will be repeated until successful. During initial association, the Sensor board is assigned a role
by the controller. The roles are given in the order in which each board associates, in the order
Hall, Bedroom, Lounge and Bathroom.
11

3. After a first successful association, the Controller board remembers the role it assigned to a
particular Sensor board, so if that Sensor board loses the communication link and has to re-
associate, it will be assigned the same role again.
4. Once associated, the Sensor board moves into operating mode.
While in operating mode, the Sensor board periodically transmits its sensor values to the
Controller board, which can then display this information. The Controller board can also display
its own sensor values.
Sensor Monitoring:
Screen navigation is performed on the Controller board using the four buttons SW1-SW4, which
are given on-screen labels. This navigation is illustrated in the figure below.

Network screens
Node screens
Node Control screens
Settings screen

Figure 2: Screen Navigation
12


Network Screens:
Each network screen displays a particular type of sensor data for all network nodes.
3 different types of screens are available namely as temperature screen, Humidity screen, Light
screen.

Figure 3: Example Network Screen (Temperature)
Node Screens:
Each node screen displays all the sensor readings from a particular node (Hall, Bedroom, Lounge
or Bathroom).

Figure 4: Example Node Screen (Bedroom)

Node Control Screens:
There is a node control screen for each node. This screen is accessed by pressing the Control
button on the corresponding node screen. The node control screen is used to configure the alarms
that can be generated for the node.
13


Figure 5: Example Node Control Screen (Bedroom)
Settings Screen
The settings screen can be accessed only from the start-up screen (before the network is formed)
by pressing the Ch x button (where x=18 be default).
This screen provides access to two configuration parameters, Local node and Four nodes, as
well as indicating software version information. The parameters are described in the table below.

Figure 6: Settings Screen
14

Remote Control of LEDs:
The Home Sensor Demonstration illustrates wireless lighting control by using a button on a
Sensor board to control an LED on the Controller board, thereby providing a wireless
lightswitch.
Buttons SW1 and SW2 on any Sensor board can be used to control one of the four LEDs on the
Controller board. The LEDs controlled from the different Sensor boards are detailed in the table
below.

The buttons SW1 and SW2 on the Sensor boards are used as follows:
Pressing SW2 illuminates the relevant LED on the Controller board.
Pressing SW1 extinguishes the relevant LED on the Controller board.

There is no visible effect on the Sensor board itself.

Build Application:
To build the applications and load them into JN5148 boards, follow the instructions below:
1.Ensure that the project directory is located in <JN5148_SDK_ROOT>\Application
where <JN5148_SDK_ROOT> is the path into which the JN5148 SDK was installed.
2. Start the Eclipse platform and import the relevant project files (.project and .cproject) as
follows:
15

a) In Eclipse, follow the menu path File>Import to display the Import dialogue box.
b) In the dialogue box, expand General, select Existing Projects Workspace and click Next.
c) Enable Select root directory, browse to the Application directory and click OK.
d) In the Projects box, select the project to be imported and click Finish.
3.Build an application. To do this, ensure that the project is highlighted in the left panel of
Eclipse and use the drop-down list associated with the hammer icon in the Eclipse toolbar
to select the relevant build configuration once selected, the application will automatically
build. Repeat this to build the other applications.
Downloading the Application:
The build process produces three binary files, one for each device type (Co-ordinator, Router,
End Device). You must download each of these files to the relevant device(s):
The Co-ordinator binary file to the Controller board
The Router binary file to the Sensor boards with SMA connectors
The End Device binary file to the Sensor boards with ceramic antennae
Result:
Home sensor demo application is running perfectly and able to get data like temperature,
Humidity, Light intensity for four rooms on LCD.
















16


ISSUES:
For the following error occurred while building the project.
Error:
I 'm beginner for Eclipse development tools, so i installed eclipse and try to start with jn-an-1085
jennet tutorial
I follows the tutorial 1 step, the import the project an build Step1_coordinator.
In the tutorial document procedure let me the compilation success, but I have some errors:
Makefile:130: /cygdrive/c/Documents: No such file or directory
Makefile:130: and: No such file or directory
Makefile:130: Settings/Administrator/My: No such file or directory
Makefile:130: Documents/Jennic/Chip/Common/Build/config.mk: No such file or directory
Makefile:131: /cygdrive/c/Documents: No such file or directory
Makefile:131: and: No such file or directory
Makefile:131: Settings/Administrator/My: No such file or directory
Makefile:131: Documents/Jennic/Platform/Common/Build/Config.mk: No such file or directory
Makefile:132: /cygdrive/c/Documents: No such file or directory
Makefile:132: and: No such file or directory
Makefile:132: Settings/Administrator/My: No such file or directory
Makefile:132: Documents/Jennic/Stack/Common/Build/Config.mk: No such file or directory

The errors are in the makefile , lines:

include $(SDK_BASE_DIR)/Chip/Common/Build/config.mk
include $(SDK_BASE_DIR)/Platform/Common/Build/Config.mk
include $(SDK_BASE_DIR)/Stack/Common/Build/Config.mk

I don't modified the default installation of Eclipse and the tutorials file.

There is something in the project configuration that is wrong?
Solution:
SDK_BASE_DIR = /cygdrive/c/Jennic
More information can be found on the following link.
17

http://www.jennic.com/support/forums/thread.php?postID=0000008426


Problem: How to display data in system
Solution: Using the following function data can be displayed in monitor.Follow the path as
Zigbee-PRO -Wireless Lightswitch application -> ZPC_Controller ->Source-
>zpc_controller_node.c

DBG_vPrintf(TRACE_APP, "Allow joining for %ds\r\n",PERMIT_JOINING_TIME);
Using above function can be used display data Allow joining for 5 second. We got problem to
get data on monitor.












18

REFERENCES:
[1] http://www.jennic.com/

You might also like