mikecmills2

GroveStreams Particle.io Electron Webhook

Oct 11th, 2016
1,784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. unsigned long lastUploadTime = 0UL; //Don't change. Used to determine if samples need to be uploaded.
  2. const unsigned long updateFrequency = 20000UL;    // Update frequency in milliseconds (20000 = 20 seconds).
  3.  
  4. void setup() {
  5.    
  6. }
  7.  
  8. void loop() {
  9.    
  10.   unsigned long now = millis();
  11.   if(now - lastUploadTime > updateFrequency)
  12.   {
  13.     lastUploadTime = now;
  14.    
  15.     FuelGauge fuel;
  16.     char voltageBuf[15] = {0}; //Initialize buffer to nulls
  17.     String(fuel.getVCell()).toCharArray(voltageBuf,10); //Convert float to string
  18.    
  19.     Spark.publish("f", voltageBuf, 60, PRIVATE);
  20.   }
  21.    
  22.  
  23. }
Add Comment
Please, Sign In to add comment