copperhead wifi board acting a little weird

I’ve just started experimenting with an Arduino (always wanted to but never made the time). I have an Uno with the copperhead wifi board. I’m connecting to it in adhoc-mode and am running the code lifted from Gadget Nate’s site to turn on/off LEDs. The problem I’m having is really hard to track down and quantify.

What I’ve found, and what’s really odd is that as soon as I add the logic to turn on/off a 4th LED, the web server provided by the wifi board seems to become unstable and have problems. I’m using a separate power supply to drive Vin as well as have tested with no loads to ensure I wasn’t drawing too much current from the board.

What I eventually found after hours of troubleshooting was that if I reduce the lines of code (such as rem’ing the lines that
the original author had in there to show how long the arduino had been up), the board stabilizes and runs correctly by turning on/off the additional LED. With the other coded added back in such as the block that displays the run time, then when trying to turn on an LED it just flickers.

I’m sure there isn’t a typo/bug in the SW cause I have additional code I’ve put together to control an RC car and the copperhead exhibits the same characteristics when adding more lines of tasks (such as trying to format the displayed HTML).

I’m not running out of memory as I’m only using from 16.8k to 17.4k’ish. I’ve also considered the delay in the main loop thinking there was something going on where the server wasn’t completing the process of code execution before having to start over but any manipulation doesn’t fix it (but does seem to be related since when activating an LED it will stay on longer if I increase the delay but it will then shut off on it’s own).

I tried googling for a while and various searches but just couldn’t find much on the to address anything like this?


* A simple sketch that uses WiServer to serve a web page 
#include <WiServer.h>


// Wireless configuration parameters —————————————- 
unsigned char local_ip[] = {10,10,100,11};    // IP address of WiShield 
unsigned char gateway_ip[] = {10,10,100,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 = {"<test>"};        // max 32 bytes

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

// WPA/WPA2 passphrase 
const prog_char security_passphrase[] PROGMEM = {"none"};    // 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 wireless_mode = WIRELESS_MODE_ADHOC;

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

int redState = 0; 
int whiteState = 0; 
int greenState = 0;
int blueState = 0;

int redPin = 5; 
int whitePin = 6; 
int greenPin = 7;
int bluePin = 8;

// This is our page serving function that generates web pages 
boolean sendMyPage(char* URL) { 
    if (strcmp(URL, "/red") == 0) redState = !redState; 
    if (strcmp(URL, "/white") == 0) whiteState = !whiteState; 
    if (strcmp(URL, "/green") == 0) greenState = !greenState; 
    if (strcmp(URL, "/blue") == 0) blueState = !blueState; 

    digitalWrite(redPin, redState); 
    digitalWrite(whitePin, whiteState); 
    digitalWrite(greenPin, greenState); 
    digitalWrite(bluePin, blueState); 

    // 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("Light Control

        printLightStatus("red", redState); 
        printLightStatus("white", whiteState); 
        printLightStatus("green", greenState);
        printLightStatus("blue", blueState); 
        WiServer.print("The page you requested was: "); 
The arduino has been running for: "); 
        WiServer.print(" milliseconds
     // URL was recognized 
        return true; 

void printLightStatus( String lightName, int lightState) { 
  WiServer.print(" Light is "); 
        if(lightState ==0) { 
            WiServer.print(" <b>off</b> <a href=/"); 
            WiServer.print(">Turn On</a>
        } else { 
          WiServer.print(" <b>on</b> <a href=/"); 
            WiServer.print(">Turn off</a>

void setup() { 
  // Initialize WiServer and have it use the sendMyPage function to serve pages 
  // Enable Serial output and ask WiServer to generate log messages (optional) 
  pinMode(redPin, OUTPUT); 
  pinMode(whitePin, OUTPUT); 
  pinMode(greenPin, OUTPUT); 
  pinMode(bluePin, OUTPUT); 


void loop(){

  // Run WiServer 
//  delay(10); 

I'm not running out of memory as I'm only using from 16.8k to 17.4k'ish.

OK, you are not running out of program memory. How are you doing for SRAM? The Uno has only 2K. There is code available to help you determine the SRAM usage.

Thanks for the response SurferTim. I took a look at the code and libraries from this link and added them to the project:,27536.15.html

My test sketch was working when the available memory was shown at around 465 bytes but when uncommenting some code it dropped the available memory to 261 and the weirdness returned. So I’m not entirely out but I can see the usage is pretty maxed.

I googled for a bit and am surprised to see the limited options to expand the RAM so am going to pickup a Mega to see if this problem goes away.


That is why I bought a Mega. It was as much for the SRAM as the program memory. So far, all my program code would fit in an Uno, but most would overflow the SRAM.

Unfortunately I’m pulling my hair out trying to get the mega to work with the copperhead wifi shield. I found the link that discusses the required code and jumper changes to get it to work with the slight changes in pinout with the mega but the wifi board isn’t coming up.

I see that shield is not Mega compatible. The giveaway is the lack of an ICSP connector. Did you do the pin changes? The Mega has the SPI data lines on pins 50-52 instead of pins 11-13, so you will need to pin bend and jumper those. The slave select (pin 10) should stay where it is.

That is the disadvantage of using a Mega with shields using SPI that are designed for an Uno.

Thanks dude for dealing with my questions and yeah, I found some info on dealing with needing to change the pinouts.

This link points out the need to do the changes to support the mega:

Which lead me to here:

I made the respective changes to the libraries, but I didn't bend the pins out (instead followed the one page's advice to set the affected pins to input. Unfortunately it's still not working and I'm about to bend the pins out to just make sure there's no voltage leakage that might be affecting the pins that should be disconnected.

I've google'd the h3ll out of this topic and just don't see anything on it outside of the above links. (ugh).