NCD.io offices will be closed on Monday, May 27th for Memorial Day. Dismiss

You are using an unsupported browser!

Please upgrade your version of IE to at least 9, or use a modern browser such as Chrome or Firefox.

Introduction

The Bluz module is an ultra low power Bluetooth 4.0 LE module which was designed for compatibility with Particle Photon based products.  Bluz aims to provide a cloud connected solution for ultra low power applications.

Development on the Bluz module is very simple and intuitive especially if you have experience developing on the Arduino or Particle platforms as it uses the same language and syntax.

The concept behind Bluz is you will have one or many Bluz modules in an environment which communicate back to a Bluz Gateway(Bluetooth ->WiFi->Internet->Particle Cloud) which will pass variables and events from the Bluz back to the Particle cloud and will receive back function calls, published events and take firmware updates over the air.  By doing this Bluz takes advantage of all the great things about Particle including simple application development on the web based Build IDE, out of the box cloud connectivity for data and OTA, along with the ultra low power operation of Bluetooth LE.  Now you can develop cloud based devices that can sip power out of a CR2032 battery for what seems like forever.  How cool is that?!

Power/Communication Connection Overview

Most Control Everything products connect to the Bluz module via I2C.  This includes all relay controllers, current monitoring products, sensors, analog inputs, analog outputs, etc.  This is done by simply plugging the Bluz module into a board(see figure 1-1) Note how the module plugs into the end of the socket leaving inner socket pins un-used.  These controllers are designed to interface with several other platform devices which is why the Bluz module does not utilize all connection pins.

Control Everything Bluz interface products take care of all that hardware connection for you.  But what’s really going on?  In order for an I2C communication port to work you must connect to the SDA and SCL lines.  The Bluz module uses pins D0 and D1 for I2C communication so the board makes connection to those two pins.  Those pins are also pulled high to 5VDC through a resistor network which is necessary for proper I2C communication to occur.  On many controllers these pull up resistors on D0 and D1 are fixed on the board hard wired in the circuit traces, on other boards such as the PScrew or PPScrew there are jumpers on board which must be installed to pull the D0 and D1 lines on the Bluz module high in order to communicate with I2C devices.

The I2C plug in cable carries the SDA, SCL, GND, and a +5VDC connections from the main board where the Bluz module lives to all other boards in the chain.  A shared ground line between the Bluz module and connected I2C devices is also required for proper I2C communications.  Many devices such as sensors, analog inputs, digital inputs, analog outputs, etc can be powered strictly from 5VDC on that cable.  Other higher power demanding products like Relay Controllers however require an alternative power source which is connected right to the control board itself.

All Control Everything I2C based products have an I2C in and an I2C out.  There are no exceptions.  I2C devices are meant to be chained on a bus.  Not having both connections on a product would break that chain.  The I2C in connection could be from a plugged in Bluz module or from an I2C in plug in cable connection.  There is always an I2C out plug in connection(on many products this connector is right under the end of the Bluz module.

Figure 1-1.  Bluz module installed in current monitoring IOT Motherboard. 

Figure 1-2 Bluz module installed in I2C interface shield

Getting Started

Get your Bluz Module Ready

Setting up the Bluz module is really easy using Bluz’s free iOS or Android app.  You will also need to create a Particle account which you can do at http://build.particle.io  Particle has fantastic documentation on how to create your account.  Once you have a Particle account and the app is installed on your phone install the Bluz module in your new ControlEverything board and power it up.  Open the Bluz app and login to your Particle account.  Now you will need to scan for devices.  The new Bluz module should show up, select to connect to it, then claim it, and you are ready to go.  See more about setting the Bluz module up here:

http://docs.bluz.io/tutorials/getting_started/

Once you have a Particle account, the module is connected to your phone, and is claimed to your Particle account we are ready to get started programming.  But first, hook up all your wonderful new ControlEverything hardware whether that means simply plugging the Bluz module into the board, or connecting some I2C cables to get everything online and ready to go.

Writing your first application on Bluz

Open your favorite web browser and head over to http://build.particle.io  This is Particle’s Build IDE which is compatible with Bluz modules.  Take a moment to get familiar with the environment.  Menus on the left side(top to bottom) will allow you to flash code to the module, check code for errors, save code, view your other custom coded applications, pull in community contributed libraries, browse Particle Docs, View your list of devices and their online status, link over to the console where you can get more info on the devices, and change various account settings.  Be sure to check out Particle’s great documentation that goes into depth on the Build IDE here for more info:

http://docs.particle.io/guide/getting-started/build/photon/

So if this is your first time coming to Build if you look on the left side of the screen there is probably a text box over there waiting for you to enter the name of your very first awesome custom application.  You have to put a name in there or you will not be allowed to save or flash the firmware so give your first application a name there and hit enter.

Ok.  For our first application we are just going to scan the Bluz module’s I2C port for connected devices, we will then publish a Particle event with that list of devices so we can see what’s connected.  This is a super useful application you will be likely to use time and time again in the future when using ControlEverything products.  Paste this code into the code editor window:

void setup() {
    //Set the speed of the I2C port on the Photon and start it.
    Wire.begin(); 
}

void loop() {
    bool devicesFound = false;
    String newDevices;
    //Step through all 127 possible I2C addresses to scan for devices on the I2C bus.
    for(int i = 1; i < 128; i++){
        //Make a general call to device at the current address to see if anything responds.
        Wire.beginTransmission(i);
        byte status = Wire.endTransmission();
        if(status == 0){
            //Device found so append it to our device list event string
            char devices[20];
            sprintf(devices, "Device at: %in", i);
            newDevices.concat(devices);
            devicesFound = true;
        }
        
    }
    if(devicesFound){
        Particle.publish("New Devices", newDevices);
    }else{
        Particle.publish("New Devices", "No Devices Found");
    }
    
    delay(2000);
}

This code is really handy for determining if all your hardware is hooked up and functioning correctly.  It also helps you to identify the I2C address of all devices connected.  Really handy code to have when working with I2C devices.

Now to flash that code into the module look on the Build IDE.  On the left side of the screen you will see an icon that looks like a target, click that.  This displays all Particle modules on your account as well as Bluz modules and allows you to select the correct one to flash firmware to(also indicates devices online or not).  If you have more than one Bluz or Particle module make sure you select it with a star, this determines which module the code is flashed to.  If you only have one Bluz/Particle module then no need to worry, code will flash to it by default.  Now just click the Flash icon in the upper left corner(looks like a lightning bolt).  Almost as if by magic that code will compile on Particle’s server and will then flash right into the Bluz module and start running.  You can watch the LED on the Bluz module for fun.  It will flash Magenta when code is being flashed.  Once it is completely done you will want to make sure to click the connect button on your smartphone app again which will give the Bluz module a valid connection to the internet.  It is important to keep in mind that the Bluz module uses your phone in this scenario as it’s way of connection to Particle’s cloud.  Alternatively you can purchase or build a Bluz gateway more on that from http://bluz.io

Monitor Data Published by Bluz

Particle has a really cool tool called Console.  You can pull it up in your browser by heading over to http://console.particle.io  Do that now!  Ok here there is allot you can do and you should read Particle’s Documentation on the console here when you get a chance:

http://docs.particle.io/guide/tools-and-features/console/

All we are interested in right now is seeing that event the Bluz module is publishing which will tell us if our I2C devices are connected and if so what their addresses are.  So on the console page click on the Logs icon on the left.  Here you will see the events published by your module showing the I2C addresses of all connected devices.

If all goes well you will see some devices listed in those published events.

0 Comments

Leave a reply

ControlAnything.com and ControlEverything Site Migration Notes

©2018 National Control Devices, LLC

ncd.io

Made in the USA
5 Year Warranty
Free Shipping on orders over $100
Free Shipping on orders over $100

To learn something new, take the path that you took yesterday. ~John Burroughs

*

Log in with your credentials

or    

Forgot your details?

Create Account