Using Sun Founder Ethernet shield & Uno to read JSON format weather data

I have used the ex: “JsonHttpClient.ino” to read the example data posted on arduinojson.org. The code section below shows the simple commands to connect to the server and access the example data:

// Send HTTP request
** client.println(F(“GET /example.json HTTP/1.0”));**
** client.println(F(“Host: arduinojson.org”));**
** client.println(F(“Connection: close”));**
** if (client.println() == 0) {**
** Serial.println(F(“Failed to send request”));**
** return;**
** }**

I receive the response:

Connected!
Response:
Sensor:
gps
Time:
1351824120
Data:
48.756080
2.302038

Then, I modified the example code to read data from an Australian Weather Service Website that has JSON formatted data: http://www.bom.gov.au/fwo/IDQ60901/IDQ60901.95551.json
I can open this website in Google and see the data easily.

In this first attempt using my ethernet shield t oread the data, I was only trying to read the “header”.

First, I used the JSON online assistant to recalculate the JSON buffer sizes for the larger weather data file.

But when I run the code there is a problem connecting to the server. My error message displayed on my serial monitor is shown below.

Connecting…
Connected!
Unexpected response: HTTP/1.0 403 Forbidden

This is the complete code I used (I also include as an attachment):

// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
//
// This example shows how to parse a JSON document in an HTTP response.
// It uses the Ethernet library, but can be easily adapted for Wifi.
#include <ArduinoJson.h>
#include <Ethernet.h>
#include <SPI.h>
void setup() {
** // Initialize Serial port**
** Serial.begin(9600);**
** while (!Serial) continue;**
** // Initialize Ethernet library**
** byte mac = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};**
** if (!Ethernet.begin(mac)) {**
** Serial.println(F(“Failed to configure Ethernet”));**
** return;**
** }**
** delay(1000);**
** Serial.println(F(“Connecting…”));**
** // Connect to HTTP server**
** EthernetClient client;**
** client.setTimeout(10000);**
** if (!client.connect(“www.bom.gov.au”, 80)) {**
** Serial.println(F(“Connection failed”));**
** return;**
** }**
** Serial.println(F(“Connected!”));**
** // Send HTTP request**
** client.println(F(“GET /fwo/IDQ60901/IDQ60901.95551.json HTTP/1.0”));**
** client.println(F(“Host: www.bom.gov.au”));**
** client.println(F(“Connection: close”));**
** if (client.println() == 0) {**
** Serial.println(F(“Failed to send request”));**
** return;**
** }**
** // Check HTTP status**
** char status[32] = {0};**
** client.readBytesUntil(’\r’, status, sizeof(status));**
** if (strcmp(status, “HTTP/1.1 200 OK”) != 0) {**
** Serial.print(F("Unexpected response: "));**
** Serial.println(status);**
** return;**
** }**
** // Skip HTTP headers**
** char endOfHeaders = “\r\n\r\n”;**
** if (!client.find(endOfHeaders)) {**
** Serial.println(F(“Invalid response”));**
** return;**
** }**
** // Allocate JsonBuffer**
** // Use arduinojson.org/assistant to compute the capacity.**
** //const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60;**
const size_t capacity = 2JSON_ARRAY_SIZE(1) + JSON_ARRAY_SIZE(147) +
** JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(4) +**
JSON_OBJECT_SIZE(8) + 147
JSON_OBJECT_SIZE(35);
** DynamicJsonBuffer jsonBuffer(capacity);**
** // Parse JSON object**
** JsonObject& root = jsonBuffer.parseObject(client);**
** if (!root.success()) {**
** Serial.println(F(“Parsing failed!”));**
** return;**
** }**
** // Extract values**
** Serial.println(F(“Response:”));**
** Serial.println(F(“header:”));**
__ Serial.println(root[“header”].as<char*>());__
** // Disconnect**
** client.stop();**
}
void loop() {
** // not used in this example**
}

Could someone help me t understand why I can connect to the arduinojson example site but not my weather site?
Thanks!

JsonHttpClientToowoomba.ino (2.35 KB)

When I hit that site, I get JSON that is ~130k in size. There is no way an UNO could read all that. There isn't enough memory.

Also, please read the first posts at the top of the forum about how to post your code using code tags.