# ThingSpeak Live Chart, multi channel, second axis, historical data, csv export

**URL:** <https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485>\
**Category:** Showcase\
**Created:** [January 24, 2014, 10:23pm UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485 "2014-01-24T22:23:41Z")\
**Posts on this page:** 17\
**Page:** 2

<div class="post-metadata">

**Author:** ![cweinhofer](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/cweinhofer/32/618179_2.png) [@cweinhofer](https://forum.arduino.cc/u/cweinhofer)\
**Post date:** [October 5, 2018, 11:32am UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/21 "2018-10-05T11:32:25Z")

</div>

> easydoor:  
> Can someone tell me how can I manually chose the colour for new graphs?  
> Thx

I am wondering the same thing. Anyone know where the line colors are set?

---

<div class="post-metadata">

**Author:** ![easydoor](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@easydoor](https://forum.arduino.cc/u/easydoor)\
**Post date:** [June 8, 2019, 1:56am UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/22 "2019-06-08T01:56:38Z")

</div>

Aprox 3-4 months this script do not update automaticly, just if I reload a browser. I tried Chrome, Firefox..but same.  
In developer option of browser I see that it really updateing every 15second but I got error code:

Request URL:[https://www.thingspeak.com/channels/579443/feed/last.json?callback=jQuery31105319498312513714\_1559958872281&amp;offset=0&amp;location=false;key=xxxxxxxxxxxxxxxxx&\_=xxxxxxxxxxxxxxx](https://www.thingspeak.com/channels/579443/feed/last.json?callback=jQuery31105319498312513714_1559958872281&amp;offset=0&amp;location=false;key=xxxxxxxxxxxxxxxxx&_=xxxxxxxxxxxxxxx)  
Request method:GET  
Remote address:52.2.102.156:443  
Status code:  
301  
Version:HTTP/1.1

So error code 301 Moved Permanently. I read on google that it means that some links are not accessable any more.  
Can someone fix this?  
Thx

---

<div class="post-metadata">

**Author:** ![zoomx](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zoomx/32/213669_2.png) [@zoomx](https://forum.arduino.cc/u/zoomx)\
**Post date:** [June 11, 2019, 1:16pm UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/23 "2019-06-11T13:16:29Z")

</div>

If I am not wrong it mean that original code used http instead of https that now is mandatory.

---

<div class="post-metadata">

**Author:** ![easydoor](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@easydoor](https://forum.arduino.cc/u/easydoor)\
**Post date:** [June 12, 2019, 12:38am UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/24 "2019-06-12T00:38:06Z")

</div>

> zoomx:  
> If I am not wrong it mean that original code used http instead of https that now is mandatory.

Thx for replay..  
All thingspeak links in codes are with https.  
Do u have any other suggestion?

---

<div class="post-metadata">

**Author:** ![zoomx](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zoomx/32/213669_2.png) [@zoomx](https://forum.arduino.cc/u/zoomx)\
**Post date:** [June 12, 2019, 6:57am UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/25 "2019-06-12T06:57:13Z")

</div>

Sorry, I wrote a complete useless response!

I tested both the original page and the modified one by Mr\_ToR.  
You are right, it didn't update but I get this error  
net::ERR\_ABORTED 422 (Unprocessable Entity)

```cpp
GET https://thingspeak.com/channels/9354/feed/last.json?callback=jQuery191003508808604683611_1560321345885&amp;offset=0&amp;location=false;key=XXXXXXXXXXXXXXXX&_=1560321345892 net::ERR_ABORTED 422 (Unprocessable Entity)

```

Unfortunately I am not able to spot the error that should be in this line

```cpp
 $.getJSON('https://www.thingspeak.com/channels/'+channelKeys[channelIndex].channelNumber+'/feed/last.json?callback=?&amp;offset=0&amp;location=false;key='+channelKeys[channelIndex].key, function(data)

```

after last.json since till json I get the last data. My suspect is on the callback.

---

<div class="post-metadata">

**Author:** ![easydoor](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@easydoor](https://forum.arduino.cc/u/easydoor)\
**Post date:** [June 15, 2019, 11:30pm UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/26 "2019-06-15T23:30:53Z")

</div>

True..I realised the same. But is tehre anyone who can give us advise or change those few lines of code to work again?  
Btw I getting two error messages:  
Status code: 422 Unprocessable Entity  
and  
Status code: 301 Moved Permanently

---

<div class="post-metadata">

**Author:** ![easydoor](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@easydoor](https://forum.arduino.cc/u/easydoor)\
**Post date:** [June 16, 2019, 7:58am UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/27 "2019-06-16T07:58:59Z")

</div>

Btw..I asked the same question on thingspeak thread and I got explanation that "Callback Parameter Deprecated" is from now deprecated. Look at link:

> **[ThingSpeak Community](https://www.mathworks.com/matlabcentral/topics/thingspeak.html)**
>
> The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things IoT applications. Find project discussions, tutorials, and answers to technical questions about your cloud-based project.

The post number 9.  
He even mentioned link for cahnges at:  
[https://ch.mathworks.com/help/thingspeak/release-notes.html](https://ch.mathworks.com/help/thingspeak/release-notes.html)

---

<div class="post-metadata">

**Author:** ![easydoor](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@easydoor](https://forum.arduino.cc/u/easydoor)\
**Post date:** [June 16, 2019, 9:09am UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/28 "2019-06-16T09:09:13Z")

</div>

Ok, it seams to be that I have enough knowledge to fix. 🙂  
I realised with help of:  
[https://ch.mathworks.com/help/thingspeak/release-notes.html](https://ch.mathworks.com/help/thingspeak/release-notes.html)  
with R2019a and their explanation:

```arduino
Callback Parameter Deprecated

    JSONP is no longer supported by the ThingSpeak API.

    If your code uses the callback parameter in a request to api.thingspeak.com, remove callback=? from the URL.

    For private channels, provide the read API key as part of the URL (for example ?api_key=READ_API_KEY). Public channels do not require an API key.

    For more information, see https://community.thingspeak.com/forum/announcements/jsonp-requests-callback-parameter-are-deprecated/#p8653.

```

that u need to modify next lines in this script from top of page:  
line: **93,149** and **378**  
and to remove

```arduino
callback=?

```

from line as to replace

```arduino
www

```

with

```arduino
api

```

.  
Example:  
Before (line 93):

```arduino
$.getJSON('https://www.thingspeak.com/channels/'+channelNumber+'/feed.json?callback=?&offset=0&results=2500;key='+key, function(data)

```

After (line 93):

```arduino
$.getJSON('https://api.thingspeak.com/channels/'+channelNumber+'/feed.json?&offset=0&results=2500;key='+key, function(data)

```

Repeat for all of three line. I realised that second line giving the error 301 and first 422

---

<div class="post-metadata">

**Author:** ![zoomx](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zoomx/32/213669_2.png) [@zoomx](https://forum.arduino.cc/u/zoomx)\
**Post date:** [June 17, 2019, 12:24pm UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/29 "2019-06-17T12:24:31Z")

</div>

Well done!  
So callback is related to error 422 and www to error 301!

I made the same changes and don't get errors any more.

Tanks!

PS. Take care that the read API is in clear text on the source HTML page.

---

<div class="post-metadata">

**Author:** ![paulie\_iwin](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@paulie\_iwin](https://forum.arduino.cc/u/paulie_iwin)\
**Post date:** [December 14, 2019, 9:53pm UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/30 "2019-12-14T21:53:38Z")

</div>

Hello everyone,

Has anyone managed to use the code as a Plugin that is displayed in Channel view?

For me there is no data loaded when I am using it as a Plugin in Channel view on [ThingSpeak.com](http://ThingSpeak.com)  
I can only get data to load as a standard .html file loaded in a browser.

---

<div class="post-metadata">

**Author:** ![crave](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@crave](https://forum.arduino.cc/u/crave)\
**Post date:** [April 22, 2020, 5:38pm UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/31 "2020-04-22T17:38:24Z")

</div>

Hello, is anybody able to have two charts for the same channel on the same page? I managed to have two charts but only one is going to be displayed the other is blank.

if some one has an example to share !

thanks

---

<div class="post-metadata">

**Author:** ![Xstrudle](https://avatars.discourse-cdn.com/v4/letter/x/7993a0/32.png) [@Xstrudle](https://forum.arduino.cc/u/Xstrudle)\
**Post date:** [April 15, 2021, 3:35am UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/32 "2021-04-15T03:35:01Z")

</div>

First I must thank you for providing a fix for the "getJSON request failed!" error.

Sadly, today it has returned - I wonder what might have changed at Thingspeak to once again break this fantastic graphing tool.

---

<div class="post-metadata">

**Author:** ![easydoor](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@easydoor](https://forum.arduino.cc/u/easydoor)\
**Post date:** [April 15, 2021, 10:02am UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/33 "2021-04-15T10:02:03Z")

</div>

Hello.  
I have the same problem.  
function getJSON yelling error in a web browser: getJSON request failed!  
Is there any fix for this?  
Thx

---

<div class="post-metadata">

**Author:** ![paulie\_iwin](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@paulie\_iwin](https://forum.arduino.cc/u/paulie_iwin)\
**Post date:** [April 15, 2021, 11:24am UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/34 "2021-04-15T11:24:06Z")

</div>

Hello erveryone,  
there currently seems to be a CORS Missing Allow Origin Error.

> **[Reason: CORS header 'Access-Control-Allow-Origin' missing - HTTP | MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSMissingAllowOrigin)**
>
> The response to the CORS request is missing the required
> Access-Control-Allow-Origin header, which is used to determine whether
> or not the resource can be accessed by content operating within the current origin.

There are more details from MathWorks here:

> **[starting to get ERROR : blocked by CORS policy -](https://www.mathworks.com/matlabcentral/discussions/thingspeak/134546-starting-to-get-error-blocked-by-cors-policy)**
>
> Find the best topics about MATLAB, Simulink, and related products.

---

<div class="post-metadata">

**Author:** ![easydoor](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@easydoor](https://forum.arduino.cc/u/easydoor)\
**Post date:** [April 15, 2021, 12:04pm UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/35 "2021-04-15T12:04:24Z")

</div>

Sadly this does not help. I tried to put the line: `Header set Access-Control-Allow-Origin *`  
in apache.conf and activate in ssh mod\_headers with the command: `a2enmod headers` and restarted the apache2, but the error is still here.  
Or I misunderstand?

---

<div class="post-metadata">

**Author:** ![paulie\_iwin](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@paulie\_iwin](https://forum.arduino.cc/u/paulie_iwin)\
**Post date:** [April 15, 2021, 7:26pm UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/36 "2021-04-15T19:26:21Z")

</div>

The issue is fixed now.  
I am using this updated HighCharts html code:

> <https://github.com/paultheman/BME280_webserver/blob/master/index.htm>

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 13, 2021, 7:27pm UTC](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485/37 "2021-08-13T19:27:08Z")

</div>

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.

[Previous page](https://forum.arduino.cc/t/thingspeak-live-chart-multi-channel-second-axis-historical-data-csv-export/207485.md?page=1)
