Post Data to Dweet.io using FRED

This guide will teach you how to post data to a Dweetio Thing using Node RED (FRED).

The sample flow can be found in: http://tutorial-samples/post-data-to-dweetio-using-fred/post-data-to-dweetio-using-fred.json

If you are not sure how to import a sample flow, please refer to: http://developers.sensetecnic.com/article/how-to-import-a-node-red-flow/

About Dweet.io

Dweet.io is simple publishing and subscribing for machines, sensors, devices, robots, and gadgets (we just call them things). We call published messages ‘dweets’. It’s helpful to think of dweet.io as a Twitter for things, in fact.

Visit https://dweet.io/play/. There you can create “dweets” and get data previously sent to a “thing” To create a thing simply expand the box labeled “create or read dweets in short term cache.” Now give the “thing” a name:

dweetio01

Click on “Try it out!”. To retrieve your data you can try “Read the latest dweet for a thing”, Read all the saved dweets for a thing” or “Listen for dweets from a thing”. Let’s try “Read for the latest dweet for a thing”. You can fill out the form for the name of your thing and click on “Try it out!”. Alternatively you can do a GET request to “/get/latest/dweet/for/{thingName}

“.

dweetio02

What is Node RED?

Node-RED is a visual tool for wiring the Internet of Things developed by IBM Emerging Technology and the open source community. Using Node-RED, developers wire up input, output and processing nodes to create flows to process data, control things, or send alerts. It works by allowing you to wire up web services or custom “nodes” to each other, or to things, to do things like:

  • Send an email on a rainy weather forecast.
  • Push sensor data to services like Twitter.
  • Perform complex analysis on data with ease.

showcase-flow

If you’re new to Node RED you might find our Introduction to Node RED tutorial very helpful.

What is FRED

Front End for Node-RED (FRED) manages instances of Node-RED for multiple users in the cloud. We manage and optimize your instance of Node RED so you worry about accomplishing your project, not setting up and maintaining your Node-RED instance.

Create a FRED Account

To begin our tutorial create your own Node-RED instance in the cloud. Register for a free account at http://fred.sensetecnic.com.

After registering make sure to activate your account via your email.

Simplest example of Posting Data

FRED provides a selection of nodes that allow you to create and retrieve data to different services. Dweet.io is one of them. When you login you will find these nodes in the left pane.

dweetio03
In Node RED you wire nodes together, nodes output messages containing a payload (msg.payload = “your message”) and receive outputs from other nodes. In the case of the Dweet.io Nodes they consume messages in the form:

[javascript]
msg.payload = {
value:42,
message:”The Answer to Everything”
}
[/javascript]

We will send a similar message. Drag onto the main panel an “inject” and a “dweetio output” nodes. Connect them like this:

dweetio04

Now double click on the Inject node, select the Payload type to “string” and type:

[javascript]
Hello From FRED
[/javascript]

dweetio05

Now double click on the Dweetio Node and fill out your thing name.

dweetio06

To deploy your nodes, click on the red button labeled “Deploy” on the top right corner.

If you click on the blue button to the left of the Inject node, the “inject” button, you will be sending the message “Hello From FRED” to your sensor. Do it a couple of times.

Visit https://dweet.io/play/ again and try “Read all of the saved dweets for a thing”. Fill out the form for your thing name and click on “Try it out!”. You will see the messages you sent from FRED.

dweetio07

Retrieving Data in FRED

The power of using FRED is that you can also access your data without having to visit Dweet.io all the time. FRED provides a “dweetio input” node that can help us in this.

Connect a dweetio input node and a debug node like this:

dweetio08

Double click on the dweetio input node and type your thing name:

dweetio09

Click on OK and click on Deploy again. Clicking on the blue button to the left of the inject node will send an event to Dweetio using the dweetio output node. The dweetio input node will listen to events and pass the received messages to the Debug node, which will print the result in the debug panel:

dweetio10

One great thing Dweet.io is that you can also pass JSON formatted strings. Which allow us to pass along more complex data, which can be very helpful in more complex examples. Try changing the injected string to a JSON string, like this:

dweetio11
This will come in handy for more complex applications.

Next Steps

Try another example:

A Node RED flow using FreeBoard

Leave a Reply