- Tue May 18, 2010 8:07 am
#101234
[Update: See WiFly Shield code library alpha 2 release (also SPI UART) for the latest release.]
Hi all,
I've been working on a library for the Arduino WiFly Shield for the folks at SparkFun.
The alpha 0 release of the WiFly library is now available for download and testing from: http://sparkfun.com/Code/wifly/WiFly-20 ... 023939.zip
The goal with this library is to make it--as much as possible--a "drop in" replacement for the official Arduino Ethernet library. Once a wireless network is joined the library should respond in the same way as the Ethernet library. This means you should be able to take existing Ethernet examples and make them work wirelessly without too many changes.
The library also provides a high-level interface for the "SC16IS750 I2C/SPI-to-UART IC" used in the shield but also available separately.
Usage
By way of example this is how you connect to a wireless network and use DHCP to obtain an IP address and DNS configuration:
You can supply a domain name rather than an IP address for client connections:
Known issues
This is an alpha release--this means it's non-feature complete and may not be entirely reliable. I've tested it with the shipped examples and it mostly works for me. There are some known issues:
The library is licensed under the LGPL.
What Next?
It would be great to hear back from people who have tested the code with what worked or didn't work for them. Please leave comments in this forum thread. Patches welcome.
Further development is likely to be dependent on response so if this helps you, let us know!
Thanks for your attention.
--Philip;
P.S. I recommend hooking up a 9 volt battery to your Arduino and WiFly then wander around the house--just because you can.
Hi all,
I've been working on a library for the Arduino WiFly Shield for the folks at SparkFun.
The alpha 0 release of the WiFly library is now available for download and testing from: http://sparkfun.com/Code/wifly/WiFly-20 ... 023939.zip
The goal with this library is to make it--as much as possible--a "drop in" replacement for the official Arduino Ethernet library. Once a wireless network is joined the library should respond in the same way as the Ethernet library. This means you should be able to take existing Ethernet examples and make them work wirelessly without too many changes.
The library also provides a high-level interface for the "SC16IS750 I2C/SPI-to-UART IC" used in the shield but also available separately.
Usage
By way of example this is how you connect to a wireless network and use DHCP to obtain an IP address and DNS configuration:
Code: Select all
From then on you can use the Client and Server classes (re-implemented for the WiFly) mostly as normal.#include "WiFly.h"
void setup() {
WiFly.begin();
if (!WiFly.join("ssid", "passphrase")) {
// Handle the failure
}
// Rejoice in your connection
}
You can supply a domain name rather than an IP address for client connections:
Code: Select all
You can also retrieve the current IP address with: Client client("google.com", 80);
Code: Select all
This release of the library comes with three examples: Serial.println(WiFly.ip());
- WiFly_Autoconnect_Terminal: reimplementation from tutorial
- WiFly_WebClient: Ethernet WebClient demo with small WiFly changes
- WiFly_WebServer: Ethernet WebServer demo with small WiFly changes
Known issues
This is an alpha release--this means it's non-feature complete and may not be entirely reliable. I've tested it with the shipped examples and it mostly works for me. There are some known issues:
- Only supports WPA networks with passwords. If you have a network without a passphrase then it should work if you supply an empty string (or a dummy passphrase) but I have not tested this. If you have a WEP network you should probably use WPA instead.
If that's not an option then it should be possible to change the library code to set the WEP key rather than a WPA passphrase.
- Incomplete documentation
- Only tested with WiFly firmware version 2.18--earlier or later versions may or may not have issues.
- Only DHCP is supported--you can't specify an IP address and DNS configuration directly.
- There are some situations (exact cause unknown but often it seems to be after initial programming) where the WiFly will fail to respond to requests. You may need to power-cycle the Arduino or try refreshing the page in your browser if it's acting as a server.
- There's a limit to how quickly you can refresh a page when acting as a server--this is because the library doesn't handle dropped connections well at present. You can generally tell from the lights on the unit if it's busy. (This is particularly obvious when a using a web browser (rather than something like 'wget') because after the page is loaded the browser makes an immediate request for the favicon. Once every five seconds or so should be fine depending on how big the page is. (This seems worse with Safari than Chrome.)
- None of the non-ethernet capabilities of the WiFly are yet exposed e.g. network scans, signal strength information etc.
- The code isn't very robust for error states--in general it will hang rather than return useful information.
- We only have a 9600 baud connection between the Arduino and WiFly it should in theory be possible to be much faster.
- Passphrases or SSIDs that contain spaces or dollar signs ($) will probably not work.
The library is licensed under the LGPL.
What Next?
It would be great to hear back from people who have tested the code with what worked or didn't work for them. Please leave comments in this forum thread. Patches welcome.

Thanks for your attention.
--Philip;
P.S. I recommend hooking up a 9 volt battery to your Arduino and WiFly then wander around the house--just because you can.

Last edited by follower on Thu Dec 16, 2010 6:20 am, edited 2 times in total.