Arduino WiFi shield with Duemilanove?

Hello!

I'm currently working on a project which involves a LynxMotion AL5B robotic arm. To control it I'm using a BotBoarduino and an Arduino Ethernet Shield. I control the servos of the robot arm with a Web Server and a client made in Visual Studio. Everything works fine and my robot moves as I want it to. I made it so you can request if you want HTML, XML or JSon returned to you depending on what you request.

But that is not what my problem is. Now when I have a working Ethernet Web server which I can control the robot with, I want to make it wireless using an Arduino WiFi shield. I can connect to my network, and the Web server example code works when I browse to the ip address it gets. But when I upload my own code to the BotBoarduio and browse to the ip address, it start a download for some file.

I know that the code is working, because I tested it with an Arduino Uno r3 and it worked exactly as I want. With it working I mean that I can browse to the ip address and it returns correct HTML, XML, and JSon for the different things I put in the URL after the ip. I can't swich the BotBoarduino with the Uno because the Uno doesn't have connections for the five servos I'm using.

I believe that the BotBoarduino is like an older version of an Uno since it doesn't have the SCL, SDA and IOREF pins. For the WiFi to work with the BotBoarduino I have a jumper attached between IOREF and 3,3v and I have read that you might have to add jumpers between SCL and A5, SDA and A4 and maybe D7 and D3, but I don't know which and If any of them to use.

I really don't know what to do after sitting on Google for the past couple of days searching for a solution, but it seems that no one uses the BotBoarduino. All answers are highly appreciated.

The robot arm I'm using: http://www.lynxmotion.com/c-126-al5b.aspx

The BotBoarduino: http://www.sedoniatech.com.au/botboarduino-botboarduino-arduino-compatible-robot-board.html

Update, is the WiFi shield compatible with an Arduino Duemilanove since the BotBoarduino is a mix of a BotBoard 2 and an Arduino Duemilanove.

Ok, so now I have sat on Google for the past day and haven’t come up with anything. I put some debug prints in my code to see where it fails and it seems that, from the web server example, if(client) always returns false and never enters the code.

And still this only happens when I use the Arduino WiFi shield with the Duemilanove. Like I said before everything works fine with an Uno and the Web Server example itself works fine on the Duemilanove. The code I’m working with is pretty long so bare with me. This is the code that works wit the Uno but not Duemilanove:

#include <SPI.h>
#include <WiFi.h>
#include <Servo.h>


char ssid[] = "networkName";      // your network SSID (name) 
char pass[] = "password";   // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

// Servo definitions
Servo Elb;
Servo Shldr;
Servo Wrist;
Servo Base;
Servo Gripper;
       
Servo servoArray[5];     // Array for storing the servos

void setup() 
{
  // Store the servos in the array
  servoArray[0] = Base;
  servoArray[1] = Shldr;
  servoArray[2] = Elb;
  servoArray[3] = Wrist;
  servoArray[4] = Gripper;

  stop(); // Start the servos detached so they wont fly around when getting power

  //Initialize serial and wait for port to open:
  Serial.begin(9600); 
  while (!Serial) 
  {
    ; // wait for serial port to connect.
  }
  
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:
    while(true);
  } 
  
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) { 
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
    status = WiFi.begin(ssid, pass);
    Serial.println(WiFi.localIP());

    // wait 10 seconds for connection:
    delay(10000);
  } 
  server.begin();
  // you're connected now, so print out the status:
  printWifiStatus();
}

void moveServo(Servo s, int endPos)
{
  int currentPos = s.read();    // read current position of servo
  int differance = endPos - currentPos;   // check how much differance is between the two positions
  // Depending on if you want to decrease och increase the angele either add or subtract angles, one at a time
  for(int i = 0; i < abs(differance); i++)
  {
    if(endPos > currentPos)
      s.write(currentPos++);
    else
      s.write(currentPos--);
    delay(45);        // Control the speed of the servos  
  }
} 

void start()
{
  // x.attach(y) attaches the x servo to the y pin on the board
  Base.attach(2);
  Shldr.attach(3);
  Elb.attach(4);
  Gripper.attach(5);
  Wrist.attach(6);

  // x.write(y) moves the x servo to a chosen angle y
  Base.write(120);
  Shldr.write(135);
  Elb.write(150);
  Wrist.write(140);
  Gripper.write(180);
}

void stop()
{ 
  Base.write(120);
  Shldr.write(135);
  Elb.write(150);
  Wrist.write(140);
  Gripper.write(180);
  delay(1000);
  
  // x.detach(y) detaches the x servo from the y pin on the board
  Base.detach();
  Shldr.detach();
  Elb.detach();
  Gripper.detach();
  Wrist.detach();
}


void loop() 
{
  // listen for incoming clients
  WiFiClient client = server.available();
  Serial.println(client);  // Debug
  Serial.println("*");
  if (client) 
  {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    String request = String();
    Serial.println(client.connected());  // Debug
    Serial.println("**");
    while (client.connected()) 
    {
      Serial.println(client.available());  //Debug
      Serial.println("***");
      if (client.available()) 
      {
        char c = client.read();     // Read one byte 
        request += String(c);             // Add it to the complete string
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) 
        {
          Serial.print(request);
                
          int textTypeHTML = request.indexOf("text/html");  // Only one of the three int:s will have a value
          int textTypeXML = request.indexOf("text/xml");    // The other two will be -1 since only one text type 
          int textTypeJson = request.indexOf("text/json");  // is accepted at a time
          
          // Request format 'GET /Servo/2/... HTTP/1.1'
          int firstSpace = request.indexOf(" ");
          int secondSpace = request.indexOf(" ", firstSpace + 1);
          request = request.substring(firstSpace + 2, secondSpace);    // Substring of the servo you chose and chosen position etc
          String message = request;
          String result[7];   // Array to store everything from the url
          int slashPos;
          Serial.println(message);
          
          // Like a split function, locate the first slash of a string and save the string between that slash and the nex one in an array
          do
          {
            for(int i = 0; i <= 6; i++)
            {
              slashPos = message.indexOf("/");      // Position of the current slash
              if(slashPos != -1)                // When there still are slashes
              {
                  String tmp = message.substring(0,slashPos);      // Store current word between slashes
                  result[i] = tmp;
                  message = message.substring(slashPos + 1, message.length());    // Update string without stored word
              } 
              else
              {  // if no more slashes
                if(message.length() > 0)    // If there are text after the last slash store it as well
                {
                  result[i] = message;   
                  break;
                }                          
              }              
            }  
          }
          while(slashPos >=0);
          
          result[0].toLowerCase();
         
          int servoNum;
          int servoPos;

          // Print out current position of all servos
          for(int i = 0; i < 5; i++)
            Serial.println(servoArray[i].read());
         
          // Decide wich content type was asked for
          int outputLanguage = 0; //HTML default
          if(textTypeJson != -1)
            outputLanguage = 1;
          if(textTypeXML != -1)
            outputLanguage = 2;  
          
          // Debug showing wich content type was accepted  
          Serial.println(textTypeJson);  
          Serial.println(textTypeXML);
          Serial.println(outputLanguage);

          String contentType[] = {"Content-Type: text/html","Content-Type: text/json","Content-Type: application/xml"};
          
          String close = "Connection: close";

          int chosenServo = result[1].toInt();
          int chosenPos = result[2].toInt();

          ////////////////////////////////////////////////////////////////////////////////////////////

          if(outputLanguage == 0) // HTML
          {
            Do stuff if you asked for HTML
          }

          ////////////////////////////////////////////////////////////////////////////////////////////

          else if(outputLanguage == 1)  // JSon
          {
           Do stuff if you asked for JSon
          }

          ////////////////////////////////////////////////////////////////////////////////////////////

          else if(outputLanguage == 2)  // XML
          {
            Do stuff if you asked for HTML
          }
          
          ////////////////////////////////////////////////////////////////////////////////////////////

          if(outputLanguage == 0)
            client.println("</html>");
          
          break;
        }    
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Hi, I’m trying to set up a webserver using an ethernet shield with the BotBoarduino. The webserver woked just fine on my Arduino Uno, but it acts wierd on the Botboarduino. COuld you share the details of the Ethernet shield you were using? The motors go into a “whining” state whenever any ethernet connection related program is downloaded onto the board.

Please let me know if you ran into something similar!

Thanks!