HTML Causing Arduino To Crash

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.

//         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
");
         
         
//         client.print("<input type='radio' name=r value='2' checked> Two
");
//         client.print("<input type='radio' name=r value='3'> Three
");
//         client.print("</form>");

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

//         client.print("<input type='radio' name=r value='3'> Three
");

If I replace with...

         client.print("
");
         client.print("Test Text");
         client.print("
");

It works fine, just not with the form HTML.

Full code attached.

Any ideas?

webcontol_dhcp_full_0_4.ino (10.7 KB)

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:

client.print("<input type=\'radio\' name=r value=\'3\'> Three
");

Thanks both for the quick replies :slight_smile:

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 :slight_smile:

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.

Zoomkat - I tried but it was too long :frowning: 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.

client.print(F("<form method=get>"));

Do the same to the rest of those strings, and that should save you a lot of SRAM.