Pages: [1] 2   Go Down
Author Topic: Need some general help on ethernet shiled wiring and Server control.  (Read 1139 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having a heck of a time figuring out how to control a simple led on/off through any type of web server through ethernet to my Uno. I need help from the ground up. I've tried other posts and youtube. I do not know the a thing about servers or PHP so I'm stuck. Once someone gets me started with a simple plan I can take it and run. After I get the communication up and running I want to use ethernet+Xbee+Uno to crontrol a bot.

    Thanks in advance.
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If what you describe in your post is all you want to achieve, you should first try google before posting. I entered "arduino led on off webserver" in the google search field and the first two items were examples of what you describe, one of them even in the Arduino playground. If these projects doesn't satisfy your needs, describe them in a bit more detail.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have found lots of examples, but have no idea to do any of the ports or HTML stuff. I'm trying to teach myself about all of this, but I seem to be missing a step. I eventually want to control a robotic arduino through the ethernet to one arduino+Xbee to a wireless Arduino+Xbee. Any help?? If I could get the web server part up and running I think I could change it enough to do the deed.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46154
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If I could get the web server part up and running I think I could change it enough to do the deed.
Are you trying to set up a web server and have the Arduino act as a client, accessing your server? Or, are you trying to have the Arduino act as server?

Forget about your long-term goal for the moment. There are client and server examples provided with the Ethernet library. Have you successfully executed them?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have not. Give me a good one to try and I'll shoot for the stars. I have plenty of time and Internet. I also have a knock off ethernet shield that needs to be explained. It's a HanRun?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46154
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have not.
You have not what? Tried to set up a web server on the PC? Tried the client code on the Arduino? Tried the server code on the Arduino?

As Foghorn Leghorn says, "Pay attention, boy!".
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have now tried all the above. I do not know how the HTML communicates with the PHP code. The php code is the one that talks to the Arduino correct?
I could make this very simple and say I need held by the hand with step by step instructions on how to do this. With out the assumption that I know a thing. I can handle the Arduino and the Xbee. I cannot handle the ethernet part. I have tinkered with this for about a week and just now got the ethernet wired up, I think. I don't have the slightest idea how the Arduino acts as a server or client. I don't know where to go online to check if my work is any good. I know nothing. Hint the login name. smiley-cry smiley-cry smiley-cry smiley-cry smiley-cry Any help will be appreciated. I will even take the sarcasm with a grain of salt, as long as someone is helping.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm new to hardware and Arduino, but here's how I would proceed. As Paul mentioned, you should start off slow. You should start with the very basics and build things in small parts.

I'm assuming you have no Arduino experience at all.

1.

To get familiar with the Arduino and uploading sketches, I would start with the blink tutorial. It is located here: http://arduino.cc/en/Tutorial/Blink

That will give you the basics of how sketch works. I would suggest trying this exercise using the built in led. Then I would try it using an led and breadboard.

This will give you the basics of turning an led on and off. There is a problem with this sketch though since there is a delay that blocks the loop.

2.

Next I would do the BlinkWithoutDelay tutorial: http://arduino.cc/en/Tutorial/BlinkWithoutDelay

This shows you how to do a blink without blocking your loop.

3.

Next I would do the AnalogInOutSerial tutorial: http://arduino.cc/en/Tutorial/AnalogInOutSerial

This gives you some basics on how to control the brightness of an led, but it also shows you how to use the Serial console.

The serial console is useful for debugging.

4.

Now if you're comfortable with the code and how everything works in 1-3, I would try the WebClient tutorial

http://arduino.cc/en/Tutorial/WebClient

This shows you how to send a query to Google and read a response.

You will need to know how to do this for your project I think.

5.

I would go through the rest of the Ethernet Library tutorials until you understand how they work:

They are listed at this link - http://arduino.cc/en/Tutorial/HomePage

See the ones under "Ethernet Library"

-----

As for using HTML and PHP, I'm not sure that would be the best way to control a robot.

I guess it could work if you made the Arduino/Ethernet board act as the server. It wouldn't work well if the Arduino was the client.

If you're going to use an XBee, why do you need the Ethernet?


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also I would look into using UDP instead of HTTP. I think it will be simpler to parse.

See this example: http://arduino.cc/en/Tutorial/UDPSendReceiveString

Once you get that example to work, try to modify it so you can control leds instead.

This is what the example does:

If you press a key, then a Hello World message will be sent to the Arduino and you can view it in the Serial monitor. After the Arduino will send a reply to the sender.

----

Now for your LED prototype, you'd need to modify the code so that it sends different messages. Preferably just a single character. 1 or 0 for example.

So now if you press 1, the Arduino will get that message. In your Arduino sketch, make it so you the LED turns on when it receives a 1. If a 0 is received, turn off the LED.


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have done the simple codes and wrote a few of my own. I'm writing and building one for the bot now. The Ethernet is so I can control the Arduino from my house to my parents and the Xbee is to control the bot from there. A lot of work, but a fun project that I hope to turn into something useful. Just need the communication from my computer to ethernet through the net. No luck yet.
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

simple server control code.

Code:
//zoomkat 4-1-12
//simple button GET for servo and pin 5
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html, or use ' instead of "
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields

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

#include <Servo.h>
Servo myservo;  // create servo object to control a servo

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

String readString;

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

void setup(){

  pinMode(5, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();

  myservo.write(90); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  //enable serial data print
  Serial.begin(9600);
  Serial.println("server servo/pin 5 test 1.0"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  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

          client.println("HTTP/1.1 200 OK"); //send new page
          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 button</H1>");
         
          client.println("<a href=\"/?on\">ON</a>");
          client.println("<a href=\"/?off\">OFF</a>");

          client.println("</BODY>");
          client.println("</HTML>");
 
          delay(1);
          //stopping client
          client.stop();

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

        }
      }
    }
  }
}

Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK. I have now tried several of the ethernet libraries and none worked. I have a cheap ethernet Shield from eBay. It has 10 pins.
CLKOUT|INT
WOL     |SO
SI         |SCK
CS        |RESET
VCC      |GND
I have it as followed to my UNO.
          INT #3
          SO #12
SI #11  SCK #13
CS #10
VCC 3.3v GND GND

Any corrections? Maybe its my IP addressing? Little help would be great. I can load and work just about all other codes. Just can't do this Ethernet crap.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46154
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have a cheap ethernet Shield from eBay.
Really? That one?
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have a cheap ethernet Shield from eBay.

Bummer
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well when I bought my stuff, I had no intention on using ethernet until I realized what an Arduino is capable of. So yes I bought a bunch of cheap parts offline all in one fast swoop. This is the first time any of it gave me trouble. So I'll order a GOOD one I suppose and then maybe I'll get some real help instead of telling me to keep trying the same crap I have been doing. Thanks for a whole lot of nothing. Youtube has more useful knowledge then this.
Logged

Pages: [1] 2   Go Up
Jump to: