In this tutorial you will learn about publishing and retrieving sensor data from dweet.io cloud using a mobile app developed with Evothings Studio. The example build is 100% Apache Cordova compliant, and this way you can also easily add Dweet capabilities to your existing projects!
An IoT sensor main task is to generate data and passing it on to the cloud. Often we want to publish its data in real time, or at least in “near real time”. To store and visualize the readings of such sensors, perfect for those cases without need of large local storage, the cloud messaging company Dweet.io came up with an interesting concept: They use each sensor’s reading as a somewhat of a short message string in tweet-like format (from twitter) if you will. The difference is that a tweet can only contain a payload of 140 characters (plus resources) while a so called dweet can engulf a payload of 2000 characters (means you can also post longer JSON strings and other text formats). Other than so, it’s a completely no-frills service, you don’t have to register for it and you don’t need any API keys et cetera to get started!
Dweet.io offers a REST API, it automatically registers and allows each “thing” handle name to be created once a new device starts communicating with the service, you can also specify a unique string as your thing’s name upon doing the communication for the first time. After that, it’s simply about publishing these dweets and correspondingly listening for and retrieving either the latest one or all of the most recent 500 dweets from the cloud in one go.
Let’s develop a mobile app with Evothings Studio and send some dweets using sensor readings from mobile phone’s accelerometer. Just follow the below steps:
- Download Evothings Workbench on your computer from the Evothings Download page
- Get an anonymous Cloud Token from the same download page, and save it somewhere
- Download Evothings Viewer app from an app store (Android, iOS)
- Generate a connection key by clicking “Get Key” button on the Connect screen of Evothings Workbench
- Provide the connection key to the Evothings Viewer(s) and tap the “Connect” button in the Evothings Viewer app.
- Now test your setup; click the Examples tab on Evothings Workbench and press the “Run” button for the “Hello World” example, and see the app load in the client
- Make your copy of the “Hello World” example, using the COPY button, give it a name press the RUN button by your new project copy. Now make changes to the source code using your code editor, and see the app automagically reload on your phone or tablet.
Now you know how Evothings Studio works (easy, right?). Let’s move forward with our tutorial.
For your ease, I have already completed and uploaded example code described below to my Github repository. Clone or download the repository to your computer, open the publish-dweet-cloud example folder, find index.html file and drag & drop it to the “My Apps” tab of the Evothings Workbench. Press the “Run” button for your new project, it will be loaded into the Evothings Viewer. Now, hold your mobile phone in hand as movement will provide different accelerometer sensor readings while the app will publish 5 dweets to the dweet.io cloud. Once published, it will retrieve and list the last 5 dweets!
Let’s see some data up in the cloud!