Does anyone know how I would be able to create something like this: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1275865385 but instead control everything through my ethernet shield?
Set up your arduino as a server. On your linux box, every time you have a new message connect to the arduino, pass the message, and disconnect.
On the arduino, every time there is a new connection, read the message and display it.
Perhaps you could give a litle more detail on what you want. Do you want the arduino on its own to get data from the internet and display it, or do you want to send data to the arduino and have the arduino display it?
Im Thinking of getting data from the internet. Perhaps an RSS Feed.
So, now I found this code:
//zoomkat 5-24-10
// http://www.arduino.cc/en/Tutorial/TextString for WString.h
#include <WString.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
Server server(84); //server port
String readString = String(100); //string for fetching data from address
///////////////////////
String teststring = String(100);
String finalstring = String(100);
String flag = String(2);
int ind1 = 0;
int ind2 = 0;
int pos = 0;
//////////////////////
void setup(){
//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
//enable serial data print
Serial.begin(9600); }
void loop(){
// Create a client connection
Client 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.append(c);
}
//if HTTP request has ended
if (c == '\n') {
///////////////
//Serial.println(readString);
//readString looks like "GET /?-0p1555-1p500t1000 HTTP/1.1"
if(readString.contains("-")) { //test for servo control sring
readString.replace('-', '#');
pos = readString.length(); //capture string length
//find start of servo command string (#)
ind1 = readString.indexOf('#');
//capture front part of command string
teststring = readString.substring(ind1, pos);
//locate the end of the command string
ind2 = teststring.indexOf(' ');
//capturing the servo command string from readString
finalstring = readString.substring(ind1, ind2+ind1);
//print "finalstring" to com port;
Serial.println(finalstring); //print string with CR
}
////////////////////////
//GET /?Slidervalue0=1800&Submit=Sub+0 HTTP/1.1
if(readString.contains("Slidervalue")) {
ind1 = readString.indexOf('u');
ind2 = readString.indexOf('&');
finalstring = readString.substring(ind1+1, ind2);
finalstring.replace('e', '#');
finalstring.replace('=', 'p');
Serial.println(finalstring);
}
///////////////////
//now output HTML data header
client.println("HTTP/1.1 204 Zoomkat");
client.println();
client.println();
delay(1);
//stopping client
client.stop();
/////////////////////
//clearing string for next read
readString="";
teststring="";
finalstring="";
}}}}}
How do I use that code to parse the date, time, and temperature from here: Sherman Oaks, California | Current Weather Forecasts, Live Radar Maps & News | WeatherBug
I will most likely need to re-get the data every minute, due to the clock.
Below are some post on the subject from the past you may want to review.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293304349/0
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293645484/8
Ok, so I reviewed. I now have this code:
//zoomkat 12-22-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again
#include <SPI.h>
#include <Ethernet.h>
String readString, readString1;
int x=0;
char lf=10;
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x22, 0x8A };
byte ip[] = { 192, 168, 1, 102 };
byte server[] = { 74, 125, 224, 45 }; // NOAA
Client client(server, 80);
void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);
Serial.println("starting simple arduino client test");
Serial.println();
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /site/chrisarduino/ HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
if (c==lf) x=(x+1);
if (x==14) readString += c;
readString += c;
}
if (!client.connected()) {
client.stop();
Serial.println("Current data row:" );
Serial.print(readString);
Serial.println();
readString1 = (readString.substring(41,43));
Serial.println();
Serial.print("DPD sec: ");
Serial.println(readString1);
Serial.println("done");
for(;;);
}
}
When I upload it and go to serial monitor I get
starting simple arduino client test
connecting...
connection failed
Current data row:
DPD sec:
done
PS: The website I get data from is https://sites.google.com/site/chrisarduino/
I doubt you will be able to access the page you want using an IP address. You can see he problem trying to access the page you have using the IP address you have in your code below. With the large commercial sites, the current server IP addresses are apparently dynamically allocated and are determined at the time the client trys to access them. You may be able to use the bottom ethernet library with DNS to be able to get the page by name.
https://74.125.224.45/site/chrisarduino/
http://74.125.224.45/site/chrisarduino/
Which example should I use zoomkat?
When I upload it and go to serial monitor I get
starting simple arduino client test
connecting...
connection failed
Current data row
If you can access the site http://74.125.224.45/ from other devices on your network (ie your browser) I suspect the problem is your network gateway. When you call ethernet.begin() there are two optional parameters, the default gateway and network mask. The default is 192.168.1.1 and 255.255.255.0. If those are not the same as the rest of the devices on your network the arduino is not going to work.
The website I get data from is https://sites.google.com/site/chrisarduino/
The https in your address is a problem. The arduino ethernet can't support https, only http. Make sure you can get what you want with http.
The other problem you're going to have is that google doesn't support HTTP 1.0. You're going to have to change this line:
client.println("GET /site/chrisarduino/ HTTP/1.0");
client.println();
to
client.println("GET /site/chrisarduino/ HTTP/1.1");
client.println("HOST sites.google.com");
client.println();
Well I still cant connect. Even with this feed: poweringnews.com - This website is for sale! - poweringnews Resources and Information. How would I fix this?
What is the subnet mask and default gateway for your network?
ADSL Port
IP Subnet Mask 255.255.255.255
Gateway IP Address 151.164.186.6
LAN Port
IP Subnet Mask 255.255.255.0
Just letting you guys know, I am still open for help.
What's the default gateway of your network? Not what the router reports (Gateway IP address) but what a computer inside the network reports. You can get it by typing "IPConfig" at the command prompt of a windows PC.
Its 192.168.0.1
I changed the feed a bit so the new one is here: http://pipes.yahoo.com/pipes/pipe.run?_id=6d2c0b97b3c18eba6be661489a35c9c3&_render=rss
I want do display the number of emails I have (first feed post), and the current temperature (second feed post), eventually I will attach my ds1307 RTC.
Carnyworld:
Its 192.168.0.1
That's your problem.
By default the ethernet library uses 192.168.1.1. When you call Ethernet.begin() you need to provide that gateway.
ie,
byte gateway={192,168,0,1};
Ethernet.begin(mac, ip, gateway);
Now when I do that it says:
scalar object 'gateway' requires one element in initializer
What is wrong?
Carnyworld:
Now when I do that it says:scalar object 'gateway' requires one element in initializer
What is wrong?
My bad.
Should be :
byte[] gateway={192,168,0,1};
Did you mean:
byte gateway[] = { 192, 168, 0, 1 };
Ethernet.begin(mac, ip, gateway);