I am trying to make an arduino weather alert, from this website: http://api.openweathermap.org/data/2.5/weather?q=Melbourne,au and I need to find the contents of the quotation marks in "weather" after "main".
Currently my code looks like this:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "api.openweathermap.org";
IPAddress ip(192,168,1,77);
EthernetClient client;
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
delay(1000);
if (client.connect(server, 80)) {
client.println("GET /data/2.5/weather?q=Melbourne,au HTTP/1.1");
client.println("Host: api.openweathermap.org");
client.println("Connection: close");
client.println();
}
else {
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
client.stop();
while(true);
}
}
and it returns:
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 07 Jun 2015 21:17:44 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: close
X-Source: redis
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST
1d2
{"coord":{"lon":144.96,"lat":-37.81},"sys":{"message":0.0117,"country":"AU","sunrise":1433626204,"sunset":1433660872},"weather":[{"id":800,"main":"Clear","description":"Sky is Clear","icon":"01n"}],"base":"stations","main":{"temp":284.532,"temp_min":284.532,"temp_max":284.532,"pressure":1011.27,"sea_level":1030.68,"grnd_level":1011.27,"humidity":80},"wind":{"speed":4.43,"deg":331.501},"clouds":{"all":0},"dt":1433711139,"id":2158177,"name":"Melbourne","cod":200}
0
(which is correct)
But for this output I want it to say: Clear
(because that's what's in the quotation marks in "weather" after "main")
thanks in advance for the help.