Go Down

Topic: Getting started with Arduino Ethernet (Read 2 times) previous topic - next topic

SurferTim

Here is my server code. It has 2 form fields.
http://arduino.cc/forum/index.php/topic,114461.msg867258.html#msg867258

Here is my client code. It down loads Google home every 10 seconds.
http://arduino.cc/forum/index.php/topic,116122.msg874184.html#msg874184

zoomkat has some examples on the forum too. Use the ones that suit you.

billroy

#6
Sep 22, 2012, 01:37 pm Last Edit: Sep 22, 2012, 01:39 pm by billroy Reason: 1
Bitlash (http://bitlash.net) comes with a web server example that may be helpful:

https://github.com/billroy/bitlash/blob/master/examples/BitlashWebServer/BitlashWebServer.ino

For a short response like a sensor reading you can define a Bitlash function to return a response to the invoking browser or server.  There's a built-in, password-protected telnet server that allows you to log in remotely and use Bitlash to make changes like this.

For longer responses you can compile in pages with arbitrary HTML and embedded Bitlash code which is executed when the page is rendered.

Good luck with your project.

-br


jharris1993

#7
Sep 23, 2012, 05:38 am Last Edit: Sep 23, 2012, 05:42 am by jharris1993 Reason: 1

Bitlash (http://bitlash.net) comes with a web server example that may be helpful:

https://github.com/billroy/bitlash/blob/master/examples/BitlashWebServer/BitlashWebServer.ino



Billroy, (et. al.)

Within the code you referenced, there is this comment:

Quote

For debugging, connect via your favorite Serial Monitor at 57600  You can watch the web traffic and issue commands


This begs the question:  Where?  How?  With what?

Again, here is one of those chicken-and-egg scenarios - there are numerous references to a "serial terminal" - and there are even example sketches that purport to use one, but (AFAIK) there is no clear guide on how to do this.  OK, I am sure there is, but it's not exactly easy to find.

I really appreciate the help I am getting here - it is invaluable! - however it strikes me as a rather poor user experience when what should be simple, easy to find information, is hidden from view until someone like me gets on a forum like this to ask - for the zillionth time, I am sure - the same "What's a Cubit?" kind of noob questions.

If I had my 'druthers, there would be clearly written explanatory documentation in each of the example folders, explaining what is being done, how to do it, and possible additional references.

OK, you're right - I'm on my soap-box again.  :D

Thanks for all the help!

Jim (JR)

PaulS

Quote
If I had my 'druthers, there would be clearly written explanatory documentation in each of the example folders, explaining what is being done, how to do it, and possible additional references.

OK, you're right - I'm on my soap-box again.

Getting on your soap box is fine. But, read through this whole thread again. You haven't explained what you want to do with your ethernet shield. How anyone is expected to anticipate everything that one might want to do with every variation of ethernet shield, and cover that in a tutorial is beyond me. Why you are berating people who have spent their time and their money to develop and host a tutorial that fails to anticipate how you want to use your ethernet shield in your environment with your network/firewall/ISP provider also escapes.

OK. I'll get off my soapbox now. If you post a question like "How do I use my Ethernet shield to connect to server this-or-that and execute script these-or-those", you'll get an answer. If you post a question like "How do I configure router this-or-that to assign an IP address to my Arduino", you'll get an answer. If you post specific questions, you'll get specific answers.

Vague questions do not get good answers.

Remember that an ethernet shield is just a piece of the puzzle. By the time that you know you want/need one, you are expected to know something about networking, something about configuring your network, etc.

zoomkat

Client test code that works on my system.

Code: [Select]

//zoomkat 9-22-12
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;

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

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600);
  Serial.println("Better client test 9/22/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  } 
}

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

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text
    client.println("Host: web.comporium.net");
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    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(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor
  }

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

}

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

Go Up