Archiv pro štítek: IoT

IoT Cloud MQTT message to Speech

For demo purposes and to be able to check if the messages are coming from the IoT cloud without looking at the screen all the time I created super simple Node-RED flow that receives messages from IBM’s IoT cloud and log them in the debug tab of the Node-RED UI and in parallel it parses JSON format of the messages to obtain value of the „temp“ property which is then passed to OS X say command.

It can be easily modified to pick another property value just by modifying „JSON and parse“ node.

Screen Shot 2014-09-04 at 13.34.43

 

You can import the flow using „Import -> From Clipboard“ menu item of Node-RED and by pasting the following text and modify your broker details:

[{"id":"7649d216.89b62c","type":"mqtt-broker","broker":"kbrhh.messaging.internetofthings.ibmcloud.com","port":"1883","clientid":"a:kbrhh:viewer2"},{"id":"482fa4c4.b7d05c","type":"debug","name":"Show message","active":true,"console":"false","complete":"true","x":343,"y":62,"z":"948d5198.6b72b","wires":[]},{"id":"a07e3b0c.5f81c8","type":"mqtt in","name":"Receiver","topic":"iot-2/type/sensor-type/id/+/evt/event1/fmt/json","broker":"7649d216.89b62c","x":93,"y":129,"z":"948d5198.6b72b","wires":[["482fa4c4.b7d05c","e9a50fa3.165af"]]},{"id":"e9a50fa3.165af","type":"function","name":"JSONify and parse","func":"msg = JSON.parse(msg.payload)\ntemp = msg.d.temp\ntemp = Math.round(temp * 10)/10;\nreturn {\"payload\": \"Temerature is \" + temp + \" degrees of Celsius\" }","outputs":1,"x":344,"y":199,"z":"948d5198.6b72b","wires":[["4de9ed0c.b21614"]]},{"id":"4de9ed0c.b21614","type":"exec","command":"/usr/bin/say","append":"","useSpawn":"","name":"Say","x":578,"y":258,"z":"948d5198.6b72b","wires":[[],[],[]]}]

You can also change the voice by modifying say command from:

/usr/bin/say

to:

/usr/bin/say -v <voice name>

You can list available voices by entering command

/usr/bin/say -v ?

into terminal.

The flow requires Node-RED installed on a OS X machine.

Home automation as a weekend project using IBM’s Clouds – part 3

Today we will add a simple user interface to our Bluemix/Node-RED/MongoDB application. We could do it in a form of a Ruby in Rails app or use another platform. But let’s assume that we want to have something up and running really fast – just for PoC purposes and as a rough prototype. That’s why I am going to use RapidApps for this purpose. Pokračování textu Home automation as a weekend project using IBM’s Clouds – part 3

Home automation as a weekend project using IBM’s Clouds – part 2

Today we will connect the MQTT bus that is core part of IoT Cloud to the MongoDB using Node-RED flow.

The goal is to have the values – that are sent by our simulated device – stored in our database to be able to display them to an user.

We need to add MongoDB to our Bluemix application. Pokračování textu Home automation as a weekend project using IBM’s Clouds – part 2

Home automation as a weekend project using IBM’s clouds – part 1

I decided to make myself familiar with the IBM’s cloud services by creating a home automation system based on these services:

  • Internet of Things Cloud to interconnect sensors (temperature and motion detector) and actuators (light switches) with the application running in cloud.
  • Bluemix to process the events and act in an appropriate way
    • I plan to use Node-RED to feed a database with the events
    • and Business rules service to implement logic.

Before implementing such a system I started by testing components that I plan to use.

Pokračování textu Home automation as a weekend project using IBM’s clouds – part 1