Hi dear friends , I have question related to arduino web server , could a LED or servo motor be controlled from country to another , and if yes what materials should we use.,,,
Thanks in advance
Yes, but the Arduino is for fast prototyping. The Ethernet and Wifi library require often a lot of code. A wrong sketch or bug or misconfiguration could stop it. An Arduino webserver is not the most reliable application for an Arduino. Even the ESP8266 can be used. I think that is even less reliable than an Arduino.
You need an Arduino board with wifi or ethernet. There are many options for that: An Arduino Uno or Mega 2560 with an Ethernet Shield or wifi shield; an Arduino Yun; at Adafruit they have more wifi boards.
What is it for ?
Thank you for nice answer ,so sir if the the web server is not the best reliable method , which method or configuration we may use ?
I'm sorry, but I don't know.
Can you tell what it is for ? We often get questions that are called xy-problem questions: http://xyproblem.info/
If you want to water plants or operate the window blinds, then there is no need to do that remotely. An Arduino can do that, and perhaps update a website with the data (websites like ThingSpeak and Adafruit.IO). Maybe even use a IP camera, to be able to see what is going on.
Hi dear friends , I have question related to arduino web server , could a LED or servo motor be controlled from country to another , and if yes what materials should we use.,,,
You can try a w5100 based ethernet shield on your arduino and connect it to your LAN internet connection router router. Below is some basic web server test code.
//zoomkat 10-6-13
//simple button GET with iframe code
//open serial monitor to see what the arduino receives
//use the ' instead of " in html ilnes
//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 }; //ethernet shield mac address
byte ip[] = { 192, 168, 1, 102 }; // arduino 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(4, 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 co
//enable serial data print
Serial.begin(9600);
Serial.println("servertest1"); // 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
//now output HTML data header
if(readString.indexOf('?') >=0) { //don't send new page
client.println("HTTP/1.1 204 Zoomkat\r\n\r\n");
}
else {
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='/?on1' 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("on1") >0)//checks for on
{
myservo.write(20);
digitalWrite(4, HIGH); // set pin 4 high
Serial.println("Led On");
}
if(readString.indexOf("off") >0)//checks for off
{
myservo.write(160);
digitalWrite(4, LOW); // set pin 4 low
Serial.println("Led Off");
}
//clearing string for next read
readString="";
}
}
}
}
}
Thank you for nice reply friends
Instead of using w5100 ,I have pcduino and raspberry pi ,can we use them because they have internet port
For the Pi, do a search for 'advanced linux programming'. It's a book (used to be available online but the link seems to be broken).
It contains sample code for a complete web server. Links that currently work:
1)
Full text of "Advanced Linux Programming"
2)
google books; terribly slow