Networking Options for Arduino-Based Systems

Arduino

Lee Goldberg

Electronic Products

Adding wired or wireless networking capabilities to the Arduino open-source hardware/software platform is easy, inexpensive, and opens up another world of applications for both commercial and DIY developers (Figure 1). In this introduction to networked Arduino systems, we’ll explore what it takes to add an Ethernet, Wi-Fi, or 802.15 interface to an Arduino-based design. (NOTE: Readers who are unfamiliar with Arduino can refer to the TechZone article “Arduino Open Source Platform Unleashes Creativity.”)

The Arduino module controlling the RobotShop Rover

Figure 1. The Arduino module controlling the RobotShop Rover receives programming and commands from a host PC using its integrated USB connection. An XBee 2.4 GHz 802.15 transceiver shield can be added for wireless remote control and sensing.

Born to network

In truth, virtually every Arduino device has some sort of communication capability. At its most basic level, a board must provide some means for its PC-based development system to upload application software and to exchange debug/trace commands. Many Arduino boards (such as the Uno and the Mega2560 have an integrated USB port that serves as both a host communication link and as a low-power power supply. Some specialized boards forego the luxury of a USB connection and fall back on the Atmel ATmega AVR processor’s serial communication capabilities to provide an RS-232 (or equivalent) link that can be read by nearly any device with a serial port.

The Arduino platform can also be equipped for serial communication with other ICs (located on the main board or attached modules) via an SPI, I²C, or generic two-wire interface (TWI). In many cases, this can be accomplished using the board’s existing resources or a small adapter module.

Many applications require the addition of networking abilities that allow it to communicate locally with other Arduino platforms or across the Internet. CANbus or I²C are often used for wired M2M connections while 802.15-compliant 2.4 GHz air interfaces are proving popular for wireless applications. If your design needs to talk to the “outside world” there are a variety of “shields” (Arduino-speak for daughter/mezzanine cards), that can provide an Ethernet, WiFi, or CDPD/GSM connection.

Hardware basics

Although Arduino processor boards vary widely in their form factors and capabilities, they follow a set of conventions for the open-source hardware platform that enable partial or full interoperability between variants. For example, many Arduino boards use similar connection assignments for the pin header connectors that provide access to the MCU’s bus and I/O signals, making it easy for a single Ethernet, ZigBee or other networking shield to work with a wide range of products.

In keeping with this philosophy, the Arduino development environment was designed to support a wide range of target boards with different MCUs, on-board I/O compliments, clock speeds, and bootloaders. While originally developed to support variants of Atmel’s 8-bit ATmega MCUs (MCU with Arduino Uno bootloader), the same environment accommodates the recently-introduced variants of the Uno and Mega boards which use Microchip’s PIC32MX family of 32-bit MCUs.

Software basics

The Arduino software suite consists of a development environment (IDE) and associated core libraries. Applications (known as sketches) are written in the Java-based Processing language. Sketches are pre-processed to identify the hardware-dependent aspects of the target board (and any shields or modules that it is using) before they are compiled.

Each board’s characteristics are defined in a file called boards.txt using multiple variables prefixed with the same keyword. A Board is described using a series of variables named for the attribute they cover such as BOARD.name, BOARD.build.f_cpu (e.g. "atmega328" or "atmega1280") and BOARD.build.core which contains the location of the core-to-link sketches used by the compiler.

The compilation process calls in any core or custom libraries required by the application, including a Serial Communication library which enables the Arduino board to exchange data with a computer or embedded microcontroller device by emulating the nine-pin Serial Port commonly found on PCs. The companion Network library allows Arduino to read and write data between machines across the Internet as well as the establishment client/server functions.

The core library set also includes support for specific networking interfaces, including USB, SPI, TWI/I²C, and Ethernet. Additional contributed libraries enable the addition of web functionality as well as support for other wired and wireless protocols.

Networking technologies

Here is a sampling of networking technologies available in the Arduino ecosystem. While the examples in this list tend to be the “official” solutions offered by Arduino, there are many similar commercial and non-commercial variants available from vendors and user groups.

USB – Many boards already include a USB interface but some space- or budget-constrained variants don’t. The easiest way to add USB capability is the USB Serial Light adapter (Figure 2) which translates between the board’s native 5 volt UART serial signals (digital pins 0 (RX) and 1 (TX) on most variants) and a USB connection.

Arduino USB Serial Light adapter

Figure 2. The Arduino USB Serial Light adapter.

The adapter uses an Atmega8U2 MCU programmed to serve as an USB-to-serial converter. Since '8U2’s firmware uses Arduino’s standard USB COM drivers, no external driver is required. If you need to “roll your own” USB interface, you can add the 8U2 or Future Technology Devices’ FT232RL USB-to-serial driver chip to your main board or custom adapter.

Ethernet – Most derivatives of the Uno and Mega boards accept Arduino’s standard Ethernet Shield (Figure 3) which is based on the Wiznet W5100 10/100 Ethernet MAC/PHY. It includes an onboard micro-SD card slot, which can be used to store files for serving over the network. Arduino communicates with both the W5100 and SD card using the MCU’s SPI bus (through the ICSP header). Power-over-Ethernet can be supported using an optional DC/DC converter module. The core Ethernet Library contains files that allow Arduino Uno and Mega boards to initialize and drive the W5100 and serve as a Client or Server for up to four concurrent incoming or outgoing socket connections.

The Arduino Ethernet shield

Figure 3. The Arduino Ethernet shield supports 10/100 Mbps Etherent and is available with an optional PoE module for remotely-powered applications.

802.15/XBee – There are many wireless data options for Arduino that use the IEEE 802.15.3 2.4GHz networking standard. In general, the ZigBee networking protocol is not very popular because of its large memory and processing requirements. Instead, a lighter-weight ZigBee-like protocol called XBee is often used. Capable of supporting both Star and Mesh topologies, the lightweight XBee protocol uses the standard AT modem command set to handle data transfers.

One of the most popular implementations is the Xbee Shield, developed by M. Yarza at Libelium Corp. in close collaboration with Arduino (Figures 4a and 4b). It accepts any of the XBee/XBee-Pro radio modules manufactured by Digi Corp which can be configured to support Mesh and Star networks or used as a wireless serial/USB replacement.

Libelium’s XBee shield

Figure 4. Libelium’s XBee shield allows MaxStream’s XBee/XBee-Pro RF modules to connect directly to many popular Arduino boards.

CDPD/GSM Mobile Data – Adding a cellular data connection to your Arduino project can be accomplished using a GSM cellular shield. Arduino’s open-source GPRS/GSM shield is based on Quectel’s M10 GSM radio module which responds to standard AT Modem commands via its serial port. Like all GSM radios, it uses a removable SIM card to provide user/system ID and billing information. There are also several manufacturers who make similar products including CuteDigi, HW Kitchen, and Sparkfun, whose cellular shield uses Spreadtrum’s SM5100B quad-band GSM 850/EGSM 900/DCS 1800/PCS 1900 module.

Other applications

The Arduino universe also has shields and dedicated processor boards which support many other wired networking technologies including WiFi, CAN bus, and Modbus. Other developments support local interfaces like SPI and Maxim’s 1-Wire low-speed inter-device signaling protocol. These will be covered in subsequent articles.

Summary

Hundreds of thousands of Arduino boards are already fueling creativity all over the world, If your Arduino design needs to communicate with “outside world” networks there are a variety of “shields”-- daughter/mezzanine cards-- that can provide an Ethernet, WiFi, or CDPD/GSM connection. As we have discussed, using, for instance, an Arduino Ethernet Shield to connect to the internet takes mere minutes; just plug this module onto your Arduino board, connect it to your network with an RJ45 cable (usually not included), follow a few simple instructions and you’re hooked into a world of possibilities.

digikey.com