WiShield Loses Connection

Discussions related to the WiServer add-on code for WiShield. WiServer is a friendly, easy-to-use front end for webserver and webclient usages.

Moderator: shard7

WiShield Loses Connection

Postby aweeks » Sat Mar 27, 2010 6:35 am

Here's my project. I have an electric gate I'm opening and closing by sending a GET request to WiServer. I've written a little iPhone app to send the GET request. Seems to work fine for several hours then the WiShield loses the connection to the access point and won't get it back. If I walk out to the gate, unscrew the cover, reach in and press the reset button it will reconnect and everything will work fine for a while.

I've done some scenario testing and here's what seems to be the case:
- Seems to sustain connection indefinitely with no problems when connected to USB sitting on desk
- Seems to have good WiFi signal with an SNR of around 22db
- Connected to Apple Airport Extreme (Have also tried a couple of Linksys APs with same results)

Couple of unique things that could be clues:
- No 120VAC power in this gate box, only 24VDC. So I built a little power supply and attached it to a shield I've stacked on top of the WiShield. My power supply is 100 uF capacitor -> 7805 regulator -> 10 uF capacitor -> .1 uF capacitor. No heatsink. No idea why this would be a problem, but I'm trying to point out everything non-standard.
- There are other electronics in the gate controller box. Two other RF frequencies. But, operating all the other RF I can't seem to find any combination that causes the WiShield to give up.
- My WiShield is V 1.0. Would 2.0 give me different results? Seems like maybe it's the same chipset with a little more memory than the v1.0 so probably wouldn't make a difference.

My guess is that my problem has something to do with my power supply or with my code. I probably need to isolate the power issue further by switching power supplies, but running an extension cord with 120VAC out to the gate and leaving it for while is sort of impractical. I might be able to figure something out.

So, I thought I'd post my code and see if anyone else has any ideas. Here's the code. I'd appreciate any thoughts.

#include <WiServer.h>

#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2

#define gatePin1 6

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,X,15}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,X,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"myssid"}; // max 32 bytes

unsigned long eMillis = 0;
unsigned int pinState = 0;

unsigned char security_type = 2; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"XXXX"}; // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------


// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {

// Serial.println("Page printing begun");

if (URL[1] == '?' && URL[2] == 'G' && URL[3] == 'A' && URL[4] == 'T' && URL[5] == 'E') //url has a leading /
{

// Serial.println("Close Relay");
pinState = 1;
digitalWrite(gatePin1, pinState);

// Get the time we closed the relay. We use this in the loop to open the relay 1 sec later.
eMillis = millis();

//after having change state, return the user to the index page.
WiServer.print("<HTML><HEAD><meta http-equiv='REFRESH' content='0;url=/'></HEAD></HTML>");
return true;
}

// Check if the requested URL matches "/"
if (strcmp(URL, "/") == 0) {
// Use WiServer's print and println functions to write out the page content
WiServer.print("<html>");
WiServer.print("<a href=?GATE>Actuate Gate</a>");
WiServer.print("</html>");

// URL was recognized
return true;
}
// URL not found
return false;
}


void setup() {
// Initialize WiServer and have it use the sendMyPage function to serve pages
pinMode(gatePin1, OUTPUT);
WiServer.init(sendMyPage);

// Enable Serial output and ask WiServer to generate log messages (optional)
// Serial.begin(9600);
WiServer.enableVerboseMode(true);
}

void loop(){

if ((millis() > (eMillis + 1000)) && (pinState)) {
pinState = 0;
digitalWrite(gatePin1, pinState);
}

// Run WiServer
WiServer.server_task();

delay(10);
}
aweeks
 
Posts: 2
Joined: Sun Mar 21, 2010 1:17 pm

Re: WiShield Loses Connection

Postby SteveF » Sat Mar 27, 2010 5:33 pm

I have a similar problem. In my case the html in progmem and my url appear to get corrupted after 3 to 5 days of running fine. After the corruption occurs the wishield looses connection and does not reconnect. I can't find any memory leaks in my sketch. I know others are having the same result with WiServer.I am using Imac usb 400 port for the power supply. Maybe a power supply issue but I think there may be a memory leak in the WiShield library. I would have much more use for WiShield if I could resolve this reliability issue.

Steve
SteveF
 
Posts: 6
Joined: Tue Dec 29, 2009 8:36 pm

Re: WiShield Loses Connection

Postby GregEigsti » Sat Mar 27, 2010 7:47 pm

Steve, WiServer is not the only way to utilize the WiShield; have you tried one of the other sample app types? What leads you to believe that progmem is being trashed? What debugging have you done that led you to think that progmem trashing might be the case.

I rarely use WiServer because I am more comfortable at the socket level and have run into one problem that I have not been able to fix; but have worked around.

I guess what I am wondering is if this is a WiShield or WiServer software issue (or some other issue).

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: WiShield Loses Connection

Postby GregEigsti » Sat Mar 27, 2010 8:02 pm

aweeks, your code (after a quick glance) looks fine; have you connected a multimeter to your homebrew power supply to make sure that it holds +5 (or whatever)? I doubt that the power supply is the problem but it could be; might be interesting to connect the +5 to an Arduino analog pin, sample the voltage, and return that as part of your web page return (so you could monitor it and look for glitches).

Where are you getting the "SNR of around 22db" reported to you? Is this part of the ZeroG driver code (may be I have never gone looking for it). I would imagine that RF interference could be playing a part - how constant is RF radiation being generated in the enclosure?

I have seen a couple of problems in this area; one where after about a day the WiShield would "hang" when it was the initiator of a socket connection and worked around this by periodically resetting the WiShield (not pretty but works). The other is that a WiShield (using a socketapp) out in the far reaches of my shop will stay online for a while but then drop off. Not sure what the wireless strength is in the shop because that is where I go to get away from computers (and kids) ;)

In my experience socket apps that are connected to remain rock solid for days upon days. And I don't really use WiServer that much.
Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: WiShield Loses Connection

Postby SteveF » Sat Mar 27, 2010 8:18 pm

Hi Greg,

I see the corruption showing up in missing characters and missing text inputs in my webpage. I serial.print my url in the loop, and just before the wishield disconnects I have seen some strange characters and the characters"ico" in my url. My sketch does not use these characters. Is there an icon in wishield memory? I am working on another project this week. I can set up this sketch and send you the results in the following week if you like.

Steve
SteveF
 
Posts: 6
Joined: Tue Dec 29, 2009 8:36 pm

Re: WiShield Loses Connection

Postby GregEigsti » Sat Mar 27, 2010 8:27 pm

How large is the web page that you are returning? The WiShield (and therefore WiServer code) has a very small "output buffer" - maybe if your page is large (e.g. greater than about 400-500 bytes) that is the cause of things blowing up. If you are serving up a largish page maybe you could try a repro with a smaller page to see if that helps isolate the problem?

If serving up large pages is the problem then this is a great find as it may be what is affecting others while using WiServer???

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: WiShield Loses Connection

Postby aweeks » Mon Mar 29, 2010 4:30 pm

GregEigsti wrote:aweeks, your code (after a quick glance) looks fine; have you connected a multimeter to your homebrew power supply to make sure that it holds +5 (or whatever)? I doubt that the power supply is the problem but it could be; might be interesting to connect the +5 to an Arduino analog pin, sample the voltage, and return that as part of your web page return (so you could monitor it and look for glitches).

Where are you getting the "SNR of around 22db" reported to you? Is this part of the ZeroG driver code (may be I have never gone looking for it). I would imagine that RF interference could be playing a part - how constant is RF radiation being generated in the enclosure?


I've put a multimeter on it and while I'm standing there the power seems to be rock solid. Who knows what's happening when I'm not looking. Reading the voltage on an analog port is a good idea.

The SNR info is coming off my access point. An Apple Airport Extreme. The Air Port utility that runs on the desktop reports signal and noise data.

Alex
aweeks
 
Posts: 2
Joined: Sun Mar 21, 2010 1:17 pm

Re: WiShield Loses Connection

Postby John_Ryan » Mon Mar 29, 2010 7:51 pm

Have any of you experiencing connection failure/faults/drops, tried this?

viewtopic.php?f=10&t=150&p=864#p864

It requires modifying WiServer.h and WiServer.cpp - and there's an example of how to use the code in the thread.

Given the number of people, myself included, who experience connection drops where the shield is unable to reconnect by itself, I'm really wondering why this persistent problem hasn't already been fixed. Losing a connection is one thing, but that the shield doesn't or can't reconnect on its own, is incredibly bothersome.

If the only way to fix a dropped connection is to walk over and manually reset the board, then it practically defeats the purpose of using wireless in the first place.

:shock:
John_Ryan
 
Posts: 155
Joined: Thu Jun 04, 2009 11:24 pm

Re: WiShield Loses Connection

Postby GregEigsti » Wed Mar 31, 2010 12:05 pm

The fix for this may be on the way; see the following thread:
http://www.asynclabs.com/forums/viewtopic.php?f=10&t=290

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: WiShield Loses Connection

Postby aom » Wed May 12, 2010 7:54 am

I've been having a strange, repeatable connection problem with the Yellowjacket as well.

My project is currently on-site, so I will try the fixes suggested here (viewtopic.php?f=10&t=150&p=864#p864) and/or here (http://www.asynclabs.com/forums/viewtop ... f=10&t=290) when I have chance to go reprogram the Yellowjacket.

The problem is as follows:

I have a Yellowjacket running the Wiserver, which sends a get request for a PHP file, followed by a get request to a resultant .txt file which has the scraped data I'm interested in. When I was developing/debugging the system, both my development computer and the Yellowjacket were (naturally) connected to the same router. I was able to view the .txt file in my browser to verify its contents, and the Yellowjacket remains connected and able to access the PHP file and write to the .txt file. This was also the case when I was on-site installing the system.

However, now that it's installed, I find it stays connected until I view the .txt file from a remote connection, that is, from a router/AP other than the one the Yellowjacket is connected to. Once I check the .txt file from home, the Yellowjacket doesn't seem to be able to access the PHP file or the .txt file. The green "connected" LED stays on, but it requires a reset to regain the connection and begin functioning again.

I really would like to be able to check that .txt file remotely to monitor the status of the system, as well as not have to return to the site to manually reset the Yellowjacket.

Anyone else have similar troubles? Could this be a file permission problem? I'm going to try the auto reset/init functions mentioned in the other threads in the meantime.

Cheers,
ao.
aom
 
Posts: 2
Joined: Wed May 12, 2010 7:41 am
Location: Ottawa, ON, CA

Next

Return to WiServer

Who is online

Users browsing this forum: No registered users and 1 guest