• 1
    Hardware setup

     1. Begin by attaching the Particle Electron to the ControlEverything - Current monitor shield.

    2. To protect the device from messy or harsh environments, we used a Takachi enclousure which offers many different types of models, making our custom projects  easy to build.

    3. To take the current measurement the circuit must be interrupted. We built our application without the need to solder or modify the original connectors.

    The diagram below illustrates the hardware integration for this Energy Monitoring project. We suggest deploying this monitoring system on a local non-critical device first to test – like the office coffee machine. :)

  • 2
    Firmware setup

    1. Follow these steps to set up the Particle data plan. Particle Electron steps.

    2. Once you've claimed your Particle Device, let’s go to Particle’s Web IDE and compile our firmware. 

    3. In the Particle’s Web IDE create a new app and set the name "EnergyMonitor

    4. Now that the application is created you have to add the libraries required to the application. To do this, go to the library tab and search the library "current_monitor" in the Community Libraries field, then press the "include in project" and select the application previously created "EnergyMonitor", to finish just press confirm. Once the library is properly added, you will see it in the "Included libraries" of the application.

    Follow the same process above to add the "Ubidots" library. Make sure to add the latests available library version. Note that there is also an Ubidots MQTT library. For this tutorial, we will be using the HTTP "Ubidots" library, but if you prefer to utilize MQTT protocols you can learn how to set up your Electron over MQTT using this link.

    5. Now that the application is ready, it's time to code! Copy and paste into the Particle IDE the code below. Once the code is properly pasted, assign your ubidots token where is indicated. See here if you cannot locate your Ubidots TOKEN.

    // This #include statement was automatically added by the Particle IDE.
    #include <Ubidots.h>
    
    // This #include statement was automatically added by the Particle IDE.
    #include <Current_Monitor.h>
    
    #ifndef TOKEN
    #define TOKEN "put_your_ubidots_token_here" // Put here your Ubidots TOKEN
    #endif
    
    Ubidots ubidots(TOKEN);
    CurrentMonitor current;
    double current_reading = 0;
    
    void setup() {
        Serial.begin(9600);
        if(!current.initialize(0,0,0,0)){
            Serial.println("Initialize failed");
        }
        Particle.variable("Current", current_reading);
        delay(5000);
    }
    
    void loop() {
        if(current.deviceStatusReady){
            double c = current.readChannelCurrent(1);
            if(c != current.failedCommand){
                current_reading = c;
                Serial.println(current_reading);
                ubidots.add("Current", current_reading);  // Change for your variable name
                if(ubidots.sendAll()){
                    // Do something if values were sent properly
                    Serial.println("Values sent by the device");
                }
            }
        }
        delay(1000);
    }

    Once you have pasted the code and updated the Ubidots TOKEN line, you must Verify this code within the Particle IDE. In the top left corner of our Particle IDE you will see the below icons. Click the Check Mark icon to verify this and any code.

    Once verified, you will receive a "Code verified! Great work" message in the Particle IDE.

    Next, upload the code into your Particle Electron by clicking the lightening bolt icon. (Be sure that your Electron is plugged into your computer's USB port before trying to upload.)

    Select the "FLASH OTA ANYWAY" to start the upload.

    Once the code is uploaded, you will receive a "Flash successful! Your device is being updated - Ready" message in the Particle IDE

    With this steps, you are now sending sending the sensor's data to the Ubidots Cloud!

  • 3
    Management of the data in Ubidots
    1. Once the particle electron has sent its first message, a new device will be created and can be found in the Device section of your Ubidots application. The name of the device will be "particle", also inside the device you will see the variable current has been been automatically created for you. 

    If you desire to change your device or variable names to a more friendly nomenclature, please see Ubidots Help Center to find: How to adjust you Device Name and Variable Name

    2. Next, to calculate the power based on the current obtained, we need to create a derived variable. The Derived Variable allows us to construct mathematical operations using the default variables of your account. In this case we are going to apply the power formula of Current multiplied by Voltage (110 AMPS).

    To create the Derived variable, click on "Add variable" and select "Derived":

    As you can see in this images, you can most any mathematical function with relative ease.

    With your formula entered, your new variable within the Particle's device menu will now display the power levels of your machine.

    3. Customize the units of the variables to make sense of the dashboard quick by editing the Variable's information in on the left-hand pane.


    As you can see below, we edited the units for each variable to Watts and AMPs:

    To modify the icon of the variable just double click in the icon in the upper left hand corner and select your desired icon.

    Completed icon customization can look as follows:

    3. Now it is time to create a dashboard to control and manage your Particle device and deploy your Energy Monitoring Application. To learn more about Ubidots widgets and events, check out these helpful video tutorials.