Skip to content

Instantly share code, notes, and snippets.

@ubi-gists
Created October 24, 2017 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ubi-gists/7b43bf44b724fecae88c92655e216100 to your computer and use it in GitHub Desktop.
Save ubi-gists/7b43bf44b724fecae88c92655e216100 to your computer and use it in GitHub Desktop.
// 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment