Wireless
This page is about ways to connect have microcontrollers talk to each other wirelessly using radio frequency (RF) communication. RF communication uses radio waves, which are electromagnetic waves, like light, and can transmit energy and information through air, buildings and other materials that typically do not conduct electricity.
Introduction
Terminology
Most of the parts described here are modules. An RF module includes a transceiver, transmitter or receiver IC, as well as a crystal to provide a frequency reference and components that match the IC to the antenna. Many modules contain everything you need for RF communication except the antenna. Some modules have an antenna built in. Properly matching and connecting an antenna to a radio can be difficult if you want to maximize range, efficiency and speed.
nRF24L01+
Serial RF Link
"RF Link" is a generic term for a variety of cheap UHF transmitter and receiver modules that operate on the 315 MHz and 433 MHz ISM bands. The modulation is typically ASK. They provide a very simple interface with a single pin.
RF Link connections can be unreliable and you often need to retransmit if you want to make sure messages are received. If the messages are commands, it might be a good idea to give the messages sequence numbers so retransmissions don't result in duplicate actions, unless of course the commands are idempotent.
On a transmitter, you would write high to the pin to transmit the high amplitude and low to transmit low, and the same signals would then be present on the receiver. In theory these pins can be connected directly to a microcontroller's UART. In practice they must be driven in a particular way to function well, including a specific bit pattern at the beginning of transmissions to prime the receiver's AGC and Manchester encoding to remove DC bias. This Arduino library is recommended for operating RF Link modules. The link protocol is then defined by the library.
The maximum speed is 2400 bps or so and they have very good range because of the low frequency. RF Link modules are particularly suited for short messages over long distances, for example control commands ("turn the relay on") and sensor readings ("the temperature is 26 degrees C").
The easiest way to accomplish full duplex communication is to simply have two modules at each node, a 315 MHz transmitter and 433 MHz receiver, or vice versa. Make sure that two modules don't share the same antenna unless you have some way of multiplexing the antenna.
RF Link transmitter modules require an antenna. If a ground plane is present, you can simply use a 24 cm (315 MHz) or 17 cm (433 MHz) piece of wire, which corresponds to a quarter wavelength. An external antenna is optional on the receiver modules.
Hardware
- Seeed Studio 315 MHz $4.90 for a receiver/transmitter pair
- Seeed Studio 433 MHz
- General information from Seeed Studio
- SparkFun 315 MHz transmitter $3.95 and receiver $4.95
RFM12B and RFM22B
SparkFun sells RFM12B and RFM22B transceiver modules that operate at 434 MHz. Compared to RF Link, these modules are more complicated and communication with the module is with SPI. The RFM22B module has an 8-bit ADC and general purpose I/O pins. Data rates are much higher, up to 256 kbps.
The modules themselves are surface mount. The SparkFun breakout board for RFM22B is very expensive; contact Guan if you want a breakout board.
The transceiver ICs on these modules are comparable to AT86RF212, which operates on 700/800/900 MHz.
Bluetooth Low Energy (Bluetooth 4.0)
Bluetooth Low Energy is a new standard for connecting low powered devices to mobile phones and computers, on 2.4 GHz. Compared with traditional Bluetooth, BLE provides much lower power consumption (months of operation on a coin cell battery) provided that communication only happens infrequently. BLE is suitable for things like control commands and sensor readings (e.g. heart rate monitor), but actually consumes more power than traditional Bluetooth if operated constantly.
On iOS devices, BLE is notable because Apple allows apps to communicate directly with devices without requiring device certification under the MFi program.
Nordic nRF8001 is a cheap slave-only Bluetooth Low Energy module. Their $99 development kit includes several complete modules that include antennas. There is an Arduino library for nRF8001.
There is also a TI part that also provides BLE master support and includes a 8051 type microcontroller, but the development tools are very expensive.
Wi-Fi
Many Wi-Fi modules exist that are controlled via SPI and have a complete TCP/IP stack on board. Wi-Fi on a microcontroller is typically very expensive because the suitable Wi-Fi modules contain a computer that is orders of magnitude more powerful than the microcontroller itself.
Raspberry Pi ($35) and similar Linux ARM boards have USB ports. You can connect a cheap (sub-$10) USB Wi-Fi module and simply use the Linux Wi-Fi and TCP/IP stacks. Trying to use a USB Wi-Fi module on a lesser microcontroller with USB host support is very difficult because of the lack of good stacks.
TP-Link TL-WR703N is Chinese-made "Wi-Fi 3G router" that can often be bought for $20. These routers have a USB port, Ethernet and Wi-Fi built in, can run OpenWRT, and can be hacked to expose the GPIO pins. There are many home automation projects based on WR703N.
Most of this also applies to Bluetooth on microcontrollers.
XBee
The XBee modules by Digi, inc. are designed as a simple platform for experimenting with the Zigbee protocol. Modules can be End Devices, designed to consume very little power by spending most of the time in sleep mode except when a communication is necessary, or to check for incoming messages. Routers are like End Devices but are always on, and can extend the range of communication by forwarding messages that are not intended for them. Finally, there is one Coordinator on the network, which manages accepting new devices onto the network, route management, encryption, and is the default destination for all messages.
XBees tend to be a bit very expensive, and for the most part will not play well with modules that have a different firmware level, even for the same protocol. To update the firmware requires a utility that is only written for Windows, though there are solutions for unixlike command lines if you can get them to compile.
XBees have built in microcontrollers and can operate alone in many applications, with its own ADC and GPIO pins. The popular website Hack a Day once had regular posts complaining about the unnecessary pairing of XBees and Arduinos.
RadioBlock
RadioBlock is a relatively new Kickstarter project to create a module that pairs a complete AT86RF212 AT86RF231 based module, including antenna, with an LPC1114 ARM Cortex-M0 microcontroller.
There are two versions of the module, a self-contained module powered by a coin cell battery, and a version that is primarily designed for interfacing with a microcontroller. The software stack includes mesh networking and the ability to forward messages throughout the mesh. This means that one module could have sensors directly connected to the LPC1114's ADC pins, and send readings through a series of other modules throughout the house to one that's connected to the Internet.
XBees are also supposed to do mesh networking using the 802.15.4 standard, but models that support it are even more expensive than regular XBees.
802.15.4, ZigBee and 6LoWPAN
802.15.4 is an IEEE standard for personal area networking, mainly on 2.4 GHz and bands in the 900 MHz range. Cheaper XBee units implement this standard, as do many other 2.4 GHz modules. ZigBee is a mesh networking standard layered on top of 802.15.4. 6LoWPAN is a standard for IPv4 and IPv6 on top of 802.15.4.
Roll your own
Unsatisfied with the cost, features or built-in microcontroller of any of the existing offerings? Roll your own! Many RF transceiver ICs have detailed datasheets with a typical application circuit that you can create to make your own module.
If you ship your own little module as part of a product in the US, it must normally undergo certification under Part 15 of FCC's rules. The rules are unclear for experimental radios for hobbyists. It would be a good idea to get a Amateur Radio license because amateur radio operators are always allowed to construct their own radios (that comply with the rules of course) and have expanded privileges on the ISM bands.
Receivers are often much more expensive and complicated than transmitters.
Transceiver ICs
Antenna
You can always just use the appropriate length of wire.