WiFlyHQ: A new library for the WiFly RN-XV

dhunt:

ndanl:
hi, I have the usb weather board from sparkfun and I am trying to get this RN-XV WiFly Module - RP-SMA Connector - WRL-11047 - SparkFun Electronics to get it work but after uploading the httpserver example all I get is this:

Starting

Free memory: 1337
setPrompt failed
Failed to enter command mode
Failed to start wifly
Terminal ready




what am I doing wrong ?:(

thanks

The XBee hardware interface looks ok, its directly connecting TX and RX to the WiFly at 3.3V.

Those errors indicate that the Library can't talk to the board. Why don't you post the sketch you are using. It might be a simple problem like you're still using software serial when the WiFly is actually connected to the hardware serial interface, or maybe the baud rate doesn't match the rate set in the WiFly module.

hm, i think that my usb weather board is damaged, since yesterday I can't get anything from serial ... so maybe this is why the wifly module is not working ... I will return :slight_smile:

dhunt:

viniciustc:
i did the same thing and work fine using your library, the board still working!

If you're using a 5V Arduino, then yes you will damage the WiFly over time and it will fail. It could take hours, days, or weeks for the failure to occur.

To fix the problem, add a voltage divider (two resistors) between the pin you're using for TX on the Arduino and the DIN pin on the WiFly module. A nice write up on how to do this is available here: http://www.savagecircuits.com/forums/content.php?309-Mixed-Voltage-Systems-Interfacing-5V-and-3-3V-Devices.

I understand. I have a Arduino Uno rev. 2. Which wireless shield I need? Or anyone will give the 3.3V?

Thanks for the reply! =]

I've posted some shield options on the wiki here Home · harlequin-tech/WiFlyHQ Wiki · GitHub.

For any XBee shield you are considering, check the schematic for the shield and make sure it has decent level shifting on the DIN pin to the module. Other nice-to-have features are the ability to connect the USB port directly to the module and the ability to switch the serial interface between hardware serial and two other digital pins for SoftwareSerial use.

Thank you very much!

The official arduino wireless proto shield with sd slot has a switch so you can talk directly to the RN-XV via usb... Might be a good idea to include it.

Waltermixxx:
The official arduino wireless proto shield with sd slot has a switch so you can talk directly to the RN-XV via usb... Might be a good idea to include it.

http://arduino.cc/en/Main/ArduinoWirelessShield

Thanks I've added it to the wiki. I assume you have one and its working with your WiFly?

im really glad someone took the time to write a library for this. i live in the netherlands, and i just wanted to be sure that
[this](http://" www.iprototype.nl/products/components/communications/RN-XV-WiFly-Module ") module combined with [this](http://" www.iprototype.nl/products/arduino/shields/xbee-shield") breakout works in combination with the Wifly HQ library. can anyone confirm? I want to use Arduino as a websocketserver using this!

supermaggel:
im really glad someone took the time to write a library for this. i live in the netherlands, and i just wanted to be sure that
[this](http://" www.iprototype.nl/products/components/communications/RN-XV-WiFly-Module ") module combined with [this](http://" www.iprototype.nl/products/arduino/shields/xbee-shield") breakout works in combination with the Wifly HQ library. can anyone confirm? I want to use Arduino as a websocketserver using this!

Those links are a bit broken. But the two items look ok ( sorry I don't understand the language). I think with that XBee shield you will need to modify it if you want software serial support ( e.g to make debugging easier), by cutting off pins 0 an 1 and soldering jumper wires in their places so you can connect the WiFly's serial port to some other digital pins.

I added a WeSockets client example sketch to the WiFlyHQ library here: WiFlyHQ/WebSocketClient.ino at master · harlequin-tech/WiFlyHQ · GitHub. It should be just as easy to create a WebSocketServer. A bit more effort is needed to add key support.

I've noticed that when sending large amounts of data it takes twice as long as you might expect. You have to send a buffer serially to the module, then wait for it to send it to the remote host on the internet. You cannot do both at once, so it takes more than twice as long. At 460k baud you might only get 5-10K bytes / sec. It doesn't seem to matter what is the data rate of Wifi. It seems like it needs a reply from the FTP host before you can send the next buffer via Serial. Do your results match mine when testing?

sbright33:
I've noticed that when sending large amounts of data it takes twice as long as you might expect. You have to send a buffer serially to the module, then wait for it to send it to the remote host on the internet. You cannot do both at once, so it takes more than twice as long. At 460k baud you might only get 5-10K bytes / sec. It doesn't seem to matter what is the data rate of Wifi. It seems like it needs a reply from the FTP host before you can send the next buffer via Serial. Do your results match mine when testing?

I haven't finished the FTP feature, but I'll do some performance measurements when I do. Most likely this weekend.

I have a question - do you have plans to support flow control? I'm losing bytes while ftp-ing large amounts of data at high speed from Arduino.

felis:
I have a question - do you have plans to support flow control? I'm losing bytes while ftp-ing large amounts of data at high speed from Arduino.

Do you have a suggestion for how to implement hardware flow control on an atmega328p?

You may have a poorly matched baud rate selected based on the crystal speed on your arduino. Here's a nice break-down of the rate errors for different crystal speeds: http://www.wormfood.net/avrbaudcalc.php. You might get better results if you switch to a 14.7456 Mhz crystal.

The WiFly datasheet claims that you can use rates above 115200 if your packes are uniform and you ensure the last packet has been sent before sending the next. So you may have some options there.

Another problem may be that the RX serial buffer is overflowing before yor sketch empties it. Optimizing the sketch and/or increasing the size of the serial buffer may help.

I'm sending data, not receiving. That's how I do it. I pick a digital pin, make it an input and connect CTS to it. I configure flow control on WiFly. in write() I read the pin and don't send until it's low. It can easily be done by modifying write(); I just though it would be nice to have it configurable instead.

[EDIT] I meant RTS, not CTS, sorry. Also, when you have flow control enabled, tie CTS to ground, otherwise you won't be receiving anything from the module's UART. You can also drive CTS if you need flow control in this direction. [/EDIT]

I have implemented my own "flow control" at 460k baud. It is also required when using FTP at 115k. You must know the default buffer size for each baud rate. You send that much at a time, then wait x milliseconds. Find x by trial and error. This is exactly the problem I'm referring to above. It appears to depend on the internet connection speed, ping time, and ISP. But not the Wifi maximum bitrate as much. My solution works great. Is there any way to decrease x? I'm only able to get 5K/sec at 460k.

400 kbaud should be 50kB/sec. I would have so many applications for this if I could decrease x to get the average rate to 10k bytes/sec. Any ideas how? Is it waiting for a response from the router after each packet sent? Or from the FTP server? I would instead by happy if I could get to 10k even with a 1% data loss. 5% loss? Will experiment and post my results here.

dhunt:

Waltermixxx:
The official arduino wireless proto shield with sd slot has a switch so you can talk directly to the RN-XV via usb... Might be a good idea to include it.

http://arduino.cc/en/Main/ArduinoWirelessShield

Thanks I've added it to the wiki. I assume you have one and its working with your WiFly?

Yup it's the model I included in the title of my threads... :slight_smile: the one you helped me with my Internet dog treat dispenser... :slight_smile:
cheers and thanks again for your help with that :slight_smile:

Has anyone figured this out? Someone must want to send FTP data fast. Please post working code with speed test results.

I'm having trouble with your httpserver example on github. Should I download the newest library again? Mine download is weeks old.

Got GET request
Sent index page
Unexpected: GET /favicon.ico HTTP/1.1
Sending 404

It displays the index page just fine in my browser, then nothing.
Please help!

ok guys so I've got this RN-XV WiFly Module - RP-SMA Connector - WRL-11047 - SparkFun Electronics module and this SparkFun Weather Shield - DEV-13956 - SparkFun Electronics board and I use this // Revision history// 1.2 Update all code to be compatible with Arduino 1.0 20 - Pastebin.com sketch, can anybody help me implement the httpserver based on the sketch I have ?

my wireless router use wpa2

thanks

Hi!

I'm trying to get any of the example sketches working from the library, but i seem to get the same error
that ndanl got:

Starting
Free memory: 1283
setPrompt failed
Failed to enter command mode
Failed to start wifly
Terminal ready

I use this board and this module with the WiFlyHQ library.
I think it's the baudrate of the xbee that's not right, but how do i enter command mode? i have 2 tiny microswitches on the breakout board,
one for switching between XBEE/USB and one for RUN/PROG.

It seems to me that if i should set it to XBEE and PROG i should be able to enter command mode with '$$$' right?
and then issue the command set baud rate 115200 for example?

The sketch i'm using is the example HTTPSERVER sketch, so i've not included it.

Cany anyone help me? Thanks a bunch! i can make a photo of my setup if that's what's needed. but i just connected the module to the shield,
and the shield to the arduino. i've decoupled all of my other electronic stuff...

[EDIT] I've tried different baudrates, from 9600 up to 230400, doesn't make any difference.
Also, switching between XBEE/USB and RUN/PROG doesn't seem to make any difference either.. i'm at a loss what i can do to analyse / debug this :confused:

[edit2] i've also tried to just enter command mode, but thats not working either.. how can i know for sure that i'm connecting to the wifly module? or is this why you guys all use the softserial thing? because switching just doesnt work well?
if i want to use softserial, how should i be able to read the output on my mac? is that done with these FTDI - USB Boards? help!