RN/WiFly 802.11 modules

From HeepyWiki
Jump to: navigation, search

you can control the wifi connection and tcp connection state of the wifly module via GPIOs but you can also just make it sleep all the time and wake up, associate, and connect when it gets a char on the RX port. This would save a lot of pins. Maybe use one to monitor status so we know when it's ready for data... so send it a throwaway char, wait for status line to come up, then transmit real data, and let a timeout put it back to sleep. try to figure out the wifly settings for this tomorrow.

the tiny85 currently seems to be drawing about 5 uA in watchdog sleep mode, which is a bit high. it counts out 37 8-second watchdog periods and then wakes up to do the periodic task (radio or whatever) Each intermediate wakeup just flashes an LED for 10ms.

WiFly settings:

set wlan ssid MYSSID
set wlan auth 4         - be in wpa2-psk mode
set wlan join 1         - auto-join the specified ssid
set wlan phrase MYPASS
set wlan rate 1         - set to 2mbit for better range

set comm idle 10        - close tcp conn when no traffic
set sys sleep 5         - sleep after tcp disconnect

set ip host <ipaddr> 
or set dns name <hostname>
set ip remote <port>
set sys autoconn 255    - connect immediately on wake, and sleep as soon as
                          tcp connection is closed.
set sys iofunc 0x40     - indicate tcp connection status on gpio 6 / pin 15
                          (marked AD5 on xbee breakout) 

once it wakes up and makes a connection, you can send data which will get delivered to the remote end of the tcp connection. you can close the connection from either end, or let it idle out in 10 seconds. to close it immediately,

<250 ms delay>$$$<250 ms delay>sleep\n

PB2 on the tiny85 (pin 7) is connected to GPIO6/pin 15 (tcp conn status) on the WiFly module.