XBee and Spark Core, Part 3 – Analog Input using Light Sensor

https://github.com/krvarma/XBee_SparkCore_LightSensor

Here is the part 3 of my XBee and Spark Core series. This part is about Analog Input using a Light Sensor. In this part AD1 of the Remote XBee is configured as Analog Input. AD1 is connected to Light Senor. As usual this XBee is configured as Router AT and Coordinator is connected to Spark Core via Serial. The Remote XBee is configured to send samples every 1 second and the Spark Core receives this IO Sample data and reads the Light Sensor value.

Same as the previous project, I am using the XBee library and reads the analog data using getAnalog method of the ZBRxIoSampleResponse class.

To monitor the values, in this part I created a Freeboard.io data source and configured a Display Panel.

Screenshots

enter image description here

enter image description here

enter image description here

XBee and Spark Core, Part #2 – Remote Door Monitor using XBee Digital Input

https://github.com/krvarma/Spark_XBee_Remote_Door_Monitor

This is the part 2 of my XBee and Spark Core series. In this part I worked on a simple remote door monitor using XBee, Spark Core and a Magnetic Contact Switch (Door Sensor).

In this project, the remote XBee is configured as Router AT. The DIO4 of the XBee is setup for Digital Input (3) and it is also configured to send IO Sample data every 1 second (setting IR to 3E8 hex). The Magnetic Contact Switch is connected to DIO4 of this XBee, so when the door is closed the DIO4 will be HIGH and when the door is open the DIO4 will be LOW.

A Coordinator XBee is connected to Spark Core using Serial. The Coordinator receives the IO Sample data that Remote XBee is sending and parse it to see whether DIO4 is HIGH/LOW. An event is generated based on the door state.

The companion web page listens for the above event and display some graphics based on the whether the door is open or closed.

I am using XBee Library ported by @peekay123. The Spark Core continuously reads XBee packets and look for packets with API ID ZB_IO_SAMPLE_RESPONSE. This is the API ID of the IO Sample Data. If it is IO Sample data, then read the data into ZBRxIoSampleResponse class. The ZBRxIoSampleResponse.isDigitalOn() method can be used to find whether a particular PIN is ON/OFF.

Screehshots

Spark Core and Coordinator XBee

Remote XBee and Door Sensor

Web Page

Demo Video

Demo Video

Using Spark Core and XBee for RF Communication, Part #1

https://github.com/krvarma/XBee_SparkCore

Here is one of the project I worked these days, this is a part one that uses Spark Core and XBee for RF Communication. My intention is to use XBee(s) and Spark Core to create very simple Home Automation project. In this part, I just turn on/off a remote LED which can be controlled using a Web Application.

The project is to control a remote light, i.e. turn on/off the light. In this part I am using Spark Core and two XBee’s (either Series 1 or Series 2). If you are using Series 1, then one should be configured to accept API Command, other can be wither API or AT mode. If you are using Series 2, then one should be configured as coordinator API and other can either be a Router AT/API or an End Device.

Introduction

Here in this project the Coordinator API XBee is connected to Spark Core and communicate using Serial. Spark Core is used as Internet Gateway to control XBee. The Core application uses XBee Library ported by @pkourany. For this project I am using XBee Remote AT command to control remote XBee(s). For more about API Mode and Remote AT Commands please refer to this link.

The Router XBee’s D0, D1, D2 and D3 pin are connected to four LEDs which can be remotely turn on/off. Any device can be connected to any pins and send the Remote AT commands to the remote XBee. It can a Rely connected to Electrical Light, or anything else.

To send Remote AT Command, you can either use a Broadcast address or a destination 64-bit (MAC/EUI64) address of the XBee module. Using the 64-bit destination address allows us to send commands to a particular XBee. There is also a 16-bit configurable address which can be used to group multiple XBees and send commands to that group. Since this is a different topic and is not in our scope, for more information refer to the Digi documentation.

The sample JavaScript Web application is used to control the remote light. To use this application you should replace the deviceid and accesstoken with actual values. When the application is opened you will be asked to enter the Name (any name, just for display purpose) and the 64-bit remote address of the XBee that is connected to the Relay Module. Once it is entered you can turn on/off the D0, D1, D2 and D3 pins.

Here you can find a very useful API Frame Generator from Digi International. This is extremely useful for the development and debugging, I used it a lot for this project.

Wiring

Coordinator XBee and Spark Core

  • XBee Vcc to Spark Core 3V3
  • XBee GND to Spark Core GND
  • XBee DOUT to Spark Core Rx
  • XBee DIN to Spark Core Tx

Router XBee and Relay Module

  • XBee Vcc to 3v3
  • XBee GND to GND
  • XBee DIO0 to LED1
  • XBee DIO1 to LED2
  • XBee DIO2 to LED3
  • XBee DIO3 to LED3

Screenshots

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Demo Video

https://www.youtube.com/watch?v=n_4AgTekWqs