Our Blog

by popular request: WiFLY Shield + Ardumote

UPDATE: this is from apr 2012, most of this code and the ref links are gonna be out of date if you’re actively debugging, just FYI

/****************************************************/
/* wifly + ardumote                                 */
/****************************************************/

to those who’ve been asking via youtube, here’s some notes on this wifly thing – if you use any of it please be sure to properly credit the people I stole most of this good stuff from, as you’ll see they deserve the credit not me – here’s a wrap up:

This device joins wifi-RF connectivity with Mitch Altman’s brilliant “TV B Gone” circuit. The circuitry is all contained in an inconspicuous utility panel box that can (theoretically) be stuck onto the wall of any bar or restaurant where you might want to (theoretically) have discreet control over their televisions.

How to use the wifly shield:

There are several pieces of the puzzle, and layers of the network communication that need to be aligned before you can send signals back and forth:

  1. Arduino 1.0 vs 0.22 and older versions – Arduino 1.0 came out recently and with it came a number of syntax, command and library changes that break 99% of the examples of wifly implementation. Before you go pulling your hair out –> search for code upgrade posts like this example that shows how to fix BYTE no longer being accepted in serial commands. E.g., the amazing example on the SparkFun WiFly shield site completely breaks all over the place if you’re running a recent version of arduino – this is also a natural segue into the next issues, about all the new libraries, as well as serial vs SoftSerial.
  2. Since the recent upgrade to 1.0 there have been no less than 4 different people all attempt libraries to implement sketch-level wifly shield interfaces – the best are still the original pre-1.0 libray WIFLY (useful for the debugging tools that let you go straight to command line with the wifi module, so you can reset it to defaults or tell it change RF modes etc BUT breaks at 1.0 so you have to have learned the work-arounds to use it). Next is the brand new WiFlySerial library (used here in this exact context by someone) , which tries to port the many serial tools that came in the Ethernet library over to the wireless world – these are great but then you also have to learn about how to use softSerial and NewSoftSerial because in this instance you’re using up your serial comms between arduino and host, you STILL need serial comms between the UART chip in the RF module and the arduino so you can receive and take commands and signals. Others, like WiFly HQ seem to work for their creators but I had zero luck and much frustration trying to implement them.
  3. The next decision you have to make is how to config the module – the WifFly RN manual is detailed and very useful, outlining how the different RF modes in the wifi module can be activated (must be done so through the module’s command line interface either by telnet’ing in or sending serial commands through arduino (both have pros and cons). You can dictate ALL KINDS of useful RF behaviours such as auto-join, adhoc network creation, SSID/Pass credentials, static and auto IP assignments, ports and much much more. For my purposes I really wanted to create an adhoc network so that no SSID credentials were required, however time was scarce and I ended up just going with the WPA2 settings. It’s quite simple to change the credentials for whereeever you would (theoretically) stick the box, as long as it’s WPA. It can also be set to WEP or solely UDP. 
  4. The above all represent lots of trial and error and research, I have 12 or so different versions of sketches and library examples saved in my files, but I hit a big breakthrough when I saw this guy’s RC car project – knowing all the pieces of the puzzle above I was able to quickly parse his implementation, upgrade his broken bits into Arduino 1.0 and then send signals over UDP. This was the really big breakthrough for me. We emailed back and forth a couple times, he’s a great guy, here’s what he said:

    Hey Nick, thanks a lot for your comments on my site. I replied to you on the post page, this is what I wrote:“Nick,You assumed correctly: I spent about 2 hours in Arduino 1.0 and decided to switch down for now. I will eventually make the transition, but like you said, at present it is a madhouse.As for being in Toronto: I’m there from time to time. Do you know Creatron? It’s a good place to get components. I have a feeling you know about it. By all means we might bump in to each other!And thank you for your compliments! To be honest what I’m most happy about is that this project is being found useful by people like your self. I’m very glad I could help.I like your vid!”And really, I thanks for your kind words and I’m glad I could help.As for using the code: I just added a “permissions” section to the Arduino Wifly Mini post. It says:“I’ve been asked if the code can be used, modified, and republished. The answer is yes! Feel free to use the code however you like. My only request is this: if you use the code verbatim or you found it helped you substantially, please just make a note of it somewhere in your published project. Thanks! And have fun. :) ”So whatever you want to do Nick! Go ahead and have fun.Take care and all the best,Blair

    What a seriously awesome guy.

  5. Breathrough FINALLY!!

    SO: the REAL lesson is, go check out Blair’s site AND read the entire Roving Networks WiFly manual BEFORE you try and code ANYTHING. You will save a LOT of time. Also, if you have a way to go back to Arduino .22 before you try the WiFly shield you will be much better off, although that has it’s own downsides. Note that while the RF module manual has clear command structures, it can be VERY tricky to debug, you NEED to keep a close eye on the serial monitor – e.g. after a half day trying to debug why it wasn’t receiving simple UDP pings, it turned out that it wasn’t properly declaring and saving network settings – only discovered this by chance, having loaded another connection test, then after that re-loading my own udp connection sketch and then noticing that still nothing happened on udp UNTIL it also received a TCP HTTP request revealing hand-shaking with the old sketch, THEN it would listen to the udp signals in the new sketch no problem – it is only by pure chance that I spotted this and if I hadn’t I also wouldn’t have realized that when you command it to *save settings* it does, but those don’t survive a power cycle unless you ALSO manually command it to *reboot* from the command line interface – totally brutal… would have been  lost except for arduino blogs.

  6. HERE IS THE CODE FOR TVFU_nickpagee.ino 
  7. UDP SIGNAL ––> ARDUMOTE IOS APP––>: this was a VERY SIMPLE config, once you have the app you can just config a button w/the settings – honestly this part took about 5mins to fig out once the signals are sending from the wifly module – email me if you’re really stuck I’ll make a vid
Tags:

Show Comments (0)

This is a unique website which will require a more modern browser to work! Please upgrade today!