Thingspeak as a Data Source

Please excuse my naivety. I have very many (~10) sensors of my own design using ESP8266, which have been posting 8 fields of numerical data quite happily to thingspeak.com for several years. Whilst there is no specific problem with that, I am aware you can extract the time series data from them using a json query. Can someone please point me towards a working example using thingspeak, telegraf, influxdb and grafana where the data source is a thingspeak json request and the data is then stored any analysed locally (to me) for example on a raspberry pi.
I would prefer to do that, but I realise I could rewrite all the sensors applications to post more directly but I would prefer not to. Thanks in advance.

Hello @Paul_Stross,
Welcome!
You’ll probably want to use this plugin:

With the json data format:

This blog might help you understand some basics about InfluxDB (complete with an example about writing data with the telegraf tail plugin):

You might want to start getting familiar with InfluxDB by signing up for a free tier and importing a sample dataset
https://cloud2.influxdata.com/signup
https://docs.influxdata.com/influxdb/v1.8/query_language/sample-data/

Thanks for the personal reply. It is much appreciated. I have come across some of those tutorials, but I think I would do better adapting someone’s code rather than trying to hack my first attempt, as it is all so new to me. I can show you the sort of data I am trying to access from my sensors…
That would have been helpful I realise!

https://thingspeak.com/channels/135163/

I think the link should work for you. There are so many channels I had hoped someone would have cracked the exporting problem already.

Many thanks for your help. Kind regards. And if you can get me started with some working code, that would be great.

Paul

@Paul_Stross

I would not be aware that there is a ready-made Thingspeak plugin for Telegraf.

Nevertheless, it is possible to query Thingspeak data with Telegraf. However, you will have to invest some time. Read the documentation of Thingspeak and the related Telegraf plugins and configure the Telegraf plugins.

As far as I know Thingspeak provides a quite extensive REST API and a MQTT interface. Both can be queried with the corresponding Telegraf plugins.

1 Like

Thank you so much for replying. I know it should be possible and I am aware of what you are saying, but I don’t think I have sufficient knowledge of all of the links to make a working chain. However, I hoped to stand on the shoulders of others. I know that is cheeky, but that is my state of experience. Paul

Also I think such a plugin would have a really big base for many others who would find it of utility as ThingSpeak captures time series data in a very stereotypical form. Paul

@Paul_Stross

I think there probably won’t be a Thingspeak plugin for Telegraf for the following reasons:

  1. I doubt that there are many users who use Thingspeak together with Influxdb. Because Thingspeak already has its own display and analysis capabilities.
  2. It is not so easy to write the plugin in a way that it fits as many applications as possible.
  3. There is not necessarily a need for this plugin. All building blocks are already available (REST, MQTT) to realize this with existing Telegraf input plugins (http, mqtt). You just have to put some time into the right configuration.

There are huge numbers of ThingSpeak channels all of which produce quite stereotypical data in their 8 fields. They accumulate a lot of data too. I know the tools exist to help, so it should be possible. Yes, there is a graphing possibility in ThingSpeak. My post asked if anyone had tackled the data transfer. I think you see this problem differently from me. You are already familiar with making working examples, but it is different if you are trying to climb a different path on the learning curve on your own.
Paul