Re: Twitter shutting down basic auth June 30

Home Forums Botanicalls Community Twitter shutting down basic auth June 30 Re: Twitter shutting down basic auth June 30

#1779
maathieu
Participant

Ok guys,

It is possible indeed to get the “leaf” working using SuperTweet. Since some people seem to have trouble to get it to work, here’s a tutorial compiled by the LOG, Grenoble’s Hackerspace, from many different internet sources, which I tried to quote accordingly.

Special thanks to Meik Mense for the authentication mod, and to the earlier posters here for the initial pointers to SuperTweet and beyond.

Of course, we decline all responsibility, yadda yadda yadda. Double-check everything!

What you will need

Hardware

  • One FTDI 3.3v cable (can be bought on several online stores). 3.3v is important, maybe 5v will fry your leaf.

Software

  • Install the Arduino environment suitable to your operating system (download here)
  • Get the Botanicalls Source Code v2.15 (download here)

Getting started

  1. First of all, you will need to register on SuperTweet. It’s actually easy: go to SuperTweet and login with your Botanicalls twitter account (Botanicalls0XXX) by clicking on “Sign in with Twitter.” Follow the instructions and “Activate” your account. You will be asked to set a new password (different from your twitter account’s password), do so and write it down – you’ll need it later.
  2. Then, unplug your leaf from the power supply and plug it in the FTDI cable, following the instructions of the Customize page of this website. Holding the leaf upwards (network connector going towards the ground), the connector should be plugged on the pins that are on the right of the board. There is a small “blk” marking at the bottom and it should be matched to the black wire of the connector.
  3. Then, plug the USB end of the FTDI cable into your computer. You’ll see your leaf blinking and it’s going to go live again.
  4. Unzip the source code you got earlier in a convenient directory.
  5. Finally, start the Arduino environment and open the said source code (File > Sketchbook > Open…)

Modify the code

Until Botanicalls integrates those modifications into a new firmware, you will need to patch the code manually. Here’s what you need to edit:

In BotanicallsTwitter:

At line 8 replace:

#define VERSION "2.15" // initial leaf board

by:

#define VERSION "2.15c" // initial leaf board

(this will be useful later)

At line 12 change:

#define USERNAMEPASS "username:password" // your twitter username and password, seperated by a :

And put in your Twitter username and the password you defined in SuperTweet (NOT your Twitter password!).

At line 54 change the IP address:

#define IPADDR "128.121.146.100" // twitter.com

becomes

#define IPADDR "66.180.175.246" // api.supertweet.net

At line 56 replace:

#define HTTPPATH "/statuses/update.xml" // the person we want to follow

by

#define HTTPPATH "/1/statuses/update.xml" // the person we want to follow

And finally uncomment the two lines 121 and 122:

// uint8_t response = posttweet("Botanicalls!"); // send a startup message to Twitter

// notify(response);

so you get:

uint8_t response = posttweet("Botanicalls!"); // send a startup message to Twitter

notify(response);

This will allow for immediate testing.

In checks:

At line 111 replace:

char *str3 = "%";

by

char *str3 = "%25";

This is to correct a bug (strings should be urlencoded).

in twitter:

Replace line 167 and following:

// next, the authentication

putstringSS("Host: ");

putstringSS_nl(IPADDR);

putstring("Host: ");

putstring_nl(IPADDR);

putstringSS("Authorization: Basic ");

putstring("Authorization: Basic ");

mySerial.println(linebuffer);

Serial.println(linebuffer);

putstringSS("Content-Length: ");

mySerial.println(7+strlen(tweet), DEC);

putstring("Content-Length: ");

Serial.println(7+strlen(tweet), DEC);

putstringSS("nstatus=");

mySerial.println(tweet);

putstring("nstatus=");

Serial.println(tweet);

by the following:

// next, the authentication

putstringSS_nl("Host: api.supertweet.net");

putstring_nl("Host: api.supertweet.net");

putstringSS("Authorization: Basic ");

putstring("Authorization: Basic ");

mySerial.println(linebuffer);

Serial.println(linebuffer);

putstringSS_nl("Content-Type: application/x-www-form-urlencoded");

putstring_nl("Content-Type: application/x-www-form-urlencoded");

putstringSS("Content-Length: ");

mySerial.println(7+strlen(tweet), DEC);

putstring("Content-Length: ");

Serial.println(7+strlen(tweet), DEC);

putstringSS("nstatus=");

mySerial.println(tweet);

putstring("nstatus=");

Serial.println(tweet);

Credits to Meik Mense for the info (found here).

Compile and test

OK, now you’re done with the changes. What you need to do is threefold:

  1. CHANGE the BOARD by going in the Tools > Board menu and choose “Arduino Diecimila or Duemilanove w/ ATMega 168
  2. Click the “Verify” button (it’s the disk-shaped arrow button).
  3. If it doesn’t show any errors (you’ll get a “Binary Sketch size:…” message), click the “Upload to IO Board” button.
  4. If you get an error message during the upload, click the button again, wait for two seconds, then press the “reset” button of the leaf (it worked for me – see here for more info if you experience issues).
  5. If the upload is OK (no errors), click the “Serial Monitor” button. Wait for a while, the leaf initializes and then it will print “Botanicalls v2.15c”. If there is no “c” at the end, then it didn’t upload the new firmware correctly :(.
  6. Open Twitter and go to your Botanicalls account. You should see a new Tweet: “Botanicalls!”

If you get the “Botanicalls!” message above, then it’s ok, your leaf is now twittering through Supertweet. You can then unplug your USB cable, the FTDI cable and afterwards plug in your power supply, and your leaf is autonomous again.

Troubleshooting

If it doesn’t work, make sure to check the following:

First, press the “test” button, wait for ten-ish seconds, and refresh your twitter page. It should print the moisture level. Apparently, the “Botanicalls!” twitter printout will only work once every day (Twitter spam restrictions), so you need a different message, and the “test” button does just that.

  • Did you use the Twitter password or the SuperTweet password in your code? (hint: use the SuperTweet password)
  • Did you manage to upload the new code? (test by resetting your leaf and see if it prints “2.15c” in the Serial Monitor
  • Is your SuperTweet account active?

Aftermath

Botanicalls devs, I hope you’ll update your code soon enough with this info (or base yourself on it), because it’s a great project you have here and it would be nice to see it alive again. There are a few more things to do in the code IMHO, I didn’t have enough time for that:

  1. Finish the URLencoding: all the “space” characters should be coded with “+” or “%20”. It works without it, but it should be corrected.
  2. Change the “Botanicalls!” initial tweet so that it shows a random string (Botanicalls!whatever) at every reset. Would be useful for testing.
  3. Recode the “twitter” stuff so that it doesn’t hardcode the URL in the auth data (will ease portability to other third parties services)



New kits are here!

Categories

Pothos Plant Tweets

    Flickr Feed

    www.flickr.com
    More photos or video tagged with botanicalls on Flickr

    Meta