Update ThingSpeak Channels and Twitter with Arduino Ethernet

This tutorial demonstrates how to use the Arduino to read in analog inputs and update a ThingSpeak Channel by sending an HTTP POST via the Arduino Ethernet Shield or the Arduino Ethernet (all-in-one). The analog input can be the output of a sensor, like a light sensor or temperature sensor. In addition to sensor data logging, this sketch updates a Twitter status every hour via ThingTweet.

Arduino Ethernet + ThingSpeak

ThingSpeak Channel and Twitter Updater Sketch

This Arduino sketch takes the value of Analog Pin 0 and Analog Pin 1 and updates Field 1 and Field 2 of a ThingSpeak Channel using the ThingSpeak API. It also updates a Twitter status every hour with the latest sensor value via ThingTweet.

ThingSpeak_Channel_and_
Twitter_Updater.pde [download]

One comment

  1. Hello some body help me!!! please… a try to use this program but wen i made the compilate on arduino this fail… and i dont know understand why, i set up my Api key for thingpeak and twitter…what more i have to do… am not expert, but this is not tipical problem of libraries… help…

    this is the error: (i just call to the program Update)

    Update.ino:43:25: error: no matching function for call to ‘Client::Client(byte [4], int)’
    Update.ino:43:25: note: candidates are:
    In file included from /usr/share/arduino/libraries/Ethernet/EthernetClient.h:5:0,
    from /usr/share/arduino/libraries/Ethernet/Ethernet.h:7,
    from Update.ino:29:
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:7:7: note: Client::Client()
    class Client : public Stream {
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:7:7: note: candidate expects 0 arguments, 2 provided
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:7:7: note: Client::Client(const Client&)
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:7:7: note: candidate expects 1 argument, 2 provided
    Update.ino:43:8: error: cannot declare variable ‘client’ to be of abstract type ‘Client’
    In file included from /usr/share/arduino/libraries/Ethernet/EthernetClient.h:5:0,
    from /usr/share/arduino/libraries/Ethernet/Ethernet.h:7,
    from Update.ino:29:
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:7:7: note: because the following virtual functions are pure within ‘Client’:
    class Client : public Stream {
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:12:18: note: virtual size_t Client::write(uint8_t)
    virtual size_t write(uint8_t) =0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:13:18: note: virtual size_t Client::write(const uint8_t*, size_t)
    virtual size_t write(const uint8_t *buf, size_t size) =0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:14:15: note: virtual int Client::available()
    virtual int available() = 0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:15:15: note: virtual int Client::read()
    virtual int read() = 0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:17:15: note: virtual int Client::peek()
    virtual int peek() = 0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:18:16: note: virtual void Client::flush()
    virtual void flush() = 0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:10:15: note: virtual int Client::connect(IPAddress, uint16_t)
    virtual int connect(IPAddress ip, uint16_t port) =0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:11:15: note: virtual int Client::connect(const char*, uint16_t)
    virtual int connect(const char *host, uint16_t port) =0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:16:15: note: virtual int Client::read(uint8_t*, size_t)
    virtual int read(uint8_t *buf, size_t size) = 0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:19:16: note: virtual void Client::stop()
    virtual void stop() = 0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:20:19: note: virtual uint8_t Client::connected()
    virtual uint8_t connected() = 0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:21:11: note: virtual Client::operator bool()
    virtual operator bool() = 0;
    ^
    Update.ino: In function ‘void updateThingSpeak(String)’:
    Update.ino:97:22: error: no matching function for call to ‘Client::connect()’
    Update.ino:97:22: note: candidates are:
    In file included from /usr/share/arduino/libraries/Ethernet/EthernetClient.h:5:0,
    from /usr/share/arduino/libraries/Ethernet/Ethernet.h:7,
    from Update.ino:29:
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:10:15: note: virtual int Client::connect(IPAddress, uint16_t)
    virtual int connect(IPAddress ip, uint16_t port) =0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:10:15: note: candidate expects 2 arguments, 0 provided
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:11:15: note: virtual int Client::connect(const char*, uint16_t)
    virtual int connect(const char *host, uint16_t port) =0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:11:15: note: candidate expects 2 arguments, 0 provided
    Update.ino: In function ‘void updateTwitterStatus(String)’:
    Update.ino:133:22: error: no matching function for call to ‘Client::connect()’
    Update.ino:133:22: note: candidates are:
    In file included from /usr/share/arduino/libraries/Ethernet/EthernetClient.h:5:0,
    from /usr/share/arduino/libraries/Ethernet/Ethernet.h:7,
    from Update.ino:29:
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:10:15: note: virtual int Client::connect(IPAddress, uint16_t)
    virtual int connect(IPAddress ip, uint16_t port) =0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:10:15: note: candidate expects 2 arguments, 0 provided
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:11:15: note: virtual int Client::connect(const char*, uint16_t)
    virtual int connect(const char *host, uint16_t port) =0;
    ^
    /usr/share/arduino/hardware/arduino/cores/arduino/Client.h:11:15: note: candidate expects 2 arguments, 0 provided

Leave a comment