Hi,
I have been writing the a code that reads various sensors and nmea data and sends the info to a webpage(s) via the ethernet shield.
Im using a a Mega and a wiznet 5100 (both chinese/clones).
I had been experiences problems with a delay of when the data would be updated on the webpages, sometimes up to a minute before the page would update, but have I have largely solved he problem by turning off the Serial port (was on for debugging) and has mage a huge difference, page is now updating every two seconds.
I would love to improve it some more and was wondering if I upgraded the shield to the wiznet 5500 chip would I see a big improvement??? or is my problem the cloned board/shield??
Thanks
Tom
Post your code. Use code tags.
edit: If you are using the serial monitor to debug and displaying a large web page, insure the serial baud rate is not slowing you up. Use 115200 baud. If you use 9600, it may take several seconds to display a large web page.
Hi,
code to big to put here, attached instead
Thanks
Tom
test2.ino (13.8 KB)
This will really slow down your web response. I can increase the speed on that download by about 4 times.
if (webFile) {
while(webFile.available()) {
client.write(webFile.read()); // send web page to client
}
webFile.close();
}
Try this instead.
int clientCount;
char tBuf[64];
while(myFile.available()) {
clientCount = myFile.read(tBuf,64);
client.write((byte*)tBuf,clientCount);
}
myFile.close();
Hi,
Thanks SurferTim,
I'll try that tonight when I get home and let you know
Tom
OK. The theory behind this is the client write, print and println each create a separate packet for the data. You are sending one byte with a 48 byte header. I send 64 bytes with a 48 byte header. Much faster.
Well, that worked and didn't work at same time!
Unfortunately it didn't help with how quick the data is updated (in particular the nmea data), but now the webpage (which is on the sd card) itself loads way quicker which is a big help.
Maybe the problem I'm having is just how long it take for thetinygps library to read, encode and then print the message and then for the arduino to update the page with Ajax.??
Or would the newer shield (wiznet55000) be better?
The newest shield may or may not help you. You must find where the delay is happening. Use Serial.println to determine where your sketch is pausing. If the pause is close to a minute, that shouldn't be difficult to find. I suspect your problem is somewhere other than the w5100 shield.
edit: Updating every two seconds isn't bad. How often are you trying to update the page?
Are you accessing the page with an IP or a domain name? It is possible you are experiencing a delay caused by the DNS resolution if by domain name.
I suppose 2 seconds isn't too bad
, I think I'm really just trying to figure out where the delay is.
When serial printing the data is instant which is why I'm thinking the problem is with the Ethernet shield.
I'm using an IP address to access the page, ie just typing the IP address of the arduino into the browser.
I read somewhere that the new shield support high speed SPI, but I really don't know anything about that.
Thanks for your help so far, that little bit of code you wrote really improved my project.