UbiMakerMaria Carlina Hernandez
Published © CC BY-NC-SA

Build an Energy Monitor Device Using a Particle Electron

Monitor your machine's energy consumption with this low-cost, Industrial Energy Monitor tutorial in just a few minutes.

BeginnerFull instructions provided3 hours1,608
Build an Energy Monitor Device Using a Particle Electron

Things used in this project

Hardware components

Electron
Particle Electron
×1
Particle Electron 1 channel 20 amp current monitoring controller
ControlEverything.com Particle Electron 1 channel 20 amp current monitoring controller
×1

Software apps and online services

Ubidots
Ubidots

Story

Read more

Code

Code snippet #1

Plain text
// 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);
}

Code snippet #2

Plain text
// 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);
}

Credits

UbiMaker

UbiMaker

52 projects • 204 followers
Maker @ ubidots.com
Maria Carlina Hernandez

Maria Carlina Hernandez

27 projects • 81 followers
A passionate maker behind an Automation Engineer, who loves constantly learn and share her skills. IoT Developer Advocate @Ubidots.

Comments

Add projectSign up / Login