Small example of how to post to Twitter

I imagine posting to Twitter will be part of the Planner eventually, but in case anyone is interested, here’s how to get the Imp to post to Twitter using

Create an account on and then create a new channel – choose "Arduino & other"

On the custom device screen name your device and choose “other” for "device is"

The other settings should be fine (HTTP Post etc).

You’ll then add a feed. Give it a name and choose "input - data flows from device to"

In the drop down for “what type of data” choose “text”.

Save the feed and click finish.

In the device settings choose “anything else” from the side menu and you’ll see instructions of how to POST to

Make a note of the feed id and then copy your API key.

Now go to this gist, copy the php code and save it as “opensense.php”- we need this to handle the post from the Planner and to then construct json to send to

Open the opensense.php file in the text editor of your choice and change the feed id and api key settings to the ones you noted down before. Upload it to your server and remember the url - we’ll use this in the plan in a moment.

Now in the Planner create a new piece of code - and paste in the Squirrel code from the gist above. It’s a very basic example that has a button on pin 1 and GND. 

In the Planner add a HTTP Request vimp and drag a noodle from the Imp node to this HTTP Request vimp. You should be able to just press ok. Click the settings icon in the vimp and paste in the url of the location of the php file on your server that you created before.

Finally, back in find the device you created earlier and add a new app. Choose the twitter app, authenticate it and in the template just simply type %VALUE.

Now when you press the button it should tweet.

Hope that’s useful!

I was wondering if you were @dawesduino ;)  Very nice. Thanks for sharing, Brendan.

Thanks Nong. 


I agree, thanks for sharing! I’ve modified parts of the code to hit ThingSpeak to get something posted to Twitter. The code in itself was an extremely helpful “learn by example” of how to make a push button web connected thing. I got far enough to prove to myself a working prototype…

Thanks for this. Helpful to get going.

I was able to knock the intermediate PHP out of the loop by manually constructing the JSON in the Squirrel code like follows:


And POSTing from the vimp to with content type application/json.


Jumped the gun…doesn’t work…figuring it out.

Since doing this I’ve now removed the need to go through and instead use this library by Matt Harris: I’ll post some code when I get chance.

Thanks for all the documentation Brendan. I’ve just got an imp and trying to get experimenting with it.

The Electric Imp whitepaper claims that they provide email and twitter gateways – is that just a lie?

We did provide email/twitter on an early planner revision, back when that was written. The whole IDE is being updated now, and agents will allow you the flexibility you need to connect to arbitrary services.

Thank you Hugo. I look forward to when the planner again allows me to both post to Twitter and react to tweets without third party services or self-hosted scripts. In the mean time I’ve been enjoying working through the examples and imagining what my impee could do.

Brendan (and/or Hugo):

I have attached a Planner screenshot to help…

I am trying to implement the above with the goal having a cat door that Tweets (basically sensing a switch closure). With the help of you and Hugo I have gotten pretty far, but now seem stuck. Probably due, in part, to the fact that I don’t fully understand the fundamentals of what is actually going on. That said, here is where I am at:

  • on I have the Twitter API working. I can manually enter a value from and it will Tweet on my page @OurCatDoor. I have established my Imp as a device in and have the FEEDID and API Code.

  • In Imp Planner I have switch closure (PIN1 to GND) code that works.

  • In Imp Planner I have the switch code ‘noddled’ to the “OPENSENSE.PHP” file on my server (with proper FEEDID and API codes). I modified the Imp code some for debug by adding a timestamp to the switch closure (see pic)

  • The HTTP node with the FEEDID/API modified PHP returns “200” which in my book means “All OK”.

But (and of course you could have guessed this), a switch closure on the Imp does not force the to send the tweet.

I’m “shotgunning” the problem now, so thought I would pause for some help from those that are wiser. Any thoughts on what I am missing. Something tells me it is with the ‘noodle’ setup.

Planner screenshot attached at and at:


Update: I got to thinking… I believe the issue is with server (ISP) not allowing script to run on their site. I should have thought of this straight away.

I’ll dust off an old PC an create a little server, I guess. I wish Electric Imp would support access to Twitter directly. Seems like one of the most convient ready made solutions for broadcasting status easily.

I welcome comments…

Agents will allow you to do this; right now you tend to need to cobble stuff together for external services I’m afraid :frowning:

OK. Update here… First off a few ‘grounding’ statements:

  • this is my first Imp
  • first use of Squirrel code
  • first PHP exposure.
  • 75% of the info came from this forum or the devwiki. 25% from other random web pages.

It’s working. I connect PIN1 to GND. The Imp sees it, the PHP script is triggered, and our cat door twitter page gets updated.

Well, for now anyway.

Pretty impressive piece of kit and pretty impressive support forum.

Build page at:

Nice one.

Thanks brendandawes for the comment and thanks for your help!

Source on build page updated to correct some error hits.

Use two magnetic reed switches on the door so you know if it swung from the inside out, or the outside in. One switch will trigger a few milliseconds before the other.

And debounce them so the door swinging back and forth after use doesn’t trigger.

These types of projects are always amusing.

With Agent it is a few lines of code to do Facebook updates…