Show Posts
Pages: [1] 2 3 ... 399
1  Using Arduino / Networking, Protocols, and Devices / Re: trouble using GET to retrieve public API XML data on: August 20, 2014, 09:56:15 am
It will be only a few domains that will be affected. It appears to be when the domain name uses a CNAME (alias server name) for the main domain name.
2  Using Arduino / Networking, Protocols, and Devices / Re: trouble using GET to retrieve public API XML data on: August 20, 2014, 06:28:41 am
There is a difference between a DHCP server's failure to issue a DNS server, and the DNS server issued being unable to resolve the domain name correctly.

This code works for me.
Code:
/*
  Web client modified to read wave height data
 
 This sketch connects to a website (http://www.google.com)
 using an Arduino Wiznet Ethernet shield.
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe, based on work by Adrian McEwen
 
 */

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

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x9C, 0xEB };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
IPAddress server(140,90,78,215);
//char server[] = "co-ops-nos.1.noaa.gov";

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,0,177);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);
 
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(2000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /api/datagetter?date=latest&station=8516945&product=one_minute_water_level&datum=STND&units=metric&time_zone=gmt&application=web_services&format=xml HTTP/1.0");
    client.println("Host: tidesandcurrents.noaa.gov");
    client.println("Connection: close");
    client.println();
  }
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

// if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}

edit: Here is the serial monitor output.
Quote
connecting...
connected
HTTP/1.1 200 OK
Date: Wed, 20 Aug 2014 11:22:36 GMT
Server: GlassFish Server Open Source Edition 3.1.2.2
X-Powered-By: JSP/2.2
Cache-Control: no-cache,no-store,must-revalidate
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/xml;charset=ISO-8859-1
Vary: User-Agent,Accept-Encoding
Connection: close
Set-Cookie: SERVERID=A; path=/

<?xml version="1.0" encoding="UTF-8" ?>
<data>
<metadata id="8516945"  name="Kings Point" lat="40.8103" lon="-73.7649"/>
<observations>
<ts t="2014-08-20 11:12"  v="6.020" />
</observations>
</data>

disconnecting.
3  Using Arduino / Networking, Protocols, and Devices / Re: trouble using GET to retrieve public API XML data on: August 19, 2014, 12:52:55 pm
It's not the DHCP that is failing. It is the DNS resolution on that domain. I'll post my working version of your code latter.
4  Using Arduino / Networking, Protocols, and Devices / Re: Using a Raspberry PI as a gateway with an XBee/Arduino Sensor Network on: August 19, 2014, 08:44:57 am
It is more difficult than you think. You must install the LAMP server package on the RPi and libmysqld-dev to interface C programs with the MySQL package.
http://www.raspberrypi.org/forums/viewtopic.php?f=33&t=70281&p=509755#p509755

Then search Google for the rest, or post a question on the RPi forum.
5  Using Arduino / Networking, Protocols, and Devices / Re: trouble using GET to retrieve public API XML data on: August 19, 2014, 07:52:21 am
The Arduino ethernet library is apparently having problems with the DNS on that domain. Use an IP address instead. It works fine here using an IP.
Code:
IPAddress server(140,90,78,215);


I even tried removing the protocol from your server entry and it still has trouble with resolving the dns on that domain.
6  Using Arduino / Storage / Re: read CSV file on SD and send it by mail on: August 19, 2014, 06:25:44 am
That looks like the way to do it!
7  Using Arduino / Storage / Re: Program Stuck at SD.begin(4) on: August 19, 2014, 06:24:42 am
It appears your Arduino is restarting for some reason. Hard to tell from here. Does the w5100 and SD card work ok separately?
8  Using Arduino / Networking, Protocols, and Devices / Re: tcp/ip connection question on: August 19, 2014, 06:20:12 am
Ethernet.begin() should be called only once in your setup() function.

The client.connect(serv,4352) must be called every time you want to connect to another device or the same device again. Insure you call client.stop() when you are finished with that connection.


9  Using Arduino / Networking, Protocols, and Devices / Re: Uno Ethernet failure, works on Mega on: August 18, 2014, 09:49:16 am
I answered this question for you already.
http://forum.arduino.cc/index.php?topic=261361.0
10  Using Arduino / Installation & Troubleshooting / Re: Problem with SD library on: August 18, 2014, 08:54:10 am
root in your setup is a file handle.
Code:
root.close()
You also try to open a file in   ecritFichier();
It's file handle is myFile.
11  Using Arduino / Installation & Troubleshooting / Re: Problem with SD library on: August 18, 2014, 08:36:03 am
I'll see if I can get a moderator to move your thread to the Storage section. You will probably get more help there than here.

I don't know how the SD library handles more than one file open at a time. You seem to have two open at once.


12  Using Arduino / Installation & Troubleshooting / Re: Problem with SD library on: August 18, 2014, 07:43:01 am
You should post a link to the Touchscreen hardware and a description on how it is connected to the Mega.

You should have posted this in the "Storage" section of the forum.
13  Using Arduino / Storage / Re: read CSV file on SD and send it by mail on: August 18, 2014, 06:59:42 am
You mean every line is a separate mail ?
The file will have 296 lines at the end of the day , then i will receive 296 mails , in this case.  thats not a good idee !

i prefer only sending i mail , with the complete file. But is the problem than that i have to but the complete file in a buffer?
No. You can send the file in one email. Just keep adding lines to the one email. It won't terminate the email body until you send a period on a line by itself.

edit: Like this. All these lines are sent in one email.
Code:
                            mailClient << F("Content-type: text/html;") << endl << endl;
                            mailClient << F("This is line one") << endl;
                            mailClient << F("This is line two") << endl;
                            mailClient << F("This is line three") << endl;
                            mailClient << F("This is line four") << endl;

                            ShowStatus(mailClient);

                            // this tells the email server you are finished sending lines of the email body
                            mailClient << endl << F(".") << endl; // end of mail
14  Using Arduino / Programming Questions / Re: Ethernet server fails (sometimes) on: August 18, 2014, 06:56:37 am
Here is the code I use to check the socket status.
Code:
#include <utility/w5100.h>

byte socketStat[MAX_SOCK_NUM];

void ShowSockStatus()
{
  for (int i = 0; i < MAX_SOCK_NUM; i++) {
    Serial.print(F("Socket#"));
    Serial.print(i);
    uint8_t s = W5100.readSnSR(i);
    socketStat[i] = s;
    Serial.print(F(":0x"));
    Serial.print(s,16);
    Serial.print(F(" "));
    Serial.print(W5100.readSnPORT(i));
    Serial.print(F(" D:"));
    uint8_t dip[4];
    W5100.readSnDIPR(i, dip);
    for (int j=0; j<4; j++) {
      Serial.print(dip[j],10);
      if (j<3) Serial.print(".");
    }
    Serial.print(F("("));
    Serial.print(W5100.readSnDPORT(i));
    Serial.println(F(")"));
  }
}
A socket status list:
0x0 = available.
0x14 = socket waiting for a connection
0x17 = socket connected to a client if a server, or a server if a client.
0x22 = UDP socket.

Here is the code I use to check available SRAM.
Code:
int freeRam() {
  extern int __heap_start,*__brkval;
  int v;
  return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int) __brkval);  
}
Use it like this:
Code:
Serial.print(F("Free RAM: "));
Serial.println(freeRam());
Call it immediately before where you feel the program is failing.

edit: And here is my server sketches I posted to the playground. The older (second) example is closer to yours.
http://playground.arduino.cc/Code/WebServerST
15  Using Arduino / Networking, Protocols, and Devices / Re: Arduino ethernet shield connected to laptop. It works, but... on: August 18, 2014, 06:48:46 am
I can't test your setup because i don't have a Windows box with a wifi connection. I'm a Linux guy.

I still believe you have a firewall problem in the laptop.
Pages: [1] 2 3 ... 399