Skip to content

IoT Gateway between XBee ZigBee and TCP network (MQTT, etc...)

License

Notifications You must be signed in to change notification settings

alex-deng/butler-xbee-gateway

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BUTLER-XBEE-GATEWAY

About

  • It is a gateway between XBee® ZigBee and TCP network for BUTLER smart house framework.
  • Gateway extracts data from XBee® ZigBee frames and sends to the TCP Server.
  • Gateway maintains separate TCP connection for each XBee® ZigBee device.

In default configuration/example:

Purpose

Usually microcontrollers like Arduino doesn't have network stack. If you use a MQTT library to communicate with broker you still need network stack. The only way to communicate with world is a Serial. Serial is simple and really popular. A lot of RF modules do work via Serial interface. Unfortunately on other side you get Serial as well in case of XBee® ZigBee. MQTT broker doesn't support Serial connection directly and we need to pack data from Serial to TCP:
      Arduino --> Serial --> RF <---z---> RF --> Serial --> xbee-gateway --> TCP --> MQTT Broker

Usage

  • Connect XBee® ZigBee Coordinator to PC where the application is installed.
  • Launch the application.
  • Do not forget to power ON all nodes with XBee® ZigBee wireless interfaces.

XBee® ZigBee Network Configuration

XBee® ZigBee Coordinator

  • Coordinator must have the firmware with ZigBee Coordinator API functional set.
  • Use XCTU to set AP (API mode) option to 0x2 (escapes).
  • Use XCTU to set BD (Baud Rate) to 57600.

XBee® ZigBee End Device and XBee® ZigBee Router

  • Devices must have the firmware with ZigBee End Device or ZigBee Router functional set.
  • Use XCTU to set PAN ID. It must be equal with Coordinator.
  • Use XCTU to set DH and DL to 0x0 (send data to Coordinator).

Prepare build environment

Cmake

Install Cmake(http://www.cmake.org) with version 2.8 or later.

C++

Install the compiler with C++11 support.

Boost

Install Boost(http://www.boost.org) library with version 1.45 or later.

Building

UNIX like OS

  • Create a build directory for out of source compilation:
mkdir build
  • Go to the build directory:
cd build
  • Use Cmake to prepare the build:
cmake <path to sources>
  • Use make to start the build process:
make
  • The resulting binary file is located in <build directory>/bin/

UNIX like OS + Eclipse

  • Create a build directory for out of source compilation:
mkdir build
  • Go to the build directory:
cd build
  • Use cmake to prepare the build:
cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug <path to sources>
  • Import the project from the build directory (File -> Import -> General -> Existing Projects into Workspace)
  • Use Project -> Build Project to start the build process

Raspberry Pi (cross compilation)

  • Download or build your own GCC based toolchain for ARM Linux with hardware floating point support.
    See http://crosstool-ng.org
  • Install all dependencies to the toolchain rootfs.
    A lot of prebuilt libraries are available on official repository (http://archive.raspbian.org/raspbian). Just unpack files to rootfs.
  • Create a build directory for out of source compilation:
mkdir build
  • Go to the build directory:
cd build
  • Configure environment:
export RASPBERRY_PI_TOOLCHAIN_PREFIX=arm-raspberry-linux-gnueabihf-
export RASPBERRY_PI_TOOLCHAIN=$HOME/raspberrypi/toolchain
export RASPBERRY_PI_ROOTFS=$HOME/raspberrypi/rootfs
  • Use Cmake to prepare the build:
cmake -D CMAKE_TOOLCHAIN_FILE=build/cmake/Toolchain/raspberrypi.cmake -D CMAKE_BUILD_TYPE=Release \
      -D PACKAGE_SYSTEM_NAME=raspbian <path to sources>
  • Use make to start the build process:
make
  • The resulting binary file is located in <build directory>/bin/
  • Use make to build deb package:
make package
  • The resulting deb file is located in <build directory>

Configuration

Configuration file is done in JSON(http://www.json.org) format. ######Example:

{
	"logger":{
		"level":"INFO"
	},
	"serial":{
		"name":"/dev/usbserial",
		"baud": 57600
	},
	"tcp":{
		"address":"test.mosquitto.org",
		"port": 1883
	}
}

Logger

Application logger settings.

Block name

logger

Parameters:
level (String)

Set verbose level.

Value Description
"ERROR" Prints only errors
"WARN" ERROR level + warnings
"INFO" WARN level + processing information
"DEBUG" INFO level + debug information
"TRACE" DEBUG level + messages content
###### file (String) Path to logfile like `"/var/log/my.log"`.

Serial

Serial port settings.

Block name

serial

Parameters:
name (String)

Path to serial port device like "/dev/usbserial".

baud (Number)

Serial port baud rate like 57600.

TCP

TCP connection settings.

Block name

tcp

Parameters:
address (String)

Server address like "test.mosquitto.org"

port (Number)

Server port like 1883

About

IoT Gateway between XBee ZigBee and TCP network (MQTT, etc...)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 92.3%
  • CMake 5.4%
  • Shell 2.3%