Created
October 24, 2017 02:05
-
-
Save ubi-gists/7b43bf44b724fecae88c92655e216100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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