You are viewing an older revision! See the latest version
wifly
Introduction¶
The WiFly is Roving Network's series of wifi modules. Comprehensive documentation etc. can be found at Roving Network's site here. An mbed WiFly library can be found here.
The WiFly series of modules provide a reasonably simple interface to the internet over a wireless network. Standard communications are through an UART interface (GND, PWR, TX & RX), which is the minimum amount of connections needed. Configuration and use of on-board functions are done in command mode, which is enabled through UART by entering a pre-set command, default '$$$' or using TELNET. The module features its own TCP/IP stack as well as UDP etc. Please refer to the Roving Networks datasheet for pin layouts.
Breakout boards available to order, with additional SPI interface added in (although the board width may be for another single-board microcontroller and hence unwieldy).
The module is capable of functioning as both a server and a client, and can function in both infrastructure and ad-hoc modes. WEP-128, WPA-PSK (TKIP) and WPA2-PSK (AES) are all supported.
Getting started¶
First determine which pins of your WiFly module are power, ground, TX & RX. These should be connected to the mbed's pins accordingly. Make sure you haven't got the tx and rx mixed up. Murphy's law says this will be the case if you do not check beforehand. If you receive no response from the module, this is the case. For this stage I wrote a simple mbed program to pass input from a terminal on the pc to the device - program. If you are experimenting, it is advisable to have a few hotkeys that will execute commands you use often.
Information
If everything is connected correctly, you should get the response "CMD" when you put in three consecutive dollar signs "$$$". The module is now in command mode. To return the module to this factory state, if you want to, you should enter in command mode "factory RESET\r".
Otherwise, some commands will change the config file that is loaded on power on, or the 'save' command will save the current state to the config file.
Another way of communicating is by putting the device into ad-hoc mode and doing it wirelessly. This can also be achieved by driving certain pins high/low. The steps to be taken for this are in the user manual.
From this command mode, various settings can be changed and functions altered. Using the 'Send' function when the device is in command mode, the module can be configured to do a multitude of things.
Useful stuff¶
Please be sure to read the Wifly datasheet and API of Wifly class, if you are using it, for maximum ease of use.
#include "mbed.h"
#include "Wifly.h"
Wifly * wifly;
Serial pc(USBTX, USBRX);
int main()
{
wifly = new Wifly(p9, p10, p20, "network", "password", true);
if(wifly->Join())
pc.printf("network joined!\r\n");
else
pc.printf("join failed!\r\n");
}
Using the libraries provided, communications should be possible in lieu of a physical Ethernet plug using the TCP/IP stack in the ethernet section of the cookbook...?
Note the Wifly code is not interchangable with the ethernet; with the ethernet code, the TCP/IP stack is on the mbed, and with the wifly, the stack is on the wifly module itself.
Things to be aware of:¶
- If sending data using the on board TCP/IP stack, it might be necessary, if you are experiencing problems, to change the flush size/timeout to the maximum, or it sends the data as it receives it.
- Sometimes an unresponsive module will need an external reset (there is also a watchdog), might need to be part of a design to guard from total failure. This is not uncommon when the server is very unreliable (when you are using your own) or there is some disconnection between the module and the router (due to intefearance/distance)
- Need to be aware of times to complete commands such as connecting to a network, as DHCP can take a while among other things. Rather than looking for ascii confirmation of things like an open TCP connection, it may be easier to configure one of the GPIO pins to do the job.
Stuff the WiFly can do¶
- Communicate over wifi
- Upgrade its firmware over TCP
- Sleep
- Be controlled completely using GPIO pins.
- Operate in wifi or ad-hoc mode
- Operate as a standalone server
Libraries for the module:¶
Projects with this module:¶
- m3pi wifi control
- Pachube data logging
- wifi computer unlock
- wifi strength finder
- wifi open network stuff?
- Internet of things
Related:¶
-HTTP client -