|For this demo I wanted to show how easy it is to modify an existing Arduino project to receive serial commands through a mobile web application usingXBee® ZB modules and the iDigi® Device Cloud™.||About the Author —
Mark Geller is an iDigi Application Developer. He has several years’ experience in programming and application development.
- 1 Arduino board
- 5-8 LEDs
- 5 220 ohm resistors
- 1 breadboard
- 1 XBee breakout board with headers
- 1 XBee ZB OEM module
- 1 ConnectPort® X4 gateway
(or ConnectPort® X2)
- hook-up wire
I approach most iDigi projects by breaking them down into four milestones:
- XBee-enable a remote device
- Configure iDigi® Dia to talk to remote device
- Use iDigi web services to talk to remote device
- Build website that uses iDigi web services to talk to remote device
I do quick system checks at each milestone to make sure that everything is working as expected.
For this project, I started with the SwitchCase2 tutorial from the Arduino website. This example combines blinking LED lights, which are always fun, with simple serial communication.
XBee-Enable Remote Device
The first step for adding XBee communication to a project is configuring the XBee module. The ConnectPort X4 gateway is acting as the coordinator for this network, so the XBee module on the Arduino needed to have either router or end device firmware. Using X-CTU, I loaded ZigBee Router AT firmware (2270). We have a lot of XBee modules in use at Digi, so I configured the module with a unique PAN ID as well. I kept the default serial interfacing options:
Baud: 9600Data: 8 bitParity: NoneStop bits: 1Flow Control: NoneI didn’t need to modify the sketch running on the Arduino to enable serial communication over XBee; I just needed to connect four pins to the Arduino board. For power, I connected pin 1 on the XBee module to the 3.3 V output on the Arduino and pin 10 on the XBee module to the ground connection on the Arduino. I connected pin 2 (TX/DOUT) on the XBee module to digital pin 0 (RX) on the Arduino and pin 3 (RX/DIN) on the XBee module to digital pin 1 (TX) on the Arduino to establish the serial connection.
I hooked up a few extra LEDs to the XBee module to make it easier to confirm that it is powered and receiving data. An LED on pin 6 (positive lead to the XBee pin with negative lead to ground) will light when the module receives data that is addressed to it. An LED on pin 13 will light up when the module is on. An LED on pin 15 will stay on as it tries to join a network and blink once it has associated itself to an XBee network. Since I configured my ConnectPort X4 gateway with the same PAN ID as the XBee module, it automatically joined when I powered up the Arduino board.
Configure iDigi Dia to Talk to the Remote Device
I used a ConnectPort X4 gateway to handle communication with both the Arduino board and with iDigi Device Cloud. I went to www.idigi.com, created a free developer account, associated my gateway to my developer account and configured my gateway to connect to my account.
I decided to use iDigi Dia on the ConnectPort X4 gateway to handle sending and receiving commands to the Arduino. The iDigi Dia software is designed to make ZigBee communication with XBee ZB modules simple. Using Digi ESP™, which is an Eclipse-based development environment, I created a new iDigi Dia project named “XBee Serial Demo.” I added an XBee serial terminal device driver to my project, compiled the project and uploaded it to my ConnectPort X4 gateway. The dia.yml file for my project looked similar to what is shown below:
- name: xbee_serial_terminal0
- name: idigi_db
- name: console0
- name: web0
Once I launched the python program on the ConnectPort X4 gateway, I was able to send serial commands to the Arduino using the built-in web console:
In the second part of this project log I will demonstrate how to use iDigi web services to connect to the Arduino board and how to build a mobile website that uses those web services.
I started my career as a variable data print programmer at a print company in Lindon, Utah. While working at the print company, I learned how to create websites that leverage web services using ASP 3, ASP.NET and Adobe Flash.
Three years later I left the print company and joined MaxStream as a PHP web programmer and search engine marketing specialist. My first tasks were to redesign the MaxStream website, market our XBee modules and help organize the firstWaveForum Developer’s Conference. About one year after I joined MaxStream, Digi International® acquired us. I moved to the corporate headquarters in Minnetonka, Minnesota and continued working as a web and Flash programmer for our Digi® and Rabbit® websites.
I started working on iDigi applications just before we announced the launch of the iDigi Device Cloud at ESC a few years ago. Since then I have built a number of iDigi applications and demos using PHP, ASP.NET, Java, Python, HTML, and Flash. I look forward to building more iDigi applications and seeing how the iDigi Device Cloud evolves.
Share Your Ideas
One of the best parts of being part of the iDigi Applications Team is hearing about the interesting ways people are using the iDigi Device Cloud. If you have an application, story request or questions, please contact us at firstname.lastname@example.org.
The WaveForum Developer’s Conference is coming to San Diego. Digi is offering three days of interactive education focused on communicating with remote devices and management solutions using device cloud networking.
Register today to take advantage of some great discounts off the price of registration and lodging.
Use coupon code JULY11 to save $100 at registration — that’s just $595 after discount for expert education, networking events, meals and more!
The Westin San Diego is offering a $155 per night room rate for WaveForum attendees — availability is limited. Visit the lodging section on the WaveForum registration page to lock in your rate.
First Prize — The iDigi Device Cloud received first prize in the Industrial IT category of the “Palmarès Technologique 2011” awards. This award recognizes the most outstanding innovation of the year in the industrial IT sector.
Storage Tank Management — TankScan is using ConnectPort X cellular and Ethernet gateways with the iDigi Device Cloud, enabling access and management of remote tank information from anywhere in the world. More >
iDigi Garden — Our self-regulating, self-maintaining irrigation system uses XBee modules, ConnectPort X gateways and the iDigi Device Cloud in combination with a variety of sensors, regulators and other monitoring and control devices to maintain optimum moisture levels, even in the July heat.
Follow Digi on Twitter, Facebook and YouTube.