Offline
Newbie
Karma: 0
Posts: 7
|
 |
« on: January 24, 2013, 07:02:49 am » |
Hi,
I just got my nice Arduino Uno and the ethernet shield. I Want to make a website hosted on the shield to control som leds. but when I started to make a simple one LED on and off test website I noticed that I used almost half of the Max sketch size. When I bought the Arduino I didn't realize that there would be a limit to the sketch size ( at least not that fast).
So my question is how (if possible) do I increase the Max sketch size is there something I can buy/exchange to get say 1-5 MB
I have the SD slot can that be used? if so how do I go about it or will the MAX sketch size increase if I just place a SD card in there?
I hope my question isn't stupid because all of you here knows the answer already.
Thanks,
Patrikk
|
|
|
|
|
Logged
|
|
|
|
|
Copenhagen / Denmark
Offline
Edison Member
Karma: 5
Posts: 2338
Do it !
|
 |
« Reply #1 on: January 24, 2013, 07:22:25 am » |
No there is not really anything you can do, except by an Arduino Mega that has more flash and more RAM.
Of course thee is always the possibility that your sketch can be optimized / rewritten in some way to take up less space.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #2 on: January 24, 2013, 07:47:02 am » |
I read somewhere that they bought more memory but they never explained howthey used it for the arduino
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #3 on: January 24, 2013, 07:52:07 am » |
I read somewhere that they bought more memory but they never explained howthey used it for the arduino They who? There are any number of things you can do. It is likely that sketch size is not your problem, but that memory is. Of course, we haven't seen any code, so that is purely a guess.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #4 on: January 24, 2013, 08:19:29 am » |
well I guess there is no need for the code because the things that will take up all of the memory is the actual HTML and jquery.js and the css file. on top of that my plan was to also control a LCD display. only the jquery is over 200K then the html is so far 17k css is about 100k so with the basic webserver sketch on about 14k with the includes we can see that there is not way it will all fit.
hmm. I thought:
is the max 32k total space on the UNO or is it just the sketch file? if its just the sketch file then maybe I could minimize the html to a few rows and then use an iframe to include the pages from the client ( read them from the SD? )
what do you think of that is it posible?
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #5 on: January 24, 2013, 08:36:34 am » |
because the things that will take up all of the memory is the actual HTML and jquery.js and the css file. All of which could be read from an SD card and sent. Of course, having that elaborate a web site served by a tiny web server hardly makes sense. Scaling back your expectations might be in order. What, exactly, is the style sheet contributing? What, exactly, is the jquery.js thing going to do?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #6 on: January 24, 2013, 08:46:40 am » |
Small optimization: you don't have to serve jQuery yourself. Google will serve it for you if you reference the right url from a script tag in your HTML:
https://developers.google.com/speed/libraries/
-br
Edit: PS: You can do the same with your .css if you put it up on web hosting somewhere. Even a public Dropbox folder would do.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6313
-
|
 |
« Reply #7 on: January 24, 2013, 09:24:32 am » |
well I guess there is no need for the code because the things that will take up all of the memory is the actual HTML and jquery.js and the css file. on top of that my plan was to also control a LCD display. only the jquery is over 200K then the html is so far 17k css is about 100k so with the basic webserver sketch on about 14k with the includes we can see that there is not way it will all fit.
You seem to be trying to host a conventional web site on an Arduino. It's not at all well suited to that. You would be far better off hosting the presentation layer of your web site on an ordinary web server on a computer, and just use a web service (or whatever other comms mechanism you may prefer) to access business layer functions in the Arduino.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #8 on: January 24, 2013, 09:51:37 am » |
Well I guess Im trying to host a conventional web site with a nice gui för the leds.
Thank you all fot the input.
How would I go about reading and showing a HTML file from the SD card.?
What Im actually trying to do it make n sliders to control the n leds and set time interval for diming the leds up and down.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #9 on: January 24, 2013, 09:55:23 am » |
What Im actually trying to do it make n sliders to control the n leds and set time interval for diming the leds up and down. Is that what the jquery.js part is doing? Sliders are not normal HTML elements.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #10 on: January 24, 2013, 10:09:08 am » |
What Im actually trying to do it make n sliders to control the n leds and set time interval for diming the leds up and down. Is that what the jquery.js part is doing? Sliders are not normal HTML elements. Yes thats what jquery is being used for and jquery ui.
|
|
|
|
|
Logged
|
|
|
|
|
0
Online
Tesla Member
Karma: 50
Posts: 6536
Arduino rocks
|
 |
« Reply #11 on: January 25, 2013, 12:16:11 am » |
I've tinkered with servo sliders in the past like below. So far loading the below on the SD card still uses too much memory. http://web.comporium.net/~shb/servoslider.htm
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #12 on: January 25, 2013, 08:44:58 am » |
I've looked into this matter with javascript and file size some more I compared your code ( I removed all but one of the sliders) and your file ends up at about 9k and the current code I got for one slider is about 2k (the 2k file have the css and javascript file in the HTML not includes). I will be trying to slim the other js things I want as well but I guess it's a good start. do you know how far off you are regarding memory usage?
|
|
|
|
|
Logged
|
|
|
|
|
0
Online
Tesla Member
Karma: 50
Posts: 6536
Arduino rocks
|
 |
« Reply #13 on: January 25, 2013, 01:34:58 pm » |
The below code compiles to 22.6k. The file sizes don't seem to be the issue, so it appears the SD.h might be the bloating factor. //zoomkat 12/26/12 //SD server test code //open serial monitor to see what the arduino receives //address will look like http://192.168.1.102:84 when submited //for use with W5100 based ethernet shields
#include <SD.h> #include <SPI.h> #include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 102 }; // ip in lan byte gateway[] = { 192, 168, 1, 1 }; // internet access via router byte subnet[] = { 255, 255, 255, 0 }; //subnet mask EthernetServer server(84); //server port String readString;
//////////////////////
void setup(){
Serial.begin(9600);
// disable w5100 while setting up SD pinMode(10,OUTPUT); digitalWrite(10,HIGH); Serial.print("Starting SD.."); if(!SD.begin(4)) Serial.println("failed"); else Serial.println("ok");
Ethernet.begin(mac, ip, gateway, gateway, subnet);
//delay(2000); server.begin(); Serial.println("Ready");
}
void loop(){ // Create a client connection EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read();
//read char by char HTTP request if (readString.length() < 100) { //store characters to string readString += c; //Serial.print(c); } //if HTTP request has ended if (c == '\n') {
/////////////// Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page client.println("Content-Type: text/html"); client.println();
File myFile = SD.open("hello.txt"); //File myFile = SD.open("boom.htm"); //File myFile = SD.open("HYPNO.JPG"); //File myFile = SD.open("BLUEH_SL.GIF"); //File myFile = SD.open("BLUEV_BG.GIF"); //File myFile = SD.open("SLIDER.JS"); //File myFile = SD.open("servosld.htm"); //File myFile = SD.open("SERVOSLD.HTM"); if (myFile) { //Serial.println("test.txt:"); // read from the file until there's nothing else in it: while (myFile.available()) { client.write(myFile.read()); } // close the file: myFile.close();
} delay(1); //stopping client client.stop(); readString=""; } } } } }
|
|
|
|
|
Logged
|
|
|
|
|
0
Online
Tesla Member
Karma: 50
Posts: 6536
Arduino rocks
|
 |
« Reply #14 on: January 25, 2013, 06:32:06 pm » |
The below will serve the slider files from the SD card. Next to add back the servo control code. //zoomkat 1/25/13 //SD server slider test code //open serial monitor to see what the arduino receives //address will look like http://192.168.1.102:84/servosld.htm when submited //for use with W5100 based ethernet shields //put the servosld.htm, slider.js, bluev_sl.gif, //and bluev_bg.gif on the SD card //files at http://web.comporium.net/~shb/servoslider.htm page
#include <SD.h> #include <SPI.h> #include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 102 }; // ip in lan byte gateway[] = { 192, 168, 1, 1 }; // internet access via router byte subnet[] = { 255, 255, 255, 0 }; //subnet mask EthernetServer server(84); //server port String readString;
//////////////////////
void setup(){
Serial.begin(9600);
// disable w5100 while setting up SD pinMode(10,OUTPUT); digitalWrite(10,HIGH); Serial.print("Starting SD.."); if(!SD.begin(4)) Serial.println("failed"); else Serial.println("ok");
Ethernet.begin(mac, ip, gateway, gateway, subnet);
//delay(2000); server.begin(); Serial.println("Ready");
}
void loop(){ // Create a client connection EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read();
//read char by char HTTP request if (readString.length() < 100) { //store characters to string readString += c; //Serial.print(c); } //if HTTP request has ended if (c == '\n') {
/////////////// Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page if(readString.indexOf("servosld") >=0) { client.println("Content-Type: text/html"); client.println(); }
if(readString.indexOf("slider") >=0) { client.println("Content-Type: application/x-javascript"); client.println(); } if(readString.indexOf("bluev") >=0) { client.println("Content-Type: image/gif"); client.println(); }
if(readString.indexOf("servosld") >=0) { File myFile = SD.open("SERVOSLD.HTM"); if (myFile) { while (myFile.available()) { client.write(myFile.read()); } myFile.close(); } }
if(readString.indexOf("slider") >=0) { File myFile = SD.open("slider.js"); if (myFile) { while (myFile.available()) { client.write(myFile.read()); } myFile.close(); } }
if(readString.indexOf("bluev_sl") >=0) { File myFile = SD.open("bluev_sl.gif"); if (myFile) { while (myFile.available()) { client.write(myFile.read()); } myFile.close(); } }
if(readString.indexOf("bluev_bg") >=0) { File myFile = SD.open("bluev_bg.gif"); if (myFile) { while (myFile.available()) { client.write(myFile.read()); } myFile.close(); } }
delay(1); //stopping client client.stop(); readString="";
} } } } }
|
|
|
|
|
Logged
|
|
|
|
|
|