dweet.io: A simple, effective messaging service for the Internet of Things

A minimum of fuss in setup and operation means that developing a messaging infrastructure for IoT systems is quick and easy

message in bottle

In my last post I discussed Freeboard, a powerful, polished, open source Web dashboard and mentioned that Bug Labs, the creators of Freeboard, also offer a very interesting Internet of Things messaging service called dweet which we’ll look at today.

Now, there are many messaging services (for example MQTT) that can be used by IoT applications but few that are really simple and free as well; dweet is, indeed, simple and free though there is also an inexpensive enhanced level of dweet service we’ll get to later.

The goal of IoT messaging is for a device to send a chunk of data to a server where it’s stored for some period of time. That data can then be retrieved by one or mutliple devices for analysis, display, storage or whatever. And here’s where it starts to get complex: What happens when a message from a source device gets lost? When it gets duplicated? When two messages arrive out of sequence? Dweet ignores these issues and simply makes a best effort attempt to receive and send messages so any messages integrity assurance has to be handled by the devices at either end (in other words, the devices have to add sequence numbers and or timestamps when they send messages and detect missing, duplicated, and out of sequence messages when they retrieve messages).

So, how easy is it to use dweet? Let’s send a message:

https://dweet.io/dweet/for/gearhead?hello=world

That’s it; no authentication required, no fussing around, you just make a GET request and voila! The “thing” here that’s dweeting is named “gearhead” and it is dweeting the value of “world” for the key “hello”. Here’s the JSON response to that request:

{
  "this": "succeeded",
  "by": "dweeting",
  "the": "dweet",
  "with": {
    "thing": "gearhead",
    "created": "2016-10-21T19:23:36.899Z",
    "content": {
      "hello": "world"
    },
    "transaction": "2b6f25c1-d0b2-4319-8160-9f4e42caa794"
  }
}       

Speaking of JSON, if you want to view JSON in your browser in a pretty and formatted display, I thoroughly recommend json-viewer, a Chrome extension for printing JSON and JSONP.

If you need to, you can use HTTP instead of HTTPS and you can send a message with multiple key/value pairs:

https://dweet.io/dweet/for/gearhead?hello=world&status=online

… and you can use a POST request with the key/value pairs in JSON as a payload.

How about retrieving that message?

https://dweet.io/get/latest/dweet/for/gearhead

Again, dead simple. And here’s the response:

 
{
  "this": "succeeded",
  "by": "getting",
  "the": "dweets",
  "with": [
    {
      "thing": "gearhead",
      "created": "2016-10-21T19:25:23.238Z",
      "content": {
        "hello": "world3"
      }
    }
  ]
}      

If there were multiple messages waiting, we could get all of them by using this request:

https://dweet.io/get/dweets/for/gearhead

… which produces:

{
  "this": "succeeded",
  "by": "getting",
  "the": "dweets",
  "with": [
    {
      "thing": "gearhead",
      "created": "2016-10-21T20:18:02.207Z",
      "content": {
        "hello": "world",
        "status": "online"
      }
    },
    {
      "thing": "gearhead",
      "created": "2016-10-21T19:25:23.238Z",
      "content": {
        "hello": "world3"
      }
    },
    {
      "thing": "gearhead",
      "created": "2016-10-21T19:25:18.394Z",
      "content": {
        "hello": "world2"
      }
    },
    {
      "thing": "gearhead",
      "created": "2016-10-21T19:23:36.899Z",
      "content": {
        "hello": "world"
      }
    }
  ]
}    

But wait! There's more! You can include the key ?callback= and dweet.io will return a JSONP response and dweets can also be streamed in real time. And if you're building software, there are client libraries for node.js, JavaScript, Python, and Ruby.

This is all well and good but as you might have guessed, dweets are essentially public because all you need to retrieve a dweet is its name. Moreover, dweet.io only stores the last five dweets for up to 24 hours. Should you want you data to remain private and or persist for more than 24 hours, you can purchase “locks”; keys that secure your data (by means of obscurity) and enable dweets to be stored for 1 month. A lock costs $1.99 per month and a single lock can be used for up to 2.5 million dweets per month.

With locked dweets you can retrieve as much as a specific 24 hour window’s worth of dweets per request or as small as one specific hour (retrieving the last dweet also works with locks and retrieving all dweets without a time frame will return all dweets within the last 24 hours). 

Another feature of locks is that you can set up and remove email alerts for specific conditions in dweets, for example, the following would email me whenever the value of status equals offline:

https://dweet.io/alert/gearhead@gibbs.com/when/gearhead/dweet.status=offline?key=abc123

If you want to see what’s being dweeted right now, dweet.io has a page that lists current things and the dweets they’re sending

dweet is incredibly useful for quickly building messaging infrastructures for constellations of IoT devices and the lock feature makes it easy and cheap to ensure both privacy and data persistence. dweet.io is highly recommended by the AIs here at Gearhead Laboratories and dweet.io gets a Gearhead rating of 5 out 5.

Comments? Thoughts? Drop me a line or comment below then follow me on Twitter and Facebook.

Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.
Must read: Hidden Cause of Slow Internet and how to fix it
Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.