Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Getting Started With Node-RED* and Texas Instruments* SensorTag

$
0
0

Overview

Node-RED* is a tool for wiring together hardware devices, APIs and online services in new and interesting ways. Node-RED provides a browser-based flow editor that makes it easy to wire together flows using the wide range nodes in the palette. Flows can be then deployed to the runtime in a single click. The lightweight run-time is built on Node.js*, taking full advantage of its event-driven, nonblocking model. This makes it ideal to run at the edge of the network. The Texas Instruments* multi-standard SensorTag, based on the SimpleLink* ultra-low power CC2650 wireless MCU, supports development for Bluetooth* Smart, 6LoWPAN and ZigBee*. This SensorTag has a unique feature that allows developers to change between different 2.4 GHz technologies by simply loading new software images directly from the SensorTag app over-the-air. In this example, we’ll be communicating to the SensorTag via Bluetooth* Low Energy. The SensorTag includes the following sensors: Infrared and Ambient Temperature, Ambient Light, Humidity, Barometric Pressure, 9-axis motion tracking, and Magnet.

  • IoT Gateway that uses Intel® IoT Gateway Technology
  • Texas Instruments SimpleLink Multi-Standard SensorTag Development Kit

Assumptions

  • Intel® IoT Gateway Technology version 3.1 or above.
  • Node.js is installed on the IoT Gateway (installed by default).
  • Node-RED node "node-red-node-sensortag" is installed on the IoT Gateway.
    • You can install this package by clicking on Packages and then Add Packages from the Intel® IoT Gateways Developer Hub.
  • Node-RED is installed on the IoT Gateway and is running (installed by default).

Enabling Bluetooth* Low Energy on the Intel® IoT Gateways

By default, Bluetooth is enabled, but Bluetooth Low Energy is not. This is easy to turn off via the IoT Gateway administrative web console. You can access the console via https://ipaddressofthegateway.

  1. Log in using your root username and password
  2. Click on the Administration icon and then the, Launch button under LuCI to launch the Intel® IoT Gateways administration console.
  3. Log in using your root username and password.
  4. Select Network from the menu and choose Bluetooth
  5. If it says Disabled next to Bluetooth Status, click on the Disabled button

It should look like this when setup correctly:

enabling bluetooth

Bluetooth* Test

Before we start, let’s make sure the Intel® IoT Gateways can discover the SensorTag device. Ensure a battery is installed in the SensorTag power it on (it goes to sleep if there are no active connections to it). To turn it on, just press the small button. You should see a green LED start flashing. By the way, when a connection is established to the SensorTag, this LED will turn off. Type the following on the IoT gateway console prompt:

hcitool lescan

It should respond with something like this:

LE Scan … B4:99:4C:1E:C0:C0 CC2650 SensorTag

It may also show other Bluetooth devices in range. Press Ctrl-C to stop the scanning tool. If it doesn’t show your SensorTag, make sure the SensorTag is turned on and the LED is flashing and try again.

Using Node-RED*

The Node-RED browser interface can be reached via http://ipaddressofthegateway:1880. When it first comes up it will look something like this:

using Node-RED*

Let’s create a Node-RED flow to get the sensor readings from the SensorTag.

Now, configure the nodes.

  1. Drag the following nodes from the left bar on to Sheet 1:
    • sensorTag
    • Debug
  2. Double click on the sensorTag node and check what sensors you’d like to include. For this example, let’s check them all.
  3. Set the name to sensorTag.
  4. Leave the UUID blank (if you have more than 1 SensorTag in range, you can set this to the MAC address of the SensorTag you want to talk to. For this example, we’ll assume there is only one in range. Leave the other fields as default. For example:

    Edit sensor tags 

  5. Click OK
  6. Now wire the sensorTag node to the Debug node by clicking and dragging between the small box on the right of the sensorTag node to the small box on the left of the Debug node. It should look like this:

  7. Click on the Deploy button on the top right, and Confirm deploy.
  8. Ensure the debug node is turned on. The box extending to the right of the node should be solid/filled in green.
  9. Switch the column on the right from the Info tab to the Debug tab.
  10. The sensor readings show appear in the Debug tab. You may need to press the power button on the SensorTag to turn it on if it’s gone to sleep since we turned it on in the above steps.

Congratulations! You are successfully communicating via BlueTooth low energy to a SensorTag device.

Example flow

Node-RED supports exporting and importing of flows (into source json). Here is an export of the above two flows we created:

[{"id":"f80454e.f07fba8","type":"sensorTag","name":"sensorTag","topic":"sensorTag","uui
d":"","temperature":true,"humidity":true,"pressure":true,"magnetometer":true,"accelerom
eter":true,"gyroscope":true,"keys":true,"luxometer":true,"x":240,"y":266,"z":"ec8b1eb.f
1374e","wires":[["ad11b15b.52ee5"]]},{"id":"ad11b15b.52ee5","type":"debug","name":"","a
ctive":true,"console":"false","complete":"payload","x":543,"y":276,"z":"ec8b1eb.f1374e"
,"wires":[]}]

If you import this, the same nodes and configuration we created manually will automatically appear on the selected Sheet. Import and Export can be found in the Node-RED menu by clicking on the 3 horizontal lines to the right of the Deploy button.

References

For the current version of this tutorial, visit GitHub and do a search.

*Other names and brands may be claimed as the property of others.


Viewing all articles
Browse latest Browse all 3384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>