Gamebuino battery data

Show us your Gamebuino clone or the last module you made.

Gamebuino battery data

Postby inversesandwich » Sun Jul 27, 2014 9:57 am

I've published the data captured by the batterylogger sketch to an interactive graph! Click here to view it. I might post more in the future to see if battery performance changes.
User avatar
inversesandwich
 
Posts: 32
Joined: Sat Apr 19, 2014 10:34 pm
Location: United Kingdom

Re: Gamebuino battery data

Postby gamebox13 » Fri Dec 23, 2016 10:00 pm

I've tried to compile this sketch and run, but had some problem with output txt file. On gamebuino it runs without errors, txt file created but on PC it not opens, because it is corrupt (says filesize is not ok). After chkdsk the file is empty. Tried many times, runs about 9 hours before battery discharge or 10 min and got same result with corrupt file.
gamebox13
 
Posts: 5
Joined: Tue Apr 12, 2016 6:24 am

Re: Gamebuino battery data

Postby Sorunome » Sat Dec 24, 2016 10:22 am

Which SD library do you use?
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Gamebuino battery data

Postby gamebox13 » Sat Dec 24, 2016 4:12 pm

This sketch was in gamebuino's examples and uses tinyfat.
gamebox13
 
Posts: 5
Joined: Tue Apr 12, 2016 6:24 am

Re: Gamebuino battery data

Postby Sorunome » Sat Dec 24, 2016 10:58 pm

Yeah, somehow that one doesn't work anymore for writing files, only for reading them. IIRC SdFat works fine for reading&writing files, so use that one instead
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Gamebuino battery data

Postby gamebox13 » Tue Jan 03, 2017 9:49 am

I made script, which plot voltage's graph on screen. There are max,min voltage and time. It has 512 size of array and can storage about 17 hours graph with every 2 minutes records.

PC250295.JPG
PC250295.JPG (236.13 KiB) Viewed 3133 times


Code: Select all
#include <Gamebuino.h>
#include <SPI.h>
Gamebuino gb;
unsigned int tm=0;
int i;
int t;
unsigned long x,y,xt,yt;
unsigned int bmax;
unsigned int bmin;
unsigned int bat;
unsigned int data[512]={};
void setup() {
  // put your setup code here, to run once:
  gb.begin();
  gb.titleScreen(F("Battery Monitor"));
  gb.backlight.automatic = false;
  gb.backlight.set(0);
  gb.display.clear();
  gb.display.persistence = true;
  gb.battery.show = false;
  gb.display.textWrap = false;
 
  data[0]=int(gb.battery.voltage);
}

void loop() {

  if(gb.update()){
  if(gb.buttons.pressed(BTN_C)){
      gb.titleScreen(F("Battery Monitor"));
      //reset();
    }
  t++;
 
  if (t>=1200*2){
    t=0;
    if (tm<511){
      tm++;
   
      bat=gb.battery.voltage;
      data[tm]=bat;
      bmin=4500;
      bmax=0;
      for (i=0; i<tm; i++)
      {
        if (data[i]<bmin) bmin=data[i];
        if (data[i]>bmax) bmax=data[i];
      }
   
    }
  }
   
 
  if((gb.frameCount%20) == 0){
   gb.display.clear();
   xt=0;
   yt=0;
    for (i=0; i<tm; i++)
      {
        x=1+i*83/(tm);
        y=int(long(47)*(bmax-data[i])/(bmax-bmin));
        gb.display.drawLine(xt,yt, x,y);
        xt=x;
        yt=y;
      }
  gb.display.drawFastVLine(0,0,48);
  gb.display.drawFastHLine(0,47,84);
  gb.display.cursorX = 40;
  gb.display.cursorY = 41;
  gb.display.print(tm*2);
  gb.display.println(F("min"));
  gb.display.cursorX = 60;
  gb.display.cursorY = 0;
  gb.display.print(bmax);
  gb.display.println(F("mV"));
  gb.display.cursorX = 2;
  gb.display.cursorY = 41;
  gb.display.print(bmin);
  gb.display.println(F("mV"));
 
  if (gb.battery.level<=1) gb.sound.playTick();
  }
  }
}
gamebox13
 
Posts: 5
Joined: Tue Apr 12, 2016 6:24 am


Return to Hardware Gallery

Who is online

Users browsing this forum: No registered users and 1 guest

cron