Menu
If you are trying to add Wifi connectivity to an existing Arduino project or have serious aspirations for developing a Internet of Things (IoT) solution, Arduino + ESP8266 wifi module is one of the top choices. Especially the Nano because it is super cheap (<$3) and is very small in size. Using some sort of web-server directly on ESP8266 (e.g. via Lua) doesn't cut it due to the lack of IO pins on ESP8266. You can get a full IoT node out at under $12 with a few sensors, Arduino Nano and a ESP9266 module (excluding the power supply).
![]()
Inspite of a plethora of posts online it turned out to be very hard for me to get this to combination to work. I spent atleast 3-4 days until I actually got this right. The main problem I see is that a lot of the solutions online are actually down-right incorrect, not-recommended or for other similar boards (e.g. Arduino Mega). Also there are a few gotchas that were not commonly called out. Before I start let me get all of those out of the way
There have a request from the customer on how to make the Xbee WiFi in AP mode. It means you can connect to Xbee WiFi directly without. Reference Home. Corrections, suggestions, and new documentation should be posted to the Forum. The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.Code samples in the reference are released into the public domain.
As mentioned above I first set the ESP8266 BAUD rate to 9600. If yours is already 9600 then nothing to be done, if not you need to make the following connection
PC (USB) <-> FTDI <-> ESP8266
Then using specific AT commands from the PC set the 9600 BAUD rate on the ESP8266. I used the following circuit. Where the connections are as follows
FTDI TX â> Via voltage divider (to move 5v to ~3.3v) to ESP8266 RX (blue wire)
FTDI RX â> Directly to ESP8266 TX (green wire). A 3.3v on Nano I/0 pin will be considered as 1. FTDI GND to common ground (black)
ESP8266 GND to common GND (black)
ESP8266 VCC to 3.3v (red) ESP8266 CH_PD to 3.3v via a 10K resistor (red)
Power supply GND to common GND
PC to FTDI USB.
One that is set bring up Arduino IDE and do the following using the menu
In the serial monitor ensure you have the following set correctly. The BAUD should match the preset BAUD of your ESP8266. If you are not sure, use 115200 and type the command AT. If should return OK, if not try changing the BAUD, until you get that.
Then change the BAUD rate by using the following command, and you should get OK back
AT+CIOBAUD=9600
After that immediately change the BAUD rate in the serial monitor to be 9600 baud as well and issue a AT command. You should see OK. You are all set for the ESP8266.
This step should work for Uno as well. Essentially make the same circuit as above, but now instead of FTDI use an Arduino. I used pins 8 and 9 on Arduino for the RX and TX respectively.
Even though I could easily run AT commands with the PC <->FTDI <-> ESP8266, I ran into various issues while doing the same programmatically in PC <->Arduino <-> ESP8266 setup. So I wrote the following very simple code to pass on commands I typed in the PC via the Arduino to the ESP8266 and reverse for outputs.
The code is at GitHub as https://github.com/bonggeek/Samples/blob/master/Arduino/SerialRepeater.ino
With this code built and uploaded to Arduino I launched the Serial monitor on my PC. After that I could type commands in my Serial Monitor and have the Arduino pass that only ESP8266 and read back the response. I can still see some junk chars coming back (in RED). All commands are in Green and could easily enumerate all Wifi in range using AT+CWLAP and even connect to my Wifi.
â¡ PagesFavoritedFavorite8
Introduction![]()
Digi's XBee WiFi modules are a nifty, all-in-one solution to get your project connected to a wireless network and up into the
An XBee WiFi Module with Whip Antenna. They're also offered with PCB antennas and RPSMA and U.FL connector options.
Aside from talking over a different wireless standard, these modules work just like any XBee. You can set them up using XCTU (which also helps get it connected to a network). You can toggle I/O pins, read analog and digital inputs, and set the module to sleep. They can operate completely on their own, without the need for an external controlling microcontroller. That said, if you want to hook up an Arduino, or another processor, it can be easily done through the serial port.
You can use these modules just as you would any other XBee -- to set up a local wireless serial gateway. One XBee WiFi module can easily talk to another, as long as it has the local IP address of the other.
But these modules have another, more unique application: to make Internet-of-Things projects super-easy. Using the Etherios(TM) Device Cloud service, you can quickly get them connected to the Cloud, where they can publish data and receive commands as well.
Covered in This Tutorial
In this tutorial we'll provide a quick overview of the XBee WiFi modules. We'll then go over some examples. We'll show you how to use XCTU to connect them to a nearby wireless network -- including setting the SSID and encryption protocols.
In the last example, we'll show you how to connect the XBee WiFi up to the Device Cloud. This allows you to control the XBee through a web app loaded up in your web browser. You could control your XBee from across the sea (or from the table across your room).
Required Materials
To follow along with this tutorial, you'll need the following items:
Suggested Reading
An Overview
The XBee WiFi modules all share the same footprint and pinout as most 'normal' XBees. They've got 20 through-hole pins, each spaced by 2mm. The pin functions range from power input to GPIO to analog input to SPI. Here, from the datasheet, is the table of pins and their function:
XBee WiFi Pinout table. Click to embiggen.
XBee WiFi modules can be connected to another microcontroller via their serial port, but what makes them special is they've got a whole host of I/O pins of their own. An XBee alone can toggle LEDs, or motors, or relays, and it can read digital or analog inputs as well. We'll take advantage of the XBee I/O capabilities in the To the Cloud! page, connecting LEDs and buttons directly to the little WiFi module.
Choosing an Antenna
There are a variety of XBee WiFi modules, each with their own antenna termination. Two of the module have integrated antennas: the PCB antenna and wire (whip) antenna. These are the best choice if you're looking for cheap, but they'll also have less range.
XBee WiFi modules with PCB antenna (left) and whip antenna (right). No external antenna needed!
If you need more range, consider going with the modules with a U.FL connector or an RPSMA connector. Either of these will require an compatible external 2.4GHz antenna.
XBee WiFi modules with a U.FL (left) and SMA (right) antenna connector.
For the U.FL version, the Adhesive 2.4GHz antennas make a nice, low-profile choice. For the SMA version, duck antennas (large and regular) make a nice, stylish choice.
Choosing a Breakout Board
The easiest way to use these modules is to plug them into a mating breakout board. For the next pages of this tutorial, we recommend you get an XBee Explorer, which will let you communicate to the XBee from your computer. The Explorers come in mini-B USB, USB Dongle and RS-232 Serial (if you've got an ancient computer with a serial port) versions. Any of the three will work!
As alternatives to the USB and Serial explorers, there are more simple XBee breakout boards. There's theXBee Breakout Board, which simply breaks out the 2mm-spaced XBee to a more breadboard-friendly 0.1' pitch. Then there's the XBee Explorer Regulated, which breaks out the pins and has onboard voltage regulating to help mesh with the 3.3V XBee. Either of these are great for embedding into a project, but may be a little more difficult to interface with your computer.
On the next few pages we'll show you how to use the XBee WiFi with XCTU and Digi's Cloud Service. This isn't the only way to use these modules, but it's the easiest to get them up-and-running quickly. If you follow along, you can very easily have an XBee communicating with the 'cloud'.
Using XCTU
XCTU is Digi's XBee configuration software. It makes communicating with XBees very easy, and provides a nice interface to modify all of the module's settings. When using it with the XBee WiFi's, it even provides a WiFi network scanning and connection interface to make connecting to networks a breeze.
The current release of XCTU is available on Digi's website, unfortunately it's only available for Windows. For Mac OS X users, there is a beta version of XCTU 6.0.0 available, which we've tested and found to work flawlessly with the XBee WiFi's. (Windows users can check it out too, it's pretty slick.) Go ahead and download XCTU to follow along.
For this section we'll also assume you have an XBee connected to your computer via a USB Explorer or something similar. The Explorer should have enumerated as a COM port on your computer. This is the port we'll use to communicate with the XBee.
Connecting to a WiFi Network With XCTU
Before we can begin using the XBee WiFi, we need to set it up to connect to our WiFi network. This is a process made simple with XCTU. Follow the steps below:
Yay! What now? There are a few directions you can go:
Communicating with Other XBees
If you've ever used XBees before, you probably think of them as easy-to-setup wireless transceivers. Two XBees, configured correctly, can seamlessly pass data to each other from one serial port to another. XBee WiFi's are no different!
Following that same set of steps, you can set up a second XBee WiFi module to also connect to your wireless network. It'll get a unique IP address (usually assigned via DHCP). Take note of that.
To setup two XBees to communicate to each other, you'll need to modify the DL -- Destination IP Address -- of each to the other XBee. You can open a second XCTU window, or configure each one at a time.
Imagine two XBees connected to a computer, each with it's own USB explorer and XCTU window open. If you want to configure them to talk with each other, set the 'DL' property of each, to the other's IP address.
Then you can click over to the Terminal tab to type characters and have them sent from your computer, through one XBee, into the other XBee and out to a second terminal.
Another optional application for these modules is to use them on the cloud. Digi's Device Cloud service makes this very easy. Click over to the next page to see an example setup.
To the Cloud!
XBee WiFi's are built to enable simple communication with Device Cloud by Etherios (TM). The Device Cloud service allows you to interface your XBee WiFi with the web, where you can control the I/O pins and read its status from the comfy confines of your web browser (anywhere in the world!).
Now, Device Cloud is a paid service, but it's pretty reasonably priced (down to $0.50 per device per month). They also provide a free 30 day trial if you just want to try it out, which is what we'll do here.
Setting up Device Cloud
To begin, we'll need to set up the Device Cloud to communicate with our XBee WiFi. Follow the steps below to set this up:
Here you can view and control just about everything as it relates to your XBee. You can set pins direction and value in the Input and Output Settings tab. Try setting a pin to 'Output High', then click
Save . The pins should have been driven to 3.3V, but how do you know? Time to whip a circuit together!
Take an Circuit Assembly Break!
Here's the circuit we'll use to get the most of XBee's example cloud dashboard. You don't have to hook up every part, but we recommend at least trying the LED connected to pin 13.
The schematic and breadboard diagram for the cloud example. Click to embiggen!
You'll still need to power the XBee WiFi module. It can remain in the XBee Explorer, or you can plug it into a separate XBee Breakout Board. Here's an image of our hookup using:
Now that we've attached some buttons and LEDs, it's time to take it to the cloud!
Setting Up XBee Dashboard
You can use Digi's Example App to test out your Device Cloud setup. Follow these steps to get up-and-running:
Play around with it! Try turning the LED on remotely. Then read some buttons and potentiometers. Pretty cool! Now ask a friend from across the ocean to do it. Even cooler!
If you want to build out your own app, all of the required code is viewable by clicking the
</> button on a widget. It looks like everything's hosted on Digi's GitHub page, which we're huge fans of.
Resources and Going Further
Now that you've taken your XBee to the cloud, what nifty Internet-of-Things app are you going to make? If you need any help, or this tutorial didn't answer all of your question, consider checking out these resources as well:
Going Further
If you need some inspiration, or just want to keep reading tutorials, check these related guides out:
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |