PART 2 – The Microcontroller
Like most electronics hobbyists, I’m a big fan of the Arduino. Power, flexibility, expandability all in an easy to use form. The first time I ever used one, it was like I had discovered a whole new way of making my electronics interface with the real world. But, it’s easy to reach in your bag of tools and grab an Arduino — even when it’s the wrong tool for the job. Given it’s direct lack of wireless interfacing capabilities, I would have to buy Wifi or XBee for the Arduino. Not the option for me.
Instead, I chose to move the basic end-unit interfacing out to the garage and keep the brains and the user interface on my existing linux server. The WiFly gives me that.
The WiFly a simple, small drop-in module designed to replace the functionality of an XBee with a 802.11b/g radio. The 802.11 output power is even user-configurable. An “XBee killer” someone called it. It features 8 GPIO pins and 3 analog (ADC) pins. It does Wifi out of the box with minimal configuration. Like many microcontrollers, however, it is 3.3v instead of the more user-friendly 5v. I chose to purchase a 5v interface from CuteDigi for $7. With this interface, I can toss it on my standard breadboard and use the basic 5v digital knowledge I already have — sometimes, I don’t like to learn when I’m trying to learn.
Setup is easy:
Plug 5v into pin 1, ground into pin 10. Tie pin 8 to high to enable adhoc networking mode.
When the module comes up, it is already broadcasting an SSID:
I use the free version of MochaSoft’s telnet client. Nice program. If I needed it for more than 30 seconds to set up one of these, I might actually buy it. In ad hoc mode, the WiFly will assign your iPhone an IP address. You need to set up your telnet session to connect to 169.254.1.1, port 2000 (the WiFly default in ad hoc mode).
NOTE: In firmware revisions 2.45 and later, ad hoc mode now assigns an IP address using dhcp instead of auto IP, so the destination address for configuration is now 188.8.131.52. (thnx to Vince for finding this)
The config is shown above. I use WPA2/PSK, so setup was a whopping 4 commands for me:
$$$ (enter command mode) set wlan auth 4 (WPA2/PSK mode) set wlan ssid ABC123 (obviously, use your ssid) set wlan passphrase 0123456789 (use your WPA2 key) save
If you use WEP (shame on you!!), your config is a little different. You’ll use a value of 1 for wlan auth, and instead of
set wlan passphrase xxx use
set wlan key xxx
Disconnect power, unhook pin 8 (turn off ad hoc mode), and reconnect power. Give your module at least 30 seconds to find and join your network. 30 seconds later, I look in /var/lib/misc/dnsmasq.leases and there is my module:
1326462274 00:06:66:71:cf:6e 192.168.xxx.108 WiFly-EZX *
Now wasn’t that easy!!!