Instructables
The Arduino Ethernet Shield is a sweet toy!!!  Everybody, from the beginner who got their Arduino yesterday and hasn't slept since, to the hard core pro who learned c as a second language, can learn how to use the Ethernet Shield and have lots of fun with it.  Its that awesome! As soon as I earned enough to get one, it was mine, but it took a while for me to figure out how to get my site running and on the web, and I had some trouble with the software, but once I got started, I designed a whole web server, which included a traffic meter, LCD screen, and SD card storage!

This instructable is going to show you how you can make your own "ServDuino" web server, and get it on the web without some of the roadblocks that I, and many others have faced.


Some of this instructable is a work in progress - specifically the code on the programming step.  Not all of the code was released as of the publishing of this instructable because I am always improving or writing new code for my projects.  I am also seeking help from the instructables community in writing code, not because I am lazy, but because I know that I don't have the most efficient code, as I have been programming in c for only a few years, most of which is spent in the world of Arduino.

Don't forget to rate!
I entered this into the Microcontroller contest, so if you think its awesome, or it helps you off the ground with the ethernet shield, vote for it! :)
 
Remove these adsRemove these ads by Signing Up
Topcam1 year ago
Hello, my English is not so perfect. (GOOGLE German ->ENGLISCH)
Catch just me with the Arduino and its potential deal.

Since I need a web server that reads all data from the SD card
I have the script on my Arduino SDWEBSERVER_FAST_LCD.

Running with the DYNDNS perfect.
Only when I: http://NAME.DYDNS.COM/test/ (here in directory there is an index.htm) write, appears donload windows.
I give but a http://NAME.DYDNS.COM/test/ index.htm
goes to the page.

There's an error in your script?


My question 2:

I would now like Led and power switch on the Web, but the code is not in the store Adruino special embed in the HTML file.
Adjust so I just need to code the HTML and not always in the code Ardoino.

Is that how and when do you do that?

Thank you.
Krayzi992 years ago
Just a thought, is this compatible with custom 404 error pages?
Teslaling (author)  Krayzi991 year ago
Yes. In the _404 sketches, there is the option to have a custom 404 page. You just have to make the page and either name it 404error.htm like what is in the sketch or put the name of your 404 page as the name to replace 404error.htm. The line has a comment after explaining what it is. Look for that then find the filename and replace it with your file's name.
Teslaling (author)  Teslaling1 year ago
I should note that the custom 404 pages are only available with the SD card sketches.
Just for people receiving errors when using the SD sketches, "Server" must be renamed to "EthernetServer" and "Client" must be renamed to "EthernetClient"
Teslaling (author)  charlesfries1 year ago
Yeah, sorry. I need to update some of this instructable when I get the chance, including making the sketches work with the new ethernet libraries.
botronics2 years ago
DealExtreame has a low cost Arduino Ethernet shield. Has anyone got it to work?
I got a report from someone that the DX one doesn't work well. They use a different chip than the Arduino standard chip. The drivers don't work with Arduino 1.01. The Arduino-brand ethernet shield works perfectly. Newark has them:
Newark Part Number: 65T3485
Vee202 years ago
My server just won't work. I'm using google chrome. I changed the port to 8081. Is there anything else that I should check? I have already disabled MAC filtering on my router. Need help urgently as I can't get any further with my project without this step.
Thank you so much for the helpful Instructable.
N.fletch2 years ago
Hello, I am a follower of yours and I wanted to say thank you for this Instructable you posted. I used this quite a bit with a wireless bridge to create my latest robot!
salvocanna2 years ago
I made something like this but with arduino and a relay... very easy and cheap (enc28j60 is something around 6$) ... check it: http://blog.salvocannamela.it/arduino-e-enc28j60/
Krayzi992 years ago
Great Ible! This is EXACTLY what i have been looking for! on a side note, if you want the website to appear like http://www.TEXTHERE.com/ instead of something like http://192.168.0.51 then go to no-ip.org, and they'll redirect people to your ip. Thats what I'm gonna do when I build my server XD.
just noticed you had something from dynds... no-ip is also good, so choose that if ya dont like dynds.
Teslaling (author)  Krayzi992 years ago
actually, dyndns doesn't provide that service anymore :( I am going to rewrite that set anyway since it can be confusing and misleading.

Good luck with your server! Glad you found this 'ible helpful!
Krayzi992 years ago
Is there a way to combine 2 of these for faster connection? I would be willing to make 3 of these if i could. I'm thinking it could be as easy as having all 3 having the same ip, but I don't know. Any suggestions?
Teslaling (author)  Krayzi992 years ago
I don't know how or if you could combined them for a faster connection. All having the same IP would NOT work though. If all three tried to respond to a request, there would be a network collision. It would be like 3 cars pulling up to a 4 way intersection and all turning onto the same road at the same time :)

Unfortunately, I think the only way to speed up the connection would be to use parallel communication with the wiznet chip. That would require a rewrite of the ethernet libraries.

As to the FTP, I don't think it would be possible. The Arduino libraries only allow 1 open port, and to have http plus ftp would require 3 ports (ftp takes 20 and 21). Plus you would need a way to store the files to the card...Things would become very complicated very quickly.
also, is there a way to edit the file contents vis FTP? i know i ask alot of questions... thanks for all your time in advance!
j1nai2 years ago
Helloo.. I have question, Can I reload/refresh reading analog sensor without using html meta tag like , because I think this is client side script. I need server side functions maybe like continuously timer or looping function in every time to call analogRead(i); and print to web browser..

anyone have idea to give me an example, thanx...
nmg1962 years ago
I think step 2 is very misleading for the reader. The examples use internal IP addresses and yet the article implies that if its not working then your ISP might be blocking ports. These are internal IP addresses which your ISP cannot touch or affect in any way (in fact you do not need internet access or an ISP for this to work). It also fails to mention the vastly more likely reason for it to not work which is that the default IP address used in the example might not be an IP address routable on your LAN (ie if the example uses 192.168.1.x addresses, but your own LAN uses 10.0.0.x addresses). The article should advise the user to change the IP address in the example to an IP address on their own subnet (which you can find by running ipconfig). In that paragraph it also mentions portforward.com which is irrelevant for testing this project on your internal network.

I think all the right text is there but the stuff about blocking ports and port forwarding should be moved to the relevant paragraph instead of sending people on a wild goose chase when trying to sort out a problem in their LAN :)

The line which says " Somebody could get into your router through your firewall and access personal information" when all they have is your IP address just makes me angry. IP addresses are public information - you reveal it to everyone every time you send them an email or give out the domain name. This statement is totally wrong and just confusing for the user and the author clearly doesn't understand the basics of the Internet. You cannot get through a firewall and access personal information (that's the entire point of a firewall). Similarly, if you give them a domain name, then that obviously reveals the IP address too as you can see if you "ping" the domain name and see the IP - it doesn't hide anything.
Teslaling (author)  nmg1962 years ago
Thanks for the feedback.

I now realize that this step is misleading and incomplete. When I find the time, I plan on rewriting it to be much more organized and systematic.

As to the firewall and ip issue, I feel stupid and ignorant now having wrote that a while ago. I understand that that is false and confusing information. I have replaced it with a more reasonable substitute: We are not very good at remembering strings of numbers, but we are good at remembering words and names.

I hope that this comment and future work will help to clarify the process.
Thanks, but although I can see you've made a few corrections, the article still seems to treat internal IP addresses as though they were external and still places the blame on the ISP. This is still very misleading. It seems you didn't understand anything I was saying so there is little point in me commenting further if you do not understand my explanations. I will simply caution the reader that the majority of the text on this page is incorrect and actively misleading.
Teslaling (author)  nmg1962 years ago
Yes I know that, I said that when I can find the time I will fix it up. I am actually really bogged down right now with such things as the Intel International Science and Engineering Fair this coming week, school work and finals, and an upcoming trip to Germany (during what should be finals week).

I understand the issues and I understand perfectly what you are trying to say, believe me. Basically I will break the step down into a few main paragraphs. The first being about finding out the router's ip range and testing the server with the default program. The second being about port forwarding and alternate ports. And the third paragraph being on finding the external ip and testing the server from it. If I find three paragraphs to be too crowded or misleading, I will break it up even further.

Trust that at some point I will fix the issues but also understand that they are of little concern to me as of present.
iApple guy2 years ago
What is your site address, I want to visit it!!!
Teslaling (author)  iApple guy2 years ago
its currently http://24.154.233.186:8888 however, it is not served by the duino anymore. I needed more speed and I wanted to try some other things with the duino and ethernet shield.
crackHacker2 years ago
dyndns no longer offers free dns service.
Teslaling (author)  crackHacker2 years ago
yup just found that out a few weeks ago
Piobel2 years ago
Hi,

Sdwebserver fast don't work With arduino UNO.

Client.write(buf,maxbyte) don't send data.

Tanks for attention!!!
diy_bloke2 years ago
You could actually store a (small) picture in your atmega eeprom, but it would not be a very efficient way of using memory. Also retrieving it from that eprom to display on a webpage might be less than straightforward and no doubt a bit slow
diy_bloke2 years ago
Tend to agree with nmg 196. The 192 series of ip numbers are internal numbers and have nothing to do with your provider blocking your port 80.

indeed, better to change tje ip address in the program to one that is available on yr network and that depends on the router you may be using. Some go in the 192.168.1.xxx range, others in the 192.168.0.xxx range, or even the 10.0.0.xxx adress range as mentioned earlier.

If someone had my -external- ip address and I have a webserver running, then indeed by typing in that ip address, they could have a look at the main page of that websever, provided I had forwarded port 80. But that is still a far cry from being able to access my personal information, unless I would put that on that particular webserver.

As most arduino / ethernet adepts will probably use it to read out temperatures and put that on a web page, All the culprit wld be able to see is how warm your house or garden is.

It would be different ofcourse if you set up a webserver ro control functions, then any passer by (provided you have an open webserver) could alter functions in your house, like switch the lights on or off :-)
Very good tutorial.
Is what i have been looking for.
Thanks for sharing.

Timóteo
Teslaling (author)  Timoteo_Mendes2 years ago
Thank You. I'm glad it helped.
doby1623 years ago
This looks really cool! I can't download your code files though, when I try I just get .tmp files. I can read them by converting them into text documents but they are still a little jumbled. How much control does one have with a server like this? You mentioned using exbee to control devices over the web, but would those devices be able to simultaneously upload significant sensor information? (live video for instance) Thanks for sharing! I might have to make one of these. :oD
Teslaling (author)  doby1623 years ago
Thanks! That weird with the files though, I might put them in text documents then. You can control quite a bit with the arduino, assuming you can run all of the connections. I had it controlling an rgb led with 8 bit pwm (0-255) control for all 3. You could have it sending sensor data simultaneously (well, it would appear to be, but it would have to run through all of the sensors in quick succession), but it couldn't be a significant amount, like live video, that would swamp the ethernet controller. As long as you have the hardware (and enough program memory) you could probably automate every light switch, thermostat, and door in your house!!!
Great instructable! Can you post the code for the web controlled RGB LED? I'm not to familiar with programing and I am getting a message that says "sd2Card does not name a type" when trying to compile the "SDWebServer normal.txt." file. any ideas?
Teslaling (author)  Teslaling3 years ago
The Code is now in text document form
Can you help me please, i need this code made so it works with arduino website

Thanks

code:

// variables for input pin and control LED
int analogInput = 1;
int LEDpin = 13;
int prev = LOW;
int refresh = 1000;
float vout = 0.0;
float vin = 0.0;
float R1 = 45000.0; // !! resistance of R1 !!
float R2 = 4500.0; // !! resistance of R2 !!

// variable to store the value
int value = 0;


void setup(){

// declaration of pin modes
pinMode(analogInput, INPUT);
pinMode(LEDpin, OUTPUT);

// begin sending over serial port
Serial.begin(9600);
}

void loop(){
// read the value on analog input
value = analogRead(analogInput);
//Serial.print("value=");
//Serial.println(value);

if (value >= 1023) {
Serial.println("MAX!!");
delay(refresh);
return;
}
else if (value <= 0) {
Serial.println("MIN!!");
delay(refresh);
return;
}

// blink the LED
if (prev == LOW) {
prev = HIGH;
} else {
prev = LOW;
}
digitalWrite(LEDpin, prev);

// print result over the serial port
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));

//Serial.print("vout=");
//Serial.println(vout);

Serial.print(vin);
Serial.println(" volt");

// sleep...
delay(refresh);
}
Teslaling (author)  Daniel Deacon2 years ago
Hi Daniel,

In order to help you get this working, can you please give me some insight on what you are trying to do? I would like to know what this code is supposed to do and how you want me to get it working with the webserver programs. If you could please, can you tell me if you are trying to make this work along side the code or make all of the information in the Serial.print lines be displayed on the webpage? If you get back to me with some information I will gladly give assistance as best as I can.
hello,

I would like to make a web server with a voltmeter it doesn't have to be anything fancy just something like 'Solar Panel Battery Voltage' '12.24 Volts'. The code I posted was an example of how the volt meter works. I don't know how to add a code along side the main bit that runs the server.

Thanks for your help! :)
I meant to add I wish to have it displayed in the web page all the serial communications :D thanks
Teslaling (author)  Daniel Deacon2 years ago
Thank you for providing that information, it really helps.

I must apologize for I am really busy right now so I probably won't be able to get the code running and tested until later in the week. If you need it before Friday please let me know and I will do my best.

Sorry once again,
Gigavolt
Teslaling (author)  Teslaling2 years ago
Hi Daniel,

I wrote and tested the code and it works. If you have any question about it or need help with anything else, please ask.

Gigavolt
Gelfling62 years ago
Making a page-dump of the entire project. It may be exactly the thing I need for a WiFi Controlled robot I've been working on, based on the Arduino, and using a mini WiFi router.. Thanks!
Teslaling (author)  Gelfling62 years ago
Cool! I hope you can get it up and running. I would like to see pictures of even a video if you can get it working!
cinezaster3 years ago
Have you tried multi html pages, with images stored on the sd card and js or css files loaded from the arduino.
Because I'm going to make my office controlled by a ethernet arduino.
Controlling lights and powersources and showing some enviromental data on a webpage.
I was thinking to pull and push the data and controls by ajax.
Arduino by itself is no problem but I never tried the ethernet shield and/or the SD libraries.
And I'm going to use the ENC28J60 ethernet module.
I hope there is enough space on the arduino chip.
Teslaling (author)  cinezaster3 years ago
Actually, I have successfully had multiple html pages with images and css files, but they were all loaded from the SD card. The Arduino has no filesystem so all pages have to be loaded from the SD card. I had my website being served by the Arduino, which included images and videos. The only reason it doesn't anymore is because i just had too much content for it to handle. Be careful because it is very slow at loading files larger than 1MB.
tatazm3 years ago
Nice works. I am trying to build a small robot controlled wireless via xbee and ethernet shield.

Teslaling (author)  tatazm3 years ago
Awesome! Can't wait to see it!