Go Down

Topic: HTML Causing Arduino To Crash (Read 2059 times) previous topic - next topic


Hi all,

I've been working on some basic HTML pin controls as a mini project to learn Ethernet side of Arduino but I keep getting stuck....

The following lines always crash the Arduino and make it restart.

Code: [Select]
//         client.print("<form method=get>");     
//                                  client.print("<input type='radio' name=r2 value='1'");
//         if (digitalRead(2) == 1) client.print(" checked");
//                                  client.print("> Relay 2<br>");
//         client.print("<input type='radio' name=r value='2' checked> Two<br>");
//         client.print("<input type='radio' name=r value='3'> Three<br>");
//         client.print("</form>");

Even leaving out the 3 that make up the if statement and just using the following line does the same..

Code: [Select]
//         client.print("<input type='radio' name=r value='3'> Three<br>");

If I replace with...

Code: [Select]
         client.print("Test Text");

It works fine, just not with the form HTML.

Full code attached.

Any ideas?


Perhaps you're running out of RAM. All those strings will be occupying RAM, and there is only a tiny amount available. Without seeing the whole sketch (hint!) or knowing what hardware you're using (hint, hint!) it's impossible to do more than guess, but that would be my guess. You avoid those strings using RAM by defining them as PROGMEM values.


You probably need to escape the single quotes like this:

Code: [Select]
client.print("<input type=\'radio\' name=r value=\'3\'> Three<br>");


Thanks both for the quick replies :)

Quick5pnt0 - No such luck does the same  =(

PeterH - You might be right, 1 line of code seems to cause a restart when I try to access the device. Whereas multiple lines of code just cause it to reboot instantaneously. I'm pretty new to this so will look up what you mean by PROGMEM tomorrow after I've got some sleep and have more patience.

PS Its an UNO and the full code is attached to the original post.

Thanks again  :)


PS Its an UNO and the full code is attached to the original post.

Hint: it is a PITA to download code when it can be posted in a code box.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


Zoomkat - I tried but it was too long :( I could try stripping out what I few as the "unimportant" code when I get home from work.


Use the F() function to keep those static strings in program memory.
Code: [Select]
client.print(F("<form method=get>"));     
Do the same to the rest of those strings, and that should save you a lot of SRAM.

Go Up