Working Twitter App with Time/date stamp

Others may find this useful:
I have modified an existing library to work with YiFi101.
It is called WiFi101Twitter. and is attached.

There are two included examples with YiFi101tweet2.ino being the most developed

The code to send a tweet is not difficult- I have included a local function option in the second library example.

Time is obtained using the new WiFi101 function WiFi.getTime(). (which is a bit buggy at present).
TimerOne.h can be dowloaded from:

You will need:

  1. A twitter account

  2. A token to post from http://arduino-tweet.appspot.com/oauth/twitter/login

  3. The TimerOne and WiFi101Twitter libraries

I only use the Mega2560, so do post on use with other Arduino versions.

The code for YiFi101tweet2.ino is too big to post inline, however here is the header for details of the setup:

// YiFi101tweet2.ino

// Useful link: http://arduino-tweet.appspot.com/

// tweet using amended Twitter library
  // <WiFi101Twitter.h> amended from:
    /*
    Gaurav Gupta
    https://github.com/gauravg11/arduinolibs/tree/master/Twitter_WiFi
    */

// Support for tweet without library using function mytwitter
  
// time/date support using WiFi101 function WiFi.getTime()
//    date/time stamp added to tweet if time is available
// time maintained using system library <time.h>
// time incremented using 1ms interrupt generated by library TimerOne.h 
// serial input parsed for new tweets
//    Serial '|' signifies newline and '>' signals send tweet
//           '|' = vertical bar, (shifted \), not 1, L or I
//    Signature defined by String Sig

// D.R.Patterson
// 21/12/2016

// *********** Getting Started *****************************
//  Create twitter account
//  Get a token to post a message using OAuth.
      /*
      http://arduino-tweet.appspot.com/oauth/twitter/login
      */ 
//  Install the library
// *********************************************************

#include <SPI.h>
#include <WiFi101.h>
#include <WiFi101Twitter.h>
#include <time.h>
#include <TimerOne.h>

const byte wifiSelect = 10; // YiFi101 select (active low)
int mystatus = WL_IDLE_STATUS;
boolean havewifi = true;

// ######### Modify this section ########################################

const byte sdSelect = 53;   // SD select (active low)

const char ssid[] = "xxxx"; // your network SSID (name)
                            // add password support/keyIndex if required
                            // and amend line with mystatus = WiFi.begin(ssid);

// Your Token to Tweet (get it from http://arduino-tweet.appspot.com/)
Twitter twitter("paste here");

// token for local tweet function 
const char *token = "and here";

// Message to post
String smsg = "Arduino tweet";  // tweet message
const String Sig = "John Doe";     // tweet signature

const boolean testmessage = false; // send initial test message using library & local function

// ######## End of modify ###############################################

boolean havetime = true;  // ntp time available

David

YiFi101Twitter.zip (6.49 KB)