Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Re: Etherent Serial Client on: July 08, 2012, 09:20:05 pm
All I changed was the IP address and the GTY and assigned a dns
2  Using Arduino / Project Guidance / Re: Etherent Serial Client on: July 08, 2012, 04:04:58 pm
Thanks for the code. It helped me get the thing talking. Obviously I have a lot to learn. The code you sent me appears to work, but it does not shut off the led for some reason.
Code:
//zoomkat 7-03-12, combined client and server
//simple button GET with iframe code
//for use with IDE 1.0
//open serial monitor and send an g to test client and
//see what the arduino client/server receives
//web page buttons make pin 5 high/low
//use the ' in html instead of " to prevent having to escape the "
//address will look like http://10.10.0.177:84 when submited
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //assign arduino mac address
byte ip[] = { 10,10,0,177 }; // ip in lan assigned to arduino server
byte gateway[] = { 10,10,0,254 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte mydns[] = { 10,10,0,254}; //dns
EthernetServer server(84); //server port arduino server will use
EthernetClient client;
char serverName[] = "web.comporium.net"; // zoomkat's test web page server
String readString; //used by server to capture GET request

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

void setup(){

  pinMode(13, OUTPUT); //pin 5 selected to control
  Ethernet.begin(mac,ip,mydns,gateway,subnet);
  server.begin();
  Serial.begin(9600);
  Serial.println("server/client 1.0 test 7/03/12"); // keep track of what is loaded
  Serial.println("Send an g in serial monitor to test client"); // what to do to test client
}

void loop(){
  // check for serial input
  if (Serial.available() > 0)
  {
    byte inChar;
    inChar = Serial.read();
    if(inChar == 'g')
    {
      sendGET(); // call client sendGET function
    }
  } 

  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

            //now output HTML data header
          if(readString.indexOf('?') >=0) { //don't send new page
            client.println("HTTP/1.1 204 Zoomkat");
            client.println();
            client.println(); 
          }
          else {   
            client.println("HTTP/1.1 200 OK"); //send new page on browser request
            client.println("Content-Type: text/html");
            client.println();

            client.println("<HTML>");
            client.println("<HEAD>");
            client.println("<TITLE>Arduino GET test page</TITLE>");
            client.println("</HEAD>");
            client.println("<BODY>");

            client.println("<H1>Zoomkat's simple Arduino 1.0 button</H1>");

            client.println("<a href='/?on' target='inlineframe'>ON</a>");
            client.println("<a href='/?off' target='inlineframe'>OFF</a>");

            client.println("<IFRAME name=inlineframe style='display:none'>");         
            client.println("</IFRAME>");

            client.println("</BODY>");
            client.println("</HTML>");
          }

          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          if(readString.indexOf("on") >0)//checks for on
          {
            digitalWrite(13, HIGH);    // set pin 5 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(13, LOW);    // set pin 5 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

//////////////////////////
void sendGET() //client function to send and receive GET data from external server.
{
  if (client.connect(serverName, 80)) {
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0");
    client.println();
  }
  else {
    Serial.println("connection failed");
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read();
    Serial.print(c);
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop();

}
3  Using Arduino / Project Guidance / Etherent Serial Client on: July 05, 2012, 02:05:55 pm
I am a newbie to Arduino and I'm looking for a little help. Basically I'd like to replace the cable running between two RS232 terminals with and Ethernet convertor using the Arduino to make the switch. The Arduino is also going to need to be smart enough to call the server as in the drawing no matter where I plug it into the Internet.

I have this all working without the Arduino using several computers to the other clients and the server work.

I'm having trouble getting the Arduino to get DHCP address and then star sending data both ways.

I would like some ideas please!

Thanks in advance for help.


4  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 06:11:16 pm
Yes, it appears to be working. I'm watching asa the simple web server gives me the pin states and it's logging th client in and out for 10 minutes now.

I guess the pins were too long and prevented the shorter pins on the Adruino from making.

Good catch!

Thanks so much for the help.
5  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 05:47:32 pm
Sorry about the picture. No problem to shrink.

As for the pins, they bottom out, but the pins on the Adurino seem shorter.

I cut 1/8" off all the pins and guess what?

server is at 10.10.0.177
new client
GET / HTTP/1.1
Host: 10.10.0.177
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive

client disonnected
new client
GET /favicon.ico HTTP/1.1
Host: 10.10.0.177
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Accept: */*
Referer: http://10.10.0.177/
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive

client disonnected
new client
GET / HTTP/1.1
Host: 10.10.0.177
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://10.10.0.177/
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive

client disonnected
new client
GET / HTTP/1.1
Host: 10.10.0.177
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://10.10.0.177/
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive

client disonnected
new client
GET / HTTP/1.1
Host: 10.10.0.177
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://10.10.0.177/
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive

client disonnected
6  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 01:35:42 pm
I ordered through Amazon from Powoot as it turns out. It looks like my 30 day window expired so i'll see about a new one.

Love the web...

7  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 12:47:47 pm
SD fail
server is at 0.0.0.0
8  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 12:25:41 pm
Sorry to hear that. I bought these too for this project and it never worked. I think I'll try another platform before buying possibly two more and finding out they don't work for some other reason. I'm also not going to buy into something that fails on the first try and can't be fixed.

I had high hopes for this.

thanks for you help.
9  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 12:14:23 pm
No joy there. Tried the Webserver  and SD programs after powering from a wall brick. Same result :-(
10  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 11:57:37 am
So I decided to try reading the SD card on the Ethernet Shield and see that it's not working either:

/*
  SD card test
   
 This example shows how use the utility libraries on which the'
 SD library is based in order to get info about your SD card.
 Very useful for testing a card when you're not sure whether its working or not.
    
 The circuit:
  * SD card attached to SPI bus as follows:
 ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
 ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
 ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
 ** CS - depends on your SD card shield or module.
       Pin 4 used here for consistency with other Arduino examples

 
 created  28 Mar 2011
 by Limor Fried
 modified 9 Apr 2012
 by Tom Igoe
 */
 // include the SD library:
#include <SD.h>

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 4;   

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("\nInitializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
  pinMode(10, OUTPUT);     // change this to 53 on a mega


  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present.");
  }

  // print the type of card
  Serial.print("\nCard type: ");
  switch(card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }


  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("\nVolume type is FAT");
  Serial.println(volume.fatType(), DEC);
  Serial.println();
 
  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize *= 512;                            // SD card blocks are always 512 bytes
  Serial.print("Volume size (bytes): ");
  Serial.println(volumesize);
  Serial.print("Volume size (Kbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Mbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);

 
  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);
 
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}


void loop(void) {
 
}

Serial output:

Initializing SD card...initialization failed. Things to check:
* is a card is inserted?
* Is your wiring correct?
* did you change the chipSelect pin to match your shield or module?


Looks like it might be something in the hardware.

What to try next?

S
11  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 11:50:48 am
Updated to 1.0.1 this morning.


Thanks
12  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 11:28:39 am
Thanks for the fast response.

I think you're right but there is only the Arduino and the Ethernet Shield as shown.

S
13  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Not taking address on: June 04, 2012, 10:49:17 am
Does w5100 make sense? I'm really new too this as you can tell. :-)
14  Using Arduino / Networking, Protocols, and Devices / Ethernet Shield Not taking address on: June 04, 2012, 08:51:35 am
I'm pretty new to Arduino. I'v been going through the examples and find that most everything works except the Ethernet shield is not accepting IP Addresses. It always comes back 0.0.0.0 on the serial monitor.

My code looks like this:

/*
  Web Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 
 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10,10,0, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(19200);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // 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) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connnection: close");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
                    // add a meta refresh tag, so the browser pulls again every 5 seconds:
          client.println("<meta http-equiv=\"refresh\" content=\"5\">");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");       
          }
          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");
  }
}


The serial Monitor gives me:


server is at 0.0.0.0


I have been surfing the forums for a day or so and tried many ideas with the same result.

The Arduino board is : Atmega328 Duemilanove
The Ethernet Shield is : HanRun HR911105A  10/49

I have link indications at both the Ethernet Shield and on my network switch. I also see traffic when i pin the broadcast so the layer 1 is working.

Any help appreciated
Pages: [1]