XBee Internet Gateway

Print This Page Print This Page

Jordan Husney, Ted Hayes and myself have written an XBee Internet Gateway for the ConnectPort X2 so that any microcontroller-powered device prototype can connect directly with the Internet. This system is now in use at ITP and in several other locations. Plain URLs sent from an XBee radio (Series 2 XBee ZB or Series 1 802.15.4) radio are processed by the Gateway, retrieved from the Internet, and results are returned to the sender.

The XBee Internet Gateway gives any device the ability to connect seamlessly to the Internet by mirroring the interactions humans have with web browsers. Any device with an XBee radio can send a web URL to the XIG and receive back the contents of that web page. All the tricky technical aspects of web connections are all handled for you behind the scenes. This simple service gives your prototype or device a simple yet completely flexible pathway to any web service that you can imagine, including posting sensor values, scraping Facebook or commanding your robotic kitten army.

To use the gateway you need to:

  1. Configure your Series 2 radio as a ZB firmware Router or End-Device. Series 1 just use the latest firmware.
  2. Switch the PAN to AAAA: ATIDAAAA
  3. For best results, set your radio to 115200 baud: ATBD7 
  4. Set the destination address to zero: ATDH0 and ATDL0

When you’re ready to go, attach the XBee to your Arduino’s hardware serial port (pins 0 and 1), then send a URL and you’ll get back the response. For example to send your request from Arduino:

Serial.println(“http://www.faludi.com/test.html”);

And to read the response back:

if (Serial.available()) {

char inChar = Serial.read();

print ( inChar );

}

Of course, you’ll be doing something way more interesting than just that! Some useful things to know:

Once your XBee is associated to your gateway, you may retrieve the contents of a website from your XBee by sending the URL of the site to the gateway via your XBee. For example, sending:

http://en.wikipedia.org/w/index.php?title=Hello_world_program&printable=yesrn

…will retrieve the printable version of Wikipedia’s entry on a

“Hello, World Program” to your XBee. Note that the “r” and “n” characters are the ASCII carriage-return and line-feed characters.

There are other commands available when using XIG:

All commands are CR “\r” or NL “\n” delimited, except where noted.

  • help or xig://help: displays this file
  • quit or xig://quit: quits program
  • abort or xig://abort: aborts the current session
  • http://host/path[:port] retrieves a URL
  • https://host/path[:port] retrieves a secure URL
  • http://username:password@domain.com/path retrieves a URL using username and password
  • https://username:password@domain.com/path retrieves a URL using username and password
  • xig://time retrieves the current time from the gateway
  • udp://host.domain.com:portnumber sets up a remote UDP streaming connection
  • osc://host.domain.com:portnumber sets up a remote OSC connection
  • …and pointing any I/O sensor information at the gateway sends I/O samples up to a pre-specified web site

IV. Known Issues

The following URL schemes are not yet supported (help contribute!):

  • ftp://
  • ftp://
  • telnet://
  • mailto:

Source code is available online for anyone who wants to download it or participate in development. There are also some sample files that may be useful once the gateway is installed on a ConnectPort device.

XIG Projects:

 

49 Responses to “XBee Internet Gateway”


  • This is a wonderful project. Do you know this code will work directly on Linux? in a negative case, do you know if there is any implementation of this gateway for a linux router?
    Regards.
    alfredo.

    • Not aware of a Linux implementation but the Python, combined with a good ZigBee library would be a place to start. I personally prefer the ConnectPort for cost, reliability, size and environmental reasons (less materials, low power). Oh and of course the full remote management via iDigi has been a lifesaver more times than I can count. On the other hand, if you have a Linux box that’s powered on 24/7 there’s no reason it couldn’t also serve as a gateway.

  • Hello Rob,

    I found out about the XIG project because I am reading your book. For a project (monitor/control greenhouse conditions) I am using Xbee to transfer statistics to pachube and my own DB via an Arduino with Xbee and Ethernet shield. Using your method would greatly reduce the complexity of my project, since adding data, messages, etc would not require an update to the gateway code.

    Are you aware of any attempts (failed or succeful) to port this functionality to an Arduino?

    Thanks for the great book and making this all open for everyone!
    Regards,
    Arno

  • I might be slightly confused and just want to make sure this will do what I need:

    If I setup an Xbee sensor network per the directions in your book then I can pickup one of these X2s and make HTTP GET/POST requests to an arbitrary webserver with the temperature (and etc) data?

    If not please let me know because this is the option I’m leaning towards now. I too am trying to track temps/humidity for my plants.

    • That’s exactly right. Using the IO mode on the radios directly is newly supported on the XIG code, so if you run into any issues with it, let us know!

      • Rob,

        Just updated XIG to 1.3.2 and have been trying to get the I/O sample request working. The X2 and Router node are configured as above. For some reason I am not getting the samples. I have a local web server that I can see using X-CTU so I know the URL’s are correct. I can change the PAN to my Arduino setup and once the node rejoins I see the samples coming through. Thoughts?

        • Not sure what you mean by changing the PAN to your Arduino setup.

          • The extended PAN ID is set to 0xAAAA when I am communicating with the X-CTU. To confirm my setup I have a coordinator on an Arduino platform with a different extended PAN ID. I did some additional digging and suspect that the XIG is acting like it is using defaults instead of loading the XIG_CONFIG.PY. My expertise is not with python and the environment. However, I did run XIG from the command line as was able to confirm I/O packets were coming in. When run from the command line, XIG still seems to pick up the default configuration instead of the XIG_CONFIG.PY

  • This is great – I’ve been able to get it working fine for my regular Xbee’s, but I run into issues with the S2B variant. Is there a trick to getting the S2B to support XIG ?

    I can sometimes get it to work in X-CTU, but most of the time it doesn’t. Any suggestions would be much appreciated.

  • I configured, successfully, ConnectPort as described above.
    In the end, the PAN identifier is reported as being 0x9213.
    Also operating channel is 0x19. I cannot find a way to modify those to match the numbers you used in the example code (PAN ID = 0xAAAA), so I modified the PAN ID on my node XBee (and the channel). I am not able to get anything back from XIG.
    Am I doing something wrong from what I just described?
    Thanks.
    FlorinC

    • You can use any PAN ID that you like. You can also set the XBee to PAN ID 0x0 in which case it will join any PAN that it finds. By default the Series 2 XBee ZB radios will join any PAN found on any channel.

  • Thanks.
    I opened my CoonnectPort X2 and noticed that it has an XBee Pro S2B. This Digi documentation
    http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/zigbee-mesh-module/xbee-zb-module#overview
    says
    “Devices that do not have the “ZB” product name, including Digi’s line of DigiMesh and 802.15.4 XBee products, are not compatible with XBee and XBee-PRO ZB Modules.”
    In the above failing experiment am trying to connect my XBee Series 1 802.15.4. (since you say “Plain URLs sent from an XBee radio (Series 2 XBee ZB or Series 1 802.15.4) radio are processed by the Gateway”)
    Should this work? Should I expect it to work? Or should I get a XBee ZB instead of the series 1 I am currently trying with?
    Your help is greatly appreciated.
    FlorinC

  • I am trying to use XIG for a project i wanted to know if there is a way to use the endpoint routers in API mode so that i can use security?

  • Great project !! It’s really exiting to combine wireless, electronics and Internet to measure and control things. I’m experimenting with my own network and will send data from ZED’s to the internet. I was wondering why I should use a PAN of AAAA (as mentioned above). As long as the X2 and the Xbee’s are on the same PAN ID I think it should work. Thanks to you book the XBee network is up and running. I was wondering is there also some information regarding the configuration steps necessary to configure the XIG to upload the data to a website.

  • This is a fine piece of work. Introduced to this by way of your book. I am using XIG in several ways, all with XBEE and Arduino, sending sensor data via HTTP GET for example. Additionally, I have begun using the idigi_data command to place data into an iDigi DIA channel. Very pleased.

    I have a question. I am sending serial text strings to the Arduino via XBEE using XIG TARGET and PYTHON CALLBACK. Is there any way I can customize responses, say from the Arduino. For example, is there any way to request a light’s status (ON or OFF) before I send a command to turn it ON?

    • Using Arduino, you could have an HTTP GET post a response in reaction to a XIG target RCI string received. The other option is to control a light directly, using Remote XBee AT Settings via iDigi RCI (section E in the User Documentation). That could either be the control output, bypassing the Arduino, or a digital input to the Arduino if you want to do something fancy based upon the request.

      • I have spent some time this weekend working with the DIA (ESP) platform, and have accomplished my original objective following Mark Geller’s THUNDERHEAD ideas. But I tend to very much like the XIG approach better. It’s much less coding and configuration, and XIG is more compact – I have a ConnectPort X2. I had several OUT OF MEMORY issues with DIA and had to pare back to the bare minimum functionality. That’s not the case with XIG — it’s footprint is the same regardless of what I’m dealing with on the device side. And it seems I can do most of the same things. But I’m inexperienced, and confused as to the relative strengths of DIA vs XIG, and for that matter, coding from scratch PYTHON, which is not where I’m wanting to go. So I don’t know if there’s a question here, but rather I’m requesting a confirmation of whether I am accurate in my assessments here. Thanks!

  • I am quite successfully continuing my development with XIG. One question has come up which I have researched without success. When storing sensor data, I have the choice of 1) storing in the iDigi cloud (using idigi_data: construct) 2) or forwarding data to an appropriate web server for storage via any of several HTTP GET constructs XIG offers. Say I use the latter, and using XIG, my XBEE / Arduino node can forward the necessary URL (including the query string) and expect an HTTP response. My question is, where is the connection to the Internet made? Does my connectport X2 ‘gateway’ the GET request directly on the Internet, and proxy the response back to XBEE / Arduino, or does connectport forward on to iDigi which manages this? I’m hoping the answer is the cloud isn’t involved in such a transaction. Thanks!

  • Douglas Datwyler

    Does XIG run on a ConnectPort X4? I got a kit with this device a while back.

  • Douglas Datwyler

    answered my own query. YES to ConnectPort X4. Currently spitting out: http://en.wikipedia.org/w/index.php?title=Hello_world_program&printable=yesrn

    Nice. Now I can do the Make garage door opener (or several other things I have thought of…)

  • Is anybody works on the ftp for the XIG ?
    I would like to transfer my data to my website.
    Also is anybody try to add web page on X2 to control a zigbee module in local ?
    Thanks

    • FTP is on the roadmap for the XIG, but I’m curious to hear what your application might be for it.

      • In fact i used a card with an xbee which store electric consumption in a sd card, and i would like to send these data in a web site to use it.
        It also records the photovoltaic power generation.
        And i would like to send these data without going thru idigi cloud, cause it’s a step which is not necessary and not free.

  • Hi, xig is wonderfull i use it for home automation
    I use too the xbee interrupt and send i/o information to my site to insert it in a database.
    For each interrupt i have an idigi web transaction.
    How is it possible ?

    Thanks

    • Sample sending to iDigi is turned on by default to make it easy for users who don’t want to do any configuration to see their data online. It is easy to turn on and off this feature in the configuration file. Instructions for modifying that file can be found in the public documentation here:
      http://code.google.com/p/xig/wiki/UserDocumentation#V._CONFIGURATION

      I like to have both turned on because it’s a nice backup feature and with a free account there’s no charge for getting the data in two places. However turning it off will save a little application memory on the ConnectPort and obviously reduces your IP traffic a bit which would be important if there is high volume data or if you are on a low bandwidth cellular or satellite connection.

  • hi , I have a question Can i send some data to my board using XIG by TCP/ip?

  • This video connects XBEE to KK2 board the code exists in the HefnyCopter2 on google code.

    http://www.youtube.com/watch?v=S_AxThJYa2g

  • Hi, I’m working on project which I need to use Xbee series 2 and display sensor out on web page. One base and two nodes point to multiple point. Can you please help me to set up communication? i have already set up point to point.
    Thanks

  • For a while I’ve been posting consumption data to Pachube/Cosm via CurrentCost bridge. Has anybody transitioned to iDigi using CurrentCost?

  • Hi, I would like to do that from my Arduino/Xbee : Serial.println(“http://localhost/FS/WEB/python/test.html”); It doesn’t work, how can i do ?

  • Hi,

    I’m having trouble using pyc-files in my zip files like you have in _xig.zip. I suspect it has to do with the python version I used for compiling which is the original 2.4.3 build #1. What python or tool did you use to compile the xig library?

  • Hi,
    I have problems using XIG in Windows.
    When I run it it get stuck after my ip is …
    Sometimes I get Error 10053, but not always.
    One time it run, and I could see the website, but after restarted it, I could no longer do that.
    I though it could be a Router issue, Firewall issue, etc.
    I tried disabling all them but could not do it.

    Any suggestions ?

    Thanks !

    • Similar to Martin, I’m having problems using XIG on win7.

      I’ve set up my XBEE ZIGBEE’s according to the Installation Instructions, then I also downloaded both the stable XIG and the beta, neither of which seem to be working.

      After configuring the XBEE (it’s still plugged in from config) I start the XIG app and wait.
      I get these lines:
      No handlers could be found for logger “cp4pc.xbee”
      xig – XBee Internet Gateway v1.5.0 starting
      cp4pc.rci – Starting web server at http://localhost:8000
      cp4pc.edp – my device ID is: 00000000-00000000-90A4DEFF-FFE5F1B2
      cp4pc.edp – my IP is 192.168.1.111

      this is the end of the output, and the tab doesn’t ever connect in IE nor in firefox.

      If I close the app window, but leave the tab open, it starts to connect. If I then re-open the app it will complete loading the page, but changing the values on the page makes no difference, and the XBEE is always showing “not connected”.

      Either I haven’t configured it right, or the installation instructions I’m following (the official instructions) are missing something.

      Please help! I’ve tried to provide all the important info. Let me know if more is required.

      Thanks!

Leave a Reply

You must login to post a comment.