Everybody is tweeting!! I like that. It keeps me updated about whats happening around. Unlike big brother FB, i don't have to worry whether to Like or Share or Comment for a post or just do nothing. If I want to spread the word, just retweet. Simple, elegant! But what happens when all these devices started tweeting. Ohh...they are gonna flood the place. I noticed first the trend around some four years( or before that? ) when people started interfacing a moisture sensor to an arduino with wifi shield and put it with a plant -- plant starts tweeting its conditions! Wow??? Really?? I don't think so. When you have one plant, it's okay. What about all the ten plants on your roof top? What if you want to add your indoor temperature sensor to twitter? What about your kid's cradle? I know it's getting messy. The moment you open your twitter page, what you will be able to see is only 'tweets' from these devices. You can easily miss out an important tweet from your friend, or the author you follows. But when I say people these things, they say, "Dude, this is internet of things!". No. I don't think so. I believe that IoT is to help me, not to flood my home page. So let's keep the devices in their domain, and invite them only when you want them. Let's make a twitter especially for them.
Seems like the guys in Bug Labs had done an appreciable job here. I think they figured out what's so hot about things tweeting and a created a super simple solution for the trend.
Enter dweet.io
from dweet.io home page
dweet.io is a Ridiculously simple messaging (and alerts) for the Internet of Things. And the best part is it doesn't require you( or your device? ) to sign up. Just publish and go. It's machine-to-machine (M2M) for the Internet Of Things (IOT) the way it was meant to be.
When they say ridiculously simple, they mean it - no cryptic APIs, no access tokens, no passkeys. Just send a normal http request and you are done! Your content is on air. Let me take you through an example. Suppose you have your room heater and it want to post the temperature reading to web. Just request this url from your device :
https://dweet.io/dweet/for/myRoomHeater?temperature=15C
and you are done. Your data is online now. So now how to access the data? It's this simple - request this url from any device which want to access the data :
https://dweet.io/get/latest/dweet/for/myRoomHeater
And you should get a json object which looks like :
{ "this":"succeeded", "by":"dweeting", "the":"dweet", "with": { "thing":"myRoomHeater", "created":"2014-08-29T11:29:55.673Z", "content":{ "temperature":"15C" } } }
What if you want to see all the data from past 24 hrs. Again simple. Request this url
https://dweet.io/get/dweets/for/myRoomHeater
You will get a response like this :
{ "this":"succeeded", "by":"getting", "the":"dweets", "with":[ { "thing":"myRoomHeater", "created":"2014-08-29T11:41:31.164Z", "content":{ "temperature":"16.5C" } }, { "thing":"myRoomHeater", "created":"2014-08-29T11:41:26.383Z", "content":{ "temperature":"15.8C" } }, { "thing":"myRoomHeater", "created":"2014-08-29T11:41:21.173Z", "content":{ "temperature":"15.3C" } }, { "thing":"myRoomHeater", "created":"2014-08-29T11:29:55.673Z", "content":{ "temperature":"15C" } } ] }
You have a json object that you can parse to figure out what you want. Isn't it so simple?
You can go to https://dweet.io/play/ and play around with all those I just said and even more.
Cool, but are there any clients?
What is a great engine without a chasis? And what about a great solution with out any client libraries? But my question is do we really need one? Bug Labs have released two official clients in Node.js and Javascript. And they also lists unofficial python and ruby clients. I chose to walk the python way and tested both the clients : dweepy and pydweet. I liked dweepy more - it has support for real time streams which is very useful( or a must? ) when you are working in project like this.
Let your Pi dweet
So much of theory. Let's get out hands dirty. Let the Pi dweet. But what to dweet? Pi don't have any sensors inbuilt . No worries. We'll dweet some junk stufff to start with. First prepare your Pi. Installing dweepy in raspberry Pi is simple. Fire up your rPi terminal and type in
sudo apt-get install python-pip
pip install dweepy
wait till the installation finishes and your are done . Now let's start dweeting. In your rPi, enter your python terminal and
>>> import dweepy
>>> dweepy.dweet_for('fmn2014_vish_raspberrypi', {'msg':'this is a test dweet' } )
where you replace 'fmn2014_vish_raspberrypi' with your thing id( anything, but keep it sufficiently long to avoid namespace collisions ). You will be able to see some thing similar to this as output :
If you go to https://dweet.io/play/ and check for your dweet, you can see like this :
That means you have successfully posted a dweet.
Now let's play with receiving dweets. Go to Dweet Play page and create a new dweet( like the one in the screenshot below ).
Now back in your python terminal, type :
>>> dweepy.get_latest_dweet_for('fmn2014_vish_raspberrypi')
and you will be able to see some thing similar to this :
Formatting is a little for the moment, but you can see that we got what we sent from our browser.
To get all the dweets from last 24 hours,
>>> dweepy.get_dweets_for('fmn2014_vish_raspberrypi')
and you will be able to get :
I'm having a few more dweets in this screenshot than I mentioned in this post.( I played a little more dweeting )
That's it for now. In my next post, I'll explain how to wireup Enocean-Py, Dweet and raspberry Pi to create a fully functional IoT system.