Hi Everyone,
Starting a project where I'll be making an Arduino Web Server. I have my own photographic web page (html code is written) can I host images using an Arduino? I have just been looking at the Nimbits sever i would like to incorporate this into my project counting the amount of visits to my web page etc, can this be done?
If anyone can point me in the right direction I would be extremely grateful.
Why an Arduino Web Server? You should give us more details. The UNO or similar was never intended for this sort of use. It can be done with shields, etc. but may not make sense.
Hi Joe,
Its for a Uni project. I have an Uno and Ethernet shield and was hoping to use the Arduino as a web server to host my web site.
Also if this can be done somehow tie the hits the webpage will receive to record this somehow using Nimbit/Google analytics.
I recommend linking to images instead of hosting them. The arduino can only use SD cards at up to 20KB/s so you will be looking at very long delays for photos. If you just link them but host smaller images, you will be able to show your professor you can do image/files hosting and also understand the limitations of arduino and properly addressed it. I'd be happy with your project as a professor if you did that.
Is using the Arduino a requirement? If not, consider the Raspberry Pi. Similar cost & size but much, much better suited as a Web Server. Remember, the Arduino has a very small memory, no operating system, no scheduler, etc. The Pi runs Linux, which is probably the most common web server on the planet. Please, no loud complaints from Windows fanboys
The advantage of an arduino in this class project would be the most direct way to learn how a web server works with HTTP requests and responses. It works the best for us non-linux super users. For a full-feature web server (probably not the class project requirement), a pi or beagle board will be best. Then you are required to know how to use linux and set up a web server, totally different knowledge involved.
People certainly have served a simple web page or two from an arduino. I have not tried Nimbits, but nothing they claim is unreasonable. In any case you can find what you need. Google is your friend.
Hi, Hilly.
Just a tip, change the subject of this thread to something like.
Arduino Web Server..help
The subject at the moment tells us nothng, I know nothing about web servers yet have looked here to see what you want.
There are probably many forum members who know about your subject, but have not read this thread because of the subject content.
Hope it helps....Tom.....
PS Because you are the originator of this thread you can go and edit the Subject.
Starting a project where I'll be making an Arduino Web Server. I have my own photographic web page (html code is written) can I host images using an Arduino?
You can put a lot of pictures on an SD card. Below is server test code that does some optimization of the file upload process.
//zoomkat 12/26/12
//SD server test code
//open serial monitor to see what the arduino receives
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields
#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
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(){
Serial.begin(9600);
// disable w5100 while setting up SD
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
Serial.print("Starting SD..");
if(!SD.begin(4)) Serial.println("failed");
else Serial.println("ok");
Ethernet.begin(mac, ip, gateway, gateway, subnet);
//delay(2000);
server.begin();
Serial.println("Ready");
}
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("Content-Type: image/jpeg");
//client.println("Content-Type: image/gif");
//client.println("Content-Type: application/x-javascript");
//client.println("Content-Type: text");
client.println();
//File myFile = SD.open("boom.htm");
File myFile = SD.open("HYPNO.JPG");
//File myFile = SD.open("BLUEH_SL.GIF");
//File myFile = SD.open("SERVOSLD.HTM");
if (myFile) {
byte clientBuf[64];
int clientCount = 0;
while(myFile.available())
{
clientBuf[clientCount] = myFile.read();
clientCount++;
if(clientCount > 63)
{
// Serial.println("Packet");
client.write(clientBuf,64);
clientCount = 0;
}
}
//final <64 byte cleanup packet
if(clientCount > 0) client.write(clientBuf,clientCount);
// close the file:
myFile.close();
}
delay(1);
//stopping client
client.stop();
readString="";
}
}
}
}
}