sayinath karuppanan
Published

Fitness Tracker Using POV Display

Heart beat count and steps count are calculated and calories burnt is retrieved from it and displayed using POV through IOT.

Showcase (no instructions)6,194
Fitness Tracker Using POV Display

Things used in this project

Story

Read more

Schematics

pov display

PLSE refers to heart beat
CAL refers to calories burnt
STEPS refer to jogging distance

pulse sensor

it shows pulse sensor connection and working

pov clock

piezo counter

Code

calorie calculator

Arduino
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ArduinoJson.h> 
#include <ArduinoHttpClient.h> 

int h1;
int d;
int f;
int ledPin = 13;
int knockSensor = 0;               
byte val = 0;
int statePin = LOW;
int THRESHOLD = 100;
int steps1;

char ssid[] = "wifi name";     
char pass[] = "wifi password";



char server[] = "api.artik.cloud";   //cloud intializaton
int port = 443;             // 443 for HTTPS 
char buf[200]; // buffer to store the JSON to be sent to the ARTIK cloud 
String deviceID = " device id"; 
String deviceToken = "device token";




WiFiSSLClient wifi; 
HttpClient client = HttpClient(wifi, server, port);



void setup()
{
  
  pinMode(A0,INPUT);
  pinMode(ledPin, OUTPUT);
  millis_start = millis();
  Serial.begin(9600);
  connectWifi();                      //conncet to wifi
}

void loop()
{
  h=int heart();
  steps=int piezo();
   Serial.println("making POST request");
  String contentType = "application/json"; 
  String AuthorizationData = "Bearer " + deviceToken; //Device Token 
  int len = loadBuffer(h,steps);   
  
  // push the data to the ARTIK Cloud
  Serial.println("Sending piezo: "+String(piezo) +" and heart: "+String(heart) );  
  Serial.println("Send POST to ARTIK Cloud API"); 
  client.beginRequest(); 
  client.post("/v1.1/messages"); //, contentType, buf 
  client.sendHeader("Authorization", AuthorizationData); 
  client.sendHeader("Content-Type", "application/json"); 
  client.sendHeader("Content-Length", len); 
  client.endRequest(); 
  client.print(buf); 

  // read the status code and body of the response

  int statusCode = client.responseStatusCode(); 
  String response = client.responseBody(); 

  Serial.print("Status code: "); 
  Serial.println(statusCode); 
  Serial.print("Response: "); 
  Serial.println(response);   
  delay(1000); // delay of update 
  
}

void conncetWifi(){
  Serial.println("Connecting node mcu to network...");
  //  WiFi.begin();
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED ) {
    Serial.print("Attempting to connect network");
    Serial.println(WIFI_AP);
    status=WiFi.begin(ssid, pass);
    // wait 5 seconds for connection:
    delay(5000);
   
  }
}



/*Buffer to send on REST*/
int loadBuffer(int h,int steps) {   
  StaticJsonBuffer<200> jsonBuffer; // reserve spot in memory 
  JsonObject& root = jsonBuffer.createObject(); // create root objects 
  root["sdid"] =  deviceID;   
  root["type"] = "message"; 
  JsonObject& dataPair = root.createNestedObject("data"); // create nested objects 
  dataPair["pulse"] = h;   
  dataPair["step"] = steps; 
  root.printTo(buf, sizeof(buf)); // JSON-print to buffer 
  return (root.measureLength()); // also return length 
} 

int heart() 
{
 d=analogRead(A0);

 Serial.println(d);
 h=60000/d;// gives heart count
 Serial.print("heart beat:");
 Serial.print(h1);
 Serial.println();
 return(h1);
 
}
// to determine step count
int piezo() {

  val = analogRead(A1);     

  if (val >= THRESHOLD) {

    statePin = !statePin;

    digitalWrite(ledPin, statePin);

    Serial.println("Knock!");

      steps1++;//gives step value
return(steps1);
  }

  delay(100);  // we have to make a delay to avoid overloading the serial port

}

pov dispaly

Arduino
int pin=7;
int _[] = {0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0};
int A[] = {1,1,1,1,1,1,1, 1,0,0,1,0,0,0, 1,0,0,1,0,0,0, 1,0,0,1,0,0,0, 1,1,1,1,1,1,1};
int B[] = {0,1,0,0,0,1,0, 1,0,1,0,1,0,1,  1,0,0,1,0,0,1, 1,0,0,1,0,0,1, 1,1,1,1,1,1,1};
int C[] = {1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1,  1,1,1,1,1,1,1};
int D[] = {0,0,1,1,1,0,0, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 1,0,0,0,0,0,1, 1,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0,0,1, 1,0,0,0,0,1,1,  1,0,0,0,0,0,1, 0,1,1,1,1,1,0,};
int R[] = {0,1,1,0,0,0,1, 1,0,0,1,1,0,0, 1,0,0,1,0,0,0, 1,0,0,1,0,0,0,  1,1,1,1,1,1,1, };
int S[] = {1,0,0,1,1,1,1, 1,0,0,1,0,0,1, 1,0,0,1,0,0,1, 1,0,0,1,0,0,1,  1,1,1,1,0,0,1, };
int T[] = {1,0,0,0,0,0,0, 1,0,0,0,0,0,0, 1,1,1,1,1,1,1, 1,0,0,0,0,0,0, 1,0,0,0,0,0,0};
int U[] = {1,1,1,1,1,1,1, 0,0,0,0,0,0,1, 0,0,0,0,0,0,1, 0,0,0,0,0,0,1, 1,1,1,1,1,1,1};
int V[] = {1,1,1,0,0,0,0, 0,0,0,0,1,0,0, 0,0,0,0,0,0,1, 0,0,0,0,1,0,0, 1,1,1,0,0,0,0};
int W[] = {1,1,1,1,1,1,1, 0,0,0,0,0,1,0, 0,0,0,1,0,0,0, 0,0,0,0,0,1,0, 1,1,1,1,1,1,1};
int X[] = {1,0,0,0,0,0,1, 0,0,1,0,0,1,0, 0,0,0,1,0,0,0, 0,0,1,0,0,1,0, 1,0,0,0,0,0,1};
int Y[] = {1,0,0,0,0,0,0, 1,0,1,0,0,0,0, 0,0,0,1,1,1,1, 1,0,1,0,0,0,0, 1,0,0,0,0,0,0};
int Z[] = {1,0,0,0,0,0,1, 1,0,0,0,1,0,1, 1,0,0,1,0,0,1, 1,0,1,0,0,0,1, 1,0,0,0,0,0,1};
int letterSpace;
int dotTime;
float cal=((-55.0969+(.6309*heartbeat)+(0.1988*weight)+(0.2017*age))/4.184*60*time
char abc[]="cal heartbeat step";// enter data here
int temp[23];
int count=0;
int c=0;
int var=0;
int q=0;
int b;
int z=0;
int d[20];
int tep=0;
int w=0;
int arr[]={16,5,4,0,2,14,12};
void setup()
{
  // setting the ports of the leds to OUTPUT
  Serial.begin(115200);
  pinMode(D0, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(D3, OUTPUT);  
  pinMode(D4, OUTPUT);
  pinMode(D5, OUTPUT);
  pinMode(D6, OUTPUT);
  pinMode(A0,INPUT);
 
  // defining the space between the letters (ms)
  letterSpace = 3;
  // defining the time dots appear (ms)
  dotTime =1;
 
}
void printlet(int letter[])
{
  int y;
 
  // printing the first y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(arr[y], letter[y]);
    //Serial.print(letter[y]);
  }
  delay(dotTime);
 
  // printing the second y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(arr[y], letter[y+7]);
  }
  delay(dotTime);
 
  // printing the third y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(arr[y], letter[y+14]);
  }
  delay(dotTime);
  // printing the fourth y row of the letter
  for (y=0; y<7; y++)
  {
    
    digitalWrite(y+2, letter[y+21]);
  }
  delay(dotTime);
  // printing the fifth y row of the letter
  for (y=0; y<7; y++)
  {
    digitalWrite(arr[y], letter[y+28]);
  }
  delay(dotTime);
  
  for(y=0;y<7;y++)
  {
    digitalWrite(arr[y],0);
  }
  delay(letterSpace);

  
 
  
}

void loop()
{ 
   for(int i=0;i<=(sizeof(abc)-2);i++)      //splitting the array into pieces for display purpose
  {
     
    if(abc[i]==' ')
    {
      
      temp[q]=i-(tep+1);
      
      if(temp[q]>14)                 //each frame in pov display can display 14 characeters
      {
        var=temp[q-1]+tep+1;
         
         printword(var);
         i=var;
         tep=var;    
         
      }
      q++;
      
      
    }
   if(i==(sizeof(abc)-2))
    {
     


      printword(i);
      i=-1;
      tep=-1;
      q=0;
      z=0;
    }
  }
}
int done=0;
void printword(int a)
{
 int d;
 d=analogRead(A0);
 Serial.println(d);
 if(d>=550)
 {
 
  
 for(b=z;b<=a;b++)
 {
 // Serial.println(abc[b]);
   switch(abc[b])
      {
        case 'a': printlet(A);
        break;
        case 'A':printlet(A);
        break;
        case 'b': printlet(B);
        break;
        case 'B':printlet(B);
        break;
        case 'c': printlet(C);
        break;
        case 'C':printlet(C);
        break;
        case 'd': printlet(D);
        break;
        case 'D':printlet(D);
        break;
        case 'e': printlet(E);
        break;
        case 'E':printlet(E);
        break;
        case 'f': printlet(F);
        break;
        case 'F':printlet(F);
        break;
        case 'g': printlet(G);
        break;
        case 'G':printlet(G);
        break;
        case 'h': printlet(H);
        break;
        case 'H':printlet(H);
        break;
        case 'i': printlet(I);
        break;
        case 'I':printlet(I);
        break;
        case 'j': printlet(J);
        break;
        case 'J':printlet(J);
        break;
        case 'k': printlet(K);
        break;
        case 'K':printlet(K);
        break;
        case 'l': printlet(L);
        break;
        case 'L':printlet(L);
        break;
        case 'm': printlet(M);
        break;
        case 'M':printlet(M);
        break;
        case 'n': printlet(N);
        break;
        case 'N':printlet(N);
        break;
        case 'o': printlet(O);
        break;
        case 'O':printlet(O);
        break;
        case 'p': printlet(P);
        break;
        case 'P':printlet(P);
        break;
        case 'q': printlet(Q);
        break;
        case 'Q':printlet(Q);
        break;
        case 'r': printlet(R);
        break;
        case 'R':printlet(R);
        break;
        case 's': printlet(S);
        break;
        case 'S':printlet(S);
        break;
        case 't': printlet(T);
        break;
        case 'T':printlet(T);
        break;
        case 'u': printlet(U);
        break;
        case 'U':printlet(U);
        break;
        case 'v': printlet(V);
        break;
        case 'V':printlet(V);
        break;
        case 'w': printlet(W);
        break;
        case 'W':printlet(W);
        break;
  case 'x': printlet(X);
        break;
        case 'X':printlet(X);
      break;
        case 'y': printlet(Y);
        break;
        case 'Y':printlet(Y);
        break;
        case 'z': printlet(Z);
        break;
        case 'Z':printlet(Z);
       break;
        case ' ':printlet(_);
        break;
      }

 // delay(1000);
  
 } 
 
 



 }
}

pov clock

Arduino
when you are not jogging or exercising pov display is used as clock
int s=0,m=20,h=30;// initial time
int a,b,c;
int x;
unsigned long tym;
unsigned long previoustym=0;
int tempo;
int seconds=0;
int minutes=0;
int hours=0;

int sec[]= {1,1,1,1,1,1,1,1,1};
int minu[]={0,0,0,0,1,1,1,1,1};
int hr[]=  {0,0,0,0,0,0,1,1,1};
int arr[]={16,5,4,0,2,14,12,13,15};
int q=0;
int z=0;
int done=0;
void setup()
{
  Serial.begin(115200);
 pinMode(D0, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(D3, OUTPUT);  
  pinMode(D4, OUTPUT);
  pinMode(D5, OUTPUT);
  pinMode(D6, OUTPUT);
  pinMode(D7, OUTPUT);
  pinMode(D8, OUTPUT);
  pinMode(A0,INPUT);
  
}
void printlet(int letter[])
{
  int y;
  for (y=0; y<9; y++)
  {
  digitalWrite(arr[y], letter[y]);
  }
  
  delay(1);
   for (y=0; y<9; y++)
  {
   
    digitalWrite(arr[y],0);
  }
  }
  
 
  
  void loop() 
  { 
     tym=millis();
     x=tym-previoustym;
     if(x>=1000)
     {
       previoustym=tym;
      s=s+2;       // incrementing 2 in pov display will increase 1 in real time
      seconds++;
   
     }
       if(seconds==60)
      {
        m=m+2;     // incrementing 2 in pov display will increase 1 in real time
        seconds=0;
        s=0;
        minutes++;
      }
      
      switch(minutes)
      {
        
        case 10:
              h=h+2;
              break;
       case 20:
              h=h+2;
              break;
        case 30:
              h=h+2;    
              break;
        case 40:
              h=h+2;
              break;
        case 50:
              break;
        case 60:
              h=h+2; 
              minutes=0; 
               m=0;
             break;
             default:
             break;  
         }
      a=s;
      b=m;
      c=h;
    Serial.println(seconds); 
    
  //sorting to find which one to display first
  if (a>b) 
  {
    tempo=b;
    b=a;
    a=tempo;
  }
 if(a>c)
  {
    tempo=c;
    c=a;
    a=tempo;
  }
  if(b>c)
  {
    tempo=c;
    c=b;
    b=tempo;
  }
            
 
     while(1)              //breaks the loop when ir sensor is high
  {
    int done=analogRead(A0);
    if(done>550)
      break;
  }
   
delay(a);
if(a==s)
          {  
           // Serial.print(a);
            // Serial.print("sec");
           printlet(sec);
           }
           
else if(a==m)
           {
         //  Serial.print(a);
            // Serial.print("min"); 
           printlet(minu);
           }
else if(a==h)
            {
      
            // Serial.print(a);
             //Serial.print("hr");  
             printlet(hr);
           }
         //  Serial.print(":");
       //    Serial.println("................... ");

           
  q=b-a;
  delay(q);
   while(1)
  {
     if(b==s)
          {// Serial.print(b);
             //Serial.print("sec"); 
            printlet(sec);
             break;
          }
      else if(b==m)
      {
            
            
            //  Serial.print(b);
             //
            // Serial.print("min"); 
               printlet(minu);
               break;
       }
 else if(b==h)
 {
            // Serial.print(b);
            /// Serial.print("hr"); 
            printlet(hr);
            break; 
   }        
  }
//Serial.print(":");



 
 z=c-b; 
  delay(z);
 while(1)
  {
 if(c==s)
    {     
    // Serial.print(c);
    //  Serial.print("sec");   
      printlet(sec);
      break;
      }
else if(c==m)
{
         //  Serial.print(c);
         //  Serial.print("min");   
           printlet(minu);
           break;
}
 else if(c==h)
 {
        // Serial.print(c);
        //   Serial.print("hr");    
           printlet(hr);
          break;    

}

}
//Serial.println("");

 }
 

Credits

sayinath karuppanan

sayinath karuppanan

1 project • 2 followers

Comments