XBee Tech Tip: Connecting to the IoT with XBee Zigbee Cloud Kit

Digi International
November 10, 2014

This Tech Tip is brought to you by Digi Applications Engineer Mark Grierson, who will take you through the steps to connect an XBee Smart Plug to the XBee Zigbee Cloud Kit and manage it from the XBeegateway.herokuapp.com web application.

The XBee Zigbee Cloud Kit is the easiest way to connect to the Internet of Things (IoT). It features a sample web application that lets users remotely activate various outputs on the development board including LEDs, a vibration motor, a bar graph gauge and an audio buzzer.

In addition, users can build their own circuits on the development board to sense temperature or light, switch on and off other devices via a relay, turn on and off additional LEDs and more. The web application code is open-source, available for anyone to download and use as a learning tool.

The purpose of this article is not to teach you how to set up and use the kit. There is an excellent online user’s guide that will step you through that process found here: http://www.digi.com/resources/documentation/Digidocs/90001399-13/Default.htm

This article assumes that you have set up the XBee Zigbee Cloud Kit and have followed the instructions in the getting started guide.

Using the XBee Smart Plug with the New XBee Zigbee Cloud Kit

Now that you have seen how easy it is to web enable just about any device, you may be wondering about Digi’s boxed Zigbee devices such as the XBee Smart Plug, XBee Sensors, AIO and DIO adapters, etc. Can you use these devices with the XBee Zigbee Cloud Kit? Absolutely!

1)     Introduction

Using the XBee Smart Plug is an easy way to intelligently monitor and control connected electrical devices. This example uses the XBee Smart Plug and allows you to control the AC relay as well as read and monitor the AC current sensor, the Temperature Sensor and the Light Sensor.

The three sensors generate voltage outputs that are passed to the XBee’s analog-to-digital converter (ADC). These readings are then sent via Device Cloud to the XBee Zigbee Cloud Kit’s online dashboard application where you can control and monitor the XBee Smart Plug right in your web browser.xbeegateway1-259x300

2)     Assemble the Parts

To complete this exercise you’ll need:

1 – XBee Gateway

1 – XBee Smart Plug

1 – Device Cloud Accountxbeegateway2-300x300

 

3)     Connect the XBee Smart Plug to the Gateway and Configure

You’ll need to ensure the XBee Smart Plug is connected to your XBee Gateway. If your XBee Smart Plug is new and has not connected to a Zigbee network, this should be as simple as plugging it in while the XBee Gateway is powered up.xbeegate3-201x300

The Green Association (ASSC) light will flash once the XBee Smart Plug has joined a network.

You can then go to the XBee Network tab in the configuration section of the Gateway’s web UI to ensure the smart plug has joined.

deviceconfic1

If the XBee Smart Plug does not show up, click on the “Discover XBee Devices” button to have the XBee Gateway perform a network discovery. If the XBee Smart Plug still does not show up and the ASSC light is flashing on the XBee Smart Plug, this means that the XBee Smart Plug has joined another Zigbee network and must be reset using a 4-button press of the Reset button. Consecutive button presses must occur within 800 milliseconds of each other for the reset to occur.

xbeegateway4

When the reset is successful, the ASSC light will go steady as the XBee Smart Plug looks for a new network to join and will flash again once it joins. Return to the Gateway web UI and click discover to see the XBee Smart Plug is now joined to the XBee Gateway.

Once the XBee Smart Plug has joined the XBee Gateway, configure it by clicking on the extended address of the Smart plug.

deviceconfig2

After a few seconds, the settings of the XBee Smart Plug will be displayed. Click on the Input/Output settings tab and:

  1. Check the Detect box for D4 (D4 is used to toggle the AC outlet)
  2. Ensure that the IR parameter is set to 5000ms
  3. Click the Apply button to save changes 

deviceconfig3

4) View It!

You will use the XBee Wi-Fi Cloud Kit’s web application to configure three widgets for viewing the temperature current and light readings from your sensor. You will also configure a widget to control the AC relay.

Log in to the XBee Zigbee Cloud Kit web application: https://xbeegateway.herokuapp.com/#/login

dcscreen342

The Outlet Widget

First we will create the outlet control widget.

Use the Add Widget button to create a new display widget.

dcwidget

Choose On/Off Switch Widget for the widget type.

Add a label such as “XBee Smart Plug Outlet.”

Choose your XBee Gateway and module by selecting their ID.

Select DIO4 as the output stream and check the device configuration to make sure it is configured properly. Your screen should look like the following.

createnewwidget

Save the changes to see your new Widget on the home screen.

You should now be able to turn the XBee Smart Plug AC outlet on and off using the widget.

The Current Draw Meter Widget

Next we will createa widget to measure the current draw on the XBee Smart Plug. The concepts used to build this widget are the same for the light meter and temp sensor built into the XBee Smart Plug. Only the Input stream and transform will be different.

Use the Add Widget button to create a new display widget.

dcwidget

Choose Gauge Widget for the widget type.

Add a label such as “Current Draw.”

Choose your XBee Gateway and module by selecting their ID.

Select AD3 as the Input Stream and check the device configuration to make sure it is configured properly.

Enter the following formula into the Input Transform:

Enter “((((value/1024)*1200)*(156/47)-520)/180*0.7071)*1000” into the Input Transform to transform the input from millivolts to milliamps. The formula in brackets converts the millivolt reading into AMPS. The herokuapp application is constrained to whole numbers and will convert a decimal result to the nearest whole number. To make this data more meaningful, we then multiply this value by 1000 to convert to milliamps. The following knowledgebase article is the source for this info: http://knowledge.digi.com/articles/Knowledge_Base_Article/Analog-and-Digital-Sampling-Using-XBee-Radios/

Enter mA into the Units field.

Enter 0 for the Low value and 8000 into the High value (the XBee Smart Plug is only rated for loads up to 8 amps).

You screen should look like the following:

widgetsettings

Save the changes to see your new Widget on the home screen.

The Temperature and Light widgets are made using the same procedure as the Current widget with a few small changes.

For the Light Widget use the following:

Label=Light Meter

Input Stream=AD1

Input Transform=(value/1024) * 1200

Units=Lux

Low Value=0

High Value=1000

lightmeter

For the Temperature Widget use the following:

Label=Temperature

Input Stream=AD2

Input Transform= (((((value/1024)*1200)-500)/10)*1.8)+32 for Fahrenheit

= (((value/1024)*1200)-500)/10 for Celcius

Units=Fahrenheit or Celcius

Low Value=0

High Value=150

5) Use It!

Now you can use the XBee Smart Plug to control any AC appliance up to 8 Amps! Additionally, you can monitor the amperage being used along with the Ambient light and temperature around the XBee Smart Plug.

In my screenshot below, I have a 60 watt lamp connected to the XBee Smart Plug.

widget dashboard

Using a variation of Ohms law “P=VxI” we can see that this 60 watt bulb should draw about 500 milliamps at 120 volts. 60W/120V=.5Amps or 500 mA. My meter is showing 494 mA, which is just about right on! Feel free to try other widget types. Use a Bar Graph or Line Graph instead of a Gauge widget.

 

Categorized in:

2 Comments