ThingSpeak Client to Connect Arduino to the Internet

Being able to save data over extended periods is my top item. Comparing this year to last, this month to last, that kind of thing. Also, being able to import data for the past so one can bring in older data. Charts and stuff are cool, but if you don't have the data from the past you can't make comparisons.

So this is basically a MySQL server, just wrapped up and easier to use???

I got my Arduino communicating with MySQL already, and writing to the database, just gotta make it look pretty and have PHP read from it.

Is that what your service is basically providing?? A PHP front end and MySQL database?

Yes, you have the right idea ... there is a database component. It's a full web app with Charts, Apps, and Plugins that extend that base functionality - much like Wordpress is a PHP/MySQL front-end for blog posts with plugins. The goal is to make it easy and not have to run a local server if you don't want to or put this on a shared web host. An import tool is in progress so you can use the visualization tools if you have data already maybe from an SD card logger or something like that.

Sounds like you are making good progress with your project. Maybe they will link...

will this work without an ethernet shield? Just straight USB serial?

Thanks for all of the feedback over at our site.

Since we released, we have added many more features and tutorials. So, if it was no so clear a few months ago, I think you can see the direction that we are going.

Here's a link to the tutorials: http://community.thingspeak.com/tutorials/

The biggest addition to our apps is called ThingHTTP - which allows you to send a simple command to the app, then the app does the connection to the resource that you want to get or command. It also can parse the response so you don't have to have an XML or JSON parser on the arduino. We hope that it simplifies connections to web services and saves code space on the mcu.

We also released the API to GitHub, so you can roll your own "ThingSpeak" on your home network.

Have fun!

polishdude20:
will this work without an ethernet shield? Just straight USB serial?

polishdude20,
I wrote a windows application that I call Seriot to communicate with an Arduino (or any other serial device) via usb/serial. The application logs the data to a file locally and optionally can send it to ThingSpeak. It's easy to configure and you can run it in several different modes depending on your needs.

You can read more and download it here:
http://nuewire.com/seriot/

willnue

Looks promising.
Will definately give it a try, now that I got my ethernet shield :slight_smile:

The things that I am interested in would be to
-store/view historical data of my setup.
-add alarm conditions to various signals that are monitored, and send notifications based on the alarm conditions.
-schedule actions / timed actions for home control etc (ie switching on the ligt at 7 am...)

Will get back to you when I test further :slight_smile:

Hi again.

So I have had a go at gathering some temperature data, and storing them on ThingSpeak.
Works great, so far... (except that for some reason, it stopped logging at 04:00 this morning)... anyway. :drooling_face:

If the developers over at ThingSpeak are listening in, I have a feature request:

Add a display, that will only show the latest reading from the chart/field. -and display it as a number in a little neat box (no graph).
That way, for any stored data on ThingSpeak, it would be possible to see the historical data, and also the most current value.

The same idea for digital values: make a text display, where you can assign some text for each value. Example: 0 = off / 1 = on etc...
That way it would be really easy to build up a webpage, and include all the info from ThingSpeak, to show current and historical status of whatever is monitored.

Nice service by the way 8)

Spumanti,
You can use the ThingSpeak API to get the last value for a given channel.

Retrieving the Last Entry in Channel Feed
Method: POST or GET
Feed URL: http://api.thingspeak.com/channels/(channel_id)/feed/last.(format)

For example to get the last value of my Outdoor temperature sensor (public channel #233) click the following link:
http://api.thingspeak.com/channels/233/feed/last

You could use some Javascript to go get the last value then parse the result and format it however you like on your web page. Note, if you don't want to make your channel public you can also generate a Read API key and pass that to the API. Check out the ThingSpeak API docs for more info:

You could also use one of their existing plugins to render a Google Gauge. See the following post for more info:

willnue

Hi,

can you pls post a tutorial on how to set up a GPRS shield to log data to Thingspeak ??

Thank you

hi I was wondering is it possible to send data FROM Thingspeak TO the Arduino? Thanks

I see traffic from this old post is still making it to ThingSpeak, so I wanted to post an update.

We have released an official library for Arduino. This library makes it easier to get sketches up and running that send data to ThingSpeak or read data from ThingSpeak.

Installation... In the Arduino IDE, choose Sketch/Include Library/Manage Libraries. Click the ThingSpeak Library from the list, and click the Install button.

The library includes several examples to help you get started.

  • CheerLights: Reads the latest CheerLights color on ThingSpeak, and sets an RGB LED.
  • ReadLastTemperature: Reads the latest temperature from the public MathWorks weather station in Natick, MA on ThingSpeak.
  • ReadPrivateChannel: Reads the latest voltage value from a private channel on ThingSpeak.
  • ReadWeatherStation: Reads the latest weather data from the public MathWorks weather station in Natick, MA on ThingSpeak.
  • WriteMultipleVoltages: Reads analog voltages from pins 0-7 and writes them to the 8 fields of a channel on ThingSpeak.
  • WriteVoltage: Reads an analog voltage from pin 0, converts to a voltage, and writes it to a channel on ThingSpeak.

Hi all,

Version 1.1.0 of the libraries Has mentions now supports ESP8226 devices, the Particle Electron (coming soon!).

You can use these libraries directly from within the Arduino and Particle IDEs.

All the best,
-Rob

So I'm a big time newb to the IoT world and HTTP. I'm trying to read my status on Thingspeak using an ESP8266 running Arduino. I've edited one of the examples to try to do what I want, but I don't seem to have things right. I've also tried sending my tweet as a string to a field on Thingspeak so that I could use the built in "readField" command(s). Any help is greatly appreciated. I'm running road block after roadblock here.

#include "ThingSpeak.h"

#ifdef ARDUINO_ARCH_ESP8266
  #include <ESP8266WiFi.h>
    char ssid[] = "<Work Sucks, Quit Now>";          //  your network SSID (name) 
    char pass[] = "<Seriously Quit Now>";            // your network password
  int status = WL_IDLE_STATUS;
  WiFiClient  client;
#endif

long myChannelNumber = 78204;
const char * myReadAPIKey = "HP5KTQQFBRTT7FRU";

void setup() {
  #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ESP8266)
    Serial.begin(115200);
    #ifdef ARDUINO_AVR_YUN
      Bridge.begin();
    #else
      #if defined(USE_WIFI_SHIELD) || defined(ARDUINO_ARCH_ESP8266)
        WiFi.begin(ssid, pass);
      #else
        Ethernet.begin(mac);
      #endif
    #endif
  #endif

  ThingSpeak.begin(client);
}

void loop() {
  // Read the latest value from field 1 of channel 31461
 client.print("GET http://api.thingspeak.com/channels/78204/status.json?api_key=SSE5518BZGNQ538K");
 delay (10);
 String Tweet = client.read();
 // String sTweet = ThingSpeak.readStringField(myChannelNumber,2);
 //String sTweet = Tweet;
  int nField1 = ThingSpeak.readIntField(myChannelNumber, 1);
  int nField2 = ThingSpeak.readIntField(myChannelNumber, 2);
  
  #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ESP8266)
    Serial.print("Latest tweet is: "); 
    Serial.print(Tweet);
    //Serial.print(sTweet);
    Serial.print (nField1);
    Serial.print (nField2);
    Serial.println(" , holy crap it worked!"); 
   //sTweet = client.print("GET api.thingspeak.com/apps/thinghttp/send_request?api_key=SSE5518BZGNQ538K");
   Serial.println(Tweet);
   
  #endif
  delay(30000);
}

Hi TipsEZ,

Love to help. Just a note -- it's best if you hide your API keys when you post, or anyone can access your private channel.

The ThingSpeak library is designed to hide all the HTTP stuff from you.

I can't quite figure out what your goal is from the code you've posted. If you want to read a string from a provate channel from ThingSpeak, check out the ReadPrivateChannel example. Try getting that to work first without any changes. Then switch it to read your channel. Since it looks like your channel has a text string in it, you'll need to change to the readStringField method.

You may find this ThingSpeak video helpful: What is ThingSpeak? - MATLAB

-Rob

Thank you for your reply. What I am trying to do is send a tweet from my phone, that activitates a stepper motor ran from an Adafruit Huzzah (ESP8266). So I have my thing speak set up currently, per examples, so that when I Tweet something like "TweetControl, #FlagsHalfStaff" it posts this tweet as a status update on my Thingspeak page. When I try to do a "GET" from Thingspeak I get nothing back.

I'd really like to parse my Tweet, similiar to the example, so that anything after the # sign is dropped into Field 2 as a string, then simply use the "readStringField(myChannel, 2)" command.

Hi! I would like to ask if this would work on ESP8266 Wifi Module.

Yes. The latest version (1.1.1) works with esp8266 devices. I tested it with a SparkFun Dev board.

Good luck!

-Rob

I am facing same issue. I checked above code but its displaying 72 as received data which is wrong data.

So, can any one help me out for solving issue or we can't read back data from thingspeak.

Hi -- post some code and let us know what device you're using... Make sure you hide your API key. Are you getting a success/failure code? Do the demos work?

-Rob