Quantcast
Channel: OpenEnergyMonitor aggregator
Viewing all articles
Browse latest Browse all 328

mharizanov: Tweeting silicon

$
0
0

Here is a fun project for I did couple days ago: a tweeting ESP8266. The typical approach when dealing with such task (and probably the better) is to use a proxy service like ThingSpeak’s ThingTweetPushingBox or by building proxy yourself with Node-RED or mqttwarn. It is much more fun though to perform a direct tweet from a microcontroller. Just think about the complexity of using TLS and oAuth along with Twitter’s API, all that done from a $5 Wi-Fi connected SoC..

Getting this done was pretty much straight forward except for the hmac-sha1 hashing of the oAuth base string. Turned out that the hmac-sha1 implementation in ESP8266’s SDK only supports 64 byte keys, while I was getting a much larger key. Wikipedia’s article on hmac-sha1 hashing shows the approach to that case and I was able to generate a correct hash with one additional SHA1 applied to the key to reduce it to 20 bytes.

if (length(key) > blocksize) then
        key = hash(key) // keys longer than blocksize are shortenedend if

So my ESP8266 can now  tweet, I created a dedicated Twitter account for it named “Tweeting silicon” @tweetingsilicon

tweeting_silicon

Code for the project is available on Github. Code is dirty, please contribute to improve it.

 

 

  (106)


Viewing all articles
Browse latest Browse all 328

Trending Articles