Hello guys, In this tutorial we will see how to make your own pedometer which will count how many steps you have walked and also calculate calories burn and distance covered in Km. It will send that data directly to smart phone via Bluetooth. So let’s get started.

For this you will need

  1. Lilypad Arduino,
  2. Accelerometer sensor (ADXL335),
  3. Bluetooth module (HC-05),
  4. Jumper Wire,
  5. Lipo battery or Bluetooth battery
  6. FTDI adapter (For uploading the code)
    OR
  7. Arduino uno,(For uploading the code)

Do connections as shown in diagram.

How to make your own pedometer, Fitness band DIY

 

Sketch:
#include <SoftwareSerial.h>
SoftwareSerial MySerial(10, 11); // pin 10 connects to TX of HC-05 | pin 11 connects to RX of HC-05
int x,y;
int count =0;
float calories;
float distance;
void setup() {
MySerial.begin(9600); 
}

void loop() {
x = analogRead(A0);
y = analogRead(A1);
if ( x <= 450 && y>=390)
{ count++;
//MySerial.print(count);
delay(200);
}
if ( x >= 460 && y<=370)
{
count++;
// MySerial.print(count);
delay(200);
}
calories = count * 0.035; // This value is taken depending upon my weight and height.
distance = count * 0.0006; // My step it is on average 60cm. 
MySerial.print(x);
MySerial.print(",");
MySerial.print(y);
MySerial.print(",");
MySerial.print(count);
MySerial.print(",");
MySerial.print(calories);
MySerial.print(",");
MySerial.print(distance);
MySerial.print(";");
delay(150); 
}
Explanation:

Add SoftwareSerial library, which is inbuilt library.

#include <SoftwareSerial.h>
SoftwareSerial MySerial(10, 11); // pin 10 connects to TX of HC-05 | pin 11 connects to RX of HC-05

We are adding this library because we want serial communication on different pins. If we use pin 0 and 1 for serial communication we have to unplug the pins before uploading code and then plug it again. If we don’t unplug the pins it shows error while uploading the code. It is really annoying if we are doing trial and error with codes so that’s the reason we use softwareSerial library.

We are taking hands acceleration in x and y direction to detect steps. Place accelerometer such that Z-axis is perpendicular to lilypad and X-axis and Y-axis is parallel to lilypad.

arduino pedometer

Finding the range of acceleration values in which your hand moves is really difficult task. Because when you upload the code to lilypad you may little displace the accelerometer because of inserting and removing pins. If it is displaced little bit. Accelerometer changes its values. So you need to make sure accelerometer is firmly placed on lilypad, and also make sure you don’t close the pins of lilypad where you will upload the code.

readings hands still

Find the range of x and y value when your hand is still. This range will not be inserted in the code. But you need to find it out because you will get an idea. When your hand is moving forward then x and y value is increasing or decreasing.

readings hands moving forward

Move your hand in forward direction and note the values in x and y direction.

readings hands moving backward

Similarly find the range for x and y values for backward direction. Depend upon your still hand values, use <= , >= this condition.

I refer this website for calculating the calories burn, so for my height weight I found 1 step burn 0.035 calories. Similarly you can find yours. I measured my 1 step is on average 60cm. we can easily calculate distance by multiplying it with steps count.

We are printing these values on mobile phone via Bluetooth. So we have to put comma (,) after every value and at the end put semi colon (;).

MySerial.print(x);
MySerial.print(",");
MySerial.print(y);
MySerial.print(",");
MySerial.print(count);
MySerial.print(",");
MySerial.print(calories);
MySerial.print(",");
MySerial.print(distance);
MySerial.print(";");

I am not using FTDI adapter so I will upload the code to lilypad with Arduino uno. You have to carefully remove the IC.

Remove IC of Arduino

Remove IC of Arduino

Then connect jumper wires as shown in diagram.

Upload code to lilypad using arduino uno

Upload code to Lilypad using Arduino Uno

Select proper port and make sure it is Arduino uno not Lilypad Arduino. Upload the code. When uploading is done. Download the app Arduino Bluetooth Terminal. Connect it with your mobile phone, password will be 0000 or 1234. After connecting, open the app. Click on linked device. Select receiver.

Go to settings and you can edit these labels and change sensors name. Also, make sure in your code, the flow of data and label in the same position.

How to make your own pedometer, Fitness band DIY

Click on red link button. Now you can see the values. I have tried this pedometer with different acceleration values. I found that for actual 100 steps it was counting 90, 96, 105, 104. We can improve its accuracy by clearly defining our hand acceleration, which will require lots of trial and error. In this pedometer there is one flaw which I didn’t work on that part, it will count steps when your hand moves even when you sat on chair. I hope you will like my effort.

arduino pedometer reading

Till then keep learning keep making.