Connecting XBee Wireless Networks to ThingSpeak via the ConnectPort X2 running XIG

If you’re interested in building wireless sensor networks, Digi’s XBee Series 2 radios are a great starting point. In some cases, you can connect analog sensors directly to an XBee radio and relay that data wirelessly to an XBee connected to an Internet Gateway such as the ConnectPort X2 or ioBridge Pro Internet Gateway. This tutorial covers how to use the ConnectPort X2 to allow web services to be accessed over a wireless network formed by XBee Series 2 radios.
In order to retrieve web data, you need to upload the XIG Python script to your ConnectPort X2. The XIG script allows you to fetch websites and URLs by using HTTP GET. We can take full advantage of that and use XIG to get ThingSpeak URLs to data log sensor data, parse data from any website using ThingHTTP, get data from SSL secured APIs, and send Tweets via ThingSpeak’s ThingTweet App. Here’s an instance where support for HTTP GET allows the XIG to perform cloud-based data logging without having to run a PHP script or write any new software. If you are following along using the Building Wireless Sensor Networks book by Rob Faludi, you can replace all of the custom PHP scripts with a ThingSpeak app.


Setting up the ConnectPort X2

Your ConnectPort will display in the Devices list and show a status of “Connected” if everything is working correctly. It may take a few minutes for the status to show that it’s connected.
Digi ConnectPort Devices Management


  • For easier setup, make sure you are connected to a computer on the same network as the ConnectPort X2.
  • The install requires Java to be installed on the computer.

Setting up XIG on the ConnectPort

In order to access external web services over a wireless XBee network, you need to add XIG to the ConnectPort. XIG is an XBee Internet Gateway for the Digi ConnectPort devices. XIG will allow you to fetch URLs and ultimately connect to ThingSpeak web services and apps. You will be able to do sensor data logging, send tweets, or get data from any web page or resource using the ThingHTTP app.
The following steps are based on the ConnectPort firmware version of and is newer than the version covered in the book, “Building Wireless Sensor Networks” by Rob Faludi. The differences for the most part is a that all of the setting are consolidated to the Management -> Devices area of the iDigi interface.

Digi ConnectPort Upload Python Files

  • Select Browse…
  • Select “” from where you unzipped XIG
  • Click OK
  • Right-click on your ConnectPort, select Administration, and Upload Python Files…
  • Select Browse…
  • Select “” from where you unzipped XIG
  • Click OK
  • Right-click on your ConnectPort and select Properties
  • Select Python option
  • Check enable on first line
  • Type “” in the Auto-start Command Line box
  • Click Save
  • Disconnect power to the ConnectPort X2
  • Reconnect power to the ConnectPort X2

Digi ConnectPort Auto-start XIG Python Script


  • Once you have uploaded the Python scripts for XIG make sure you cycle the power for the changes to take effect.


  • Add Data to a ThingSpeak Channel
  • Send Tweets using ThingTweet
  • Fetch and Parse Web Sites with ThingHTTP
  • Get Data from a ThingSpeak Channel

Connecting a Series 2 XBee to an Arduino

There are 4 lines that you need to connect together: TX / RX serial lines and the 3.3V DC / Ground power lines. Use the hardware serial lines of the Arduino.


XBee Arduino
VCC or 3.3 V 3V3
TX DOUT RX or Pin 0
RX or DIN TX or Pin 1


I used the components from the BWSN Basics Kit from SparkFun. The items I used were the XBee breakout board and the solderless breadboard. The XBee breakout board converts the small headers of the XBee modem to standard spacing for plugging into a breadboard.

Sensor Data Logging

  • Create a ThingSpeak Channel and note your Write API Key
  • Connect an XBee Series 2 radio to a micontroller such as the Arduino development board
  • Connect an analog sensor to an analog pin
  • From the microcontroller send your ThingSpeak Channel Update URL to the XBee via the hardware serial lines

Example Arduino Code

Serial.println(" Channel Write API Key)&field1=(Analog Input Value)");