Arduino Pedometer




Introduction: Arduino Pedometer

About: Lazy Old Geek

Problem: So my nutritionist (doesn’t everyone have a nutritionist) suggested I should increase my exercise which primarily consists of walking my dog. She even gave me a chart of activities and calories burned. Here’s an example.
Well, being a LAZY OLD GEEK, I decided to monitor my walking electronically.

Solution: It was a “long and winding road” but here’s the finished product. It’s not very elegant but it does the job. The Arduino attaches to the pedometer which counts my steps and records steps plus temperature and humidity and time to the SD card.

Parts List:
USB Freeduino kit
(Arduino-clone) $22.50
HSM-20G Temp-RH $9 (Closeout)
AdaFruit Datalogger $19.50
Adafruit 6 AA
Battery holder $5.00
Pedometer $1 (Dollar Store)
SD Card $6

Prices US dollars December 2010

The total is about $63. Yes, it’s costly but the Arduino stuff can be used for other projects.

Soldering tools
DMM Recommended

Step 1: Selecting Parts

I recently built an Arduino with LCD to measure temperature and humidity while taking our walks.

Problem: I decided to extend this concept. The problem with using the LCD is that it’s not easy to use or see, especially when wrestling with my big dog, Marcus.

Solution: Recently I received an Adafruit datalogger kit for my birthday.
See picture. This Adafruit kit is well designed and uses quality parts. As with all Adafruit products, the assembly instructions are excellent. For a LAZY OLD GEEK I really appreciate the quality of the PCB which makes soldering and unsoldering easy. Another nice feature is the real time clock with battery. Highly recommended.

I used an Adafruit 6 AA Battery holder because it will work with rechargeable batteries. It is a lot bigger and heavier than a 9Volt holder, however.

For logging data, you need an SD card. Adafruit recommends 2gB or less and not SDHC.

The Arduino-clone, Freeduino and the temperature-humidity sensor are the same ones used in the previous Instructable.

Problem: How to monitor walking. My first idea was to use the GPS, I have.
Well this GPS has a USB output. I tried various methods/schemes to interface this with my Arduino but had no success. Also my experience with my GPS is that it is not that accurate for short distances. It would probably work if our walks were long straight distances but walking with Marcus is very convoluted. He follows his nose and we encounter a lot of rabbit and field mice smells. And he is big, so I mostly follow.

Solution: I decided a pedometer was a better solution. It’s pretty easy to interface and keeps track of steps. My pedometer was a gift but our dollar store sells pedometers that will probably work as well as the one I used.

I connected the sensors with telephone wire.

Step 2: Pedometer Wiring

The pedometer I used is an Accusplit x 120. It is available from See picture.

Most pedometers use the same basic design. A little weighted arm is held up by a tiny spring. When the user walks, the hip movement and gravity lets the arm drop down closing an electrical contact.
See first green pedometer picture.
Warning: When opening up the pedometer, be very careful as there usually is a tiny spring that can come off and get lost. That’s what happened to this one. On this one, the spring went from the bottom metal plate to the metal arm. The spring was part of the electrical circuit that connected the bottom plate to the arm.

When the user steps, gravity forces the metal arm down so that it touches the upper metal plate and electrically shorts the two metal plates together.

Take the cover off the pedometer. It may use screws or mine opened with a twist of a coin.
Carefully turn on the pedometer.
Take your DMM, set it to VDC.
Place the black-negative lead on the bottom metal plate, place the red-postive lead on the upper metal plate.
Measure the voltage, it will probably read about 1.2 VDC
If it measures -1.2VDC then switch the two leads.

If you want and are dexterous, while holding the probes on the pedometer, move the arm down so that it touching the top plate. The voltage should read about 0 VDC.

Black pedometer:
For the pedometer I used, the design is a little different. See picture. The arm is plastic and has a little magnet in it. You should be able to see the little curved spring holding the arm up. On the right is a little glass tube with two leads in it. This is called a reed switch. When the magnet comes close to it, the two leads inside are shorted together so the results are the same as the green pedometer.
For the electronically inclined, the little black cylinder under and to the right of the reed switch is a capacitor. This (I assume) is a hardware debounce component.

The procedure is the same but you measure the voltage across the reed switch. In this case when I had the black lead on the bottom, it read -1.2Vdc. See picture, so I had to switch the leads with the black on top.

Procedure continued:
Cut a length of two wire cable, I made mine about three feet long. I used an old phone cord. This one had two wires, most have four. Solder the ground wire, usually black or in my case, green to where the negative lead of the DMM was. In my case, it was the top of the reed switch. Connect the other wire (red) to where the red DMM lead was, in this case the bottom of the reed switch.

Step 3: Datalogger Wiring

Assemble the datalogger per instructions.
Load the software from Adafruit website.
Set up the real time clock per instructions.
Test the SD card (sdfat) software per instructions

Wiring procedure:
The first picture shows the 5VDC and ground wiring on the datalogger. The green wire is from the pedometer ‘ground’. The small black wire is the ground wire from other telephone wire going to the HSM-20G. The little red wire is the 5VDC connecting to the HSM-20G temperature-humidity sensor.

The second picture shows the red (5VDC) and black (ground) wires going to the prototype area shown in the first picture. The yellow and green wires are the two sensor outputs for the HSM-20G, Humidity to Analog 1 and temperature to 2 of the datalogger and Arduino. The red wire from the pedometer is going to Analog 3.

Warning: If you leave the pedometer connected to the Arduino unpowered, the Arduino will try to draw power from the pedometer and drain the battery faster. When finished, disconnect the datalogger from the Arduino. I didn’t have the instructions for my pedometer but it apparently does not have an on-off switch.
A more permanent solution would be to put a connector on the telephone cord so I could unplug it or put in a switch but I’m LAZY.

Step 4: Pedometer Theory and Software Design

Software is in file

Theory of Operation:

The voltage from the pedometer going to the Arduino Analog 3 is about 1.2VDC. When the user steps, the voltage drops to close to zero. The Arduino software will detect this and count this as a step.

Software Design:

The software has to read the data from the temperature and humidity probe and the pedometer, then log it to the SD card. The software will determine how often to log data to the SD card. This software is set for 10 second samples. This can be changed by changing the value of LOG_INTERVAL (10,000 means 10,000 milliseconds which is 10 seconds).

Reading temperature and humidity can be done once for every log entry.

Problem: The pedometer has to be monitored pretty continuously as a step can occur at any time. (This is called an asynchronous event).

Solution: I had to rewrite the sample program so that the pedometer is sampled constantly and data is collected until the LOG_INTERVAL (10 seconds) is reached, then the temperature and humidity sensors are sampled and all of the data plus the time is written to the SD card.

Here is the significant portions of the software loop.

void loop(void)

// MTS Pedometer reads about 1.2V open = 245 counts
if (analogRead(PedoPin) < 50) // About .245V
  StepCnt +=1;
  TotalCnt +=1;
  delay(300); //Delay .3 sec

if ((millis()-StartTime)>long(LOG_INTERVAL))

  Code that writes to log file

  StepCnt =0;
  StartTime = millis();

Theory: Before the loop is started, StartTime reads in millis() which is the number of milliseconds since the Arduino was powered up or reset.
The pedometer is read, if it’s close to zero, then StepCnt and TotalCnt are incremented.
This is repeated until millis() is 10 seconds or greater than StartTime.

When the 10 seconds has passed, the real time, temperature, humidity, StepCnt and TotalCnt are written to the log file.
The StepCnt is set to zero (so that only counts between samples are recorded)
StartTime is set to millis() so the next 10 second interval can be measured.
The whole process is repeated.

The file created on the SD card is labeled loggerxx.csv where xx is a number starting with 00, e.g., the first will be logger00.csv.
.csv means the file is written as comma separated values and can be read directly into Excel software. It can also be read by Google docs (free) and Open Office (free).

Step 5: Calibration

Problem: Circuits like a pedometer have a problem called debounce. Whenever you have a mechanical switch like the pedometer mechanical arm or reed switch, you might think the switch is open or closed but that is not the case. When the switch contacts get close to each other, there is a varying resistance between the two contacts.
This is indicated in the next picture. For many readers, this won’t mean anything. It is an oscilloscope trace of a switch turning off. But to simplify, it is apparent that it is not a smooth transition from on to off. Since the Arduino chip is fast, it could actually read several ‘steps’ when there should only be one.

Solution: Now this problem can be ‘debounced’ in hardware or software. Since I don’t have any control over the hardware of any pedometer you may be using, I am using a software ‘debounce.’

Here is the pedometer code:

// MTS Pedometer reads about 1.2V open = 245 counts
if (analogRead(PedoPin) < 50) // About .245V
  StepCnt +=1;
  TotalCnt +=1;
  delay(300); //Delay .3 sec

There are two values that may need to be adjusted. The first is the 50. Remember when I said you could measure the closed value for the pedometer? Did you do it? Well, this is the voltage that will be sent out when the user is stepping. The number 50 is in counts where each count is about 0.0049VDC so 50 counts is about 0.245VDC.
This code value needs to be set a little bit above the measured value. The reason is that the actual closed voltage will vary and it will also be different because of the resistance of the wire. I didn’t actually measure the closed value but 50 should work in most cases. The ‘<’ symbol just means that it has to be less than 50. You don’t care how much less.

The other value is the delay(300). This is the software debounce. Not what this means is that if the Arduino sees a step, it will do nothing for .3 second (300 milliseconds) before it will look for another step. If my calculations are right, you would have to be walking/running at over 4.5 MPH for this not to work. I am OLD so I don’t think that will be a problem. If you are younger, you can probably put in a shorter delay value.

Calibration procedure:
Load the Arduino software
Turn on the pedometer
Reset the Arduino
Go for your walk
Record the step count from your pedometer
Wait 10 seconds, disconnect the power to the Arduino
Take the SD card out and stick it in your computer.
Open the last loggerxx.csv file.
Go to the bottom and get that last total count number.
It should be close to the count on your pedometer.
Mine was within 2 counts over a couple of samples over a couple hours each.
If not, tweak the values above and repeat.

I searched the internet on accuracy of pedometers. Most weren’t that accurate, often about 10% so that’s about all the accuracy you can get anyway.

Step 6: Using Arduino Pedometer

Many internet articles on pedometers suggest a good goal for most people is 10,000 steps a day.
You may also be interested in mileage or feet. You can ‘calibrate’ your pedometer by counting how many steps you take for a known distance. I’ve tried this about three times and got three different answers from about 1.8 to 2.1 feet per step.

What my nutritionist is interested in is miles per hour.

Here’s how I use my Arduino pedometer.

The two pictures show the assembly ready for action.

 I restart the Arduino and the pedometer when I start our walk and stop it when I get back.
I open the last loggerxx.csv file with Excel. All I really need is the first record and the last.

date                time       tempF     RH% steps totalsteps
12/23/2010    7:6:54       81        38         4          4
12/23/2010    9:13:18    58        82          0         8552

To calculate the time for the walk, just take the last time and subtract the first time. Excel has a way to do this using something like this
=TIMEVALUE(B753)-TIMEVALUE(B2) {{B753 and B2 are cell numbers}}
This gives a value in days of 0.087778.
Multiply by 24 to get hours = 2.106667

I use a step value of 2 feet per step so multiply totalsteps 8552 * 2 = 17104 feet
Divide by 5280 to get miles = 3.239394
Divide miles by hours to get MPH 3.239394/2.10667 = 1.5 MPH

So according to the chart, with my weight, that means I burned about 280 calories on this walk.

Yes, I know. It’s a lot of algebra but it’s not too hard with Excel.
I’ve includes a sample file Dec23.csv and Dec23.xls with the calculations at the bottom

By the way, this two hour logging only took up 30K on my 64mByte SD card.

Conclusion: My Arduino pedometer seems to work pretty good. Logging to an SD card has the disadvantage of not having on going data but I can get steps by looking at the pedometer.

The log file has other ‘interesting’ information. On a cold December early morning in the high desert, it took about 15 minutes for the temperature to drop from inside house temp of 76F to outside 31F. Humidity stayed pretty constant until it started to warm up. Temperature went for 31F to about 66F which seems a high to me. I should investigate but then I am LAZY.

On some really cold days, I noticed the Arduino pedometer count was higher than the pedometer count but it was still within about 10% so I'm ignoring the differences. I also noticed that the temperature never went below 0 F but am ignoring this also. I shouldn't be walking my dog when it's this cold anyway.

1 Person Made This Project!


  • Remote Control Contest

    Remote Control Contest
  • Build a Tool Contest

    Build a Tool Contest
  • Fruits and Veggies Speed Challenge

    Fruits and Veggies Speed Challenge



4 years ago

In addition to the earlier comment I just posted, here is the serial output I am getting from Arduino. I'm not sure how to fix this.

Initializing SD card...card initialized.
Logging to: LOGGER07.CSV
date, time, tempF,RH%, steps, totalsteps
1998, ⸮⸮⸮b⸮⸮⸮҂҂bJ⸮⸮⸮ 143, 0, 0

3998, ⸮⸮⸮b⸮⸮⸮҂҂bJ⸮⸮⸮ 143, 0, 0

5998, ⸮⸮⸮b⸮⸮⸮҂҂bJ⸮⸮⸮ 143, 0, 0

Any help at all would be very much appreciated, thank you!


Reply 4 years ago

Sorry, I don't see any thing definite but here's a guess.

It looks like the output is correct except for the real time clock stuff. Is this a newer Adafruit datalogger??

It looks like they have two different Real Time Clock ICs

I suspect you have the newer one but don't have the correct library and setup.

Anyway, look thru that link and see if you have the newer chip, PCF8523.

If you do, you will probably have to load the newer library and use the examples to change the code.

Good luck, hope this helps. LOG


Reply 4 years ago

Thank you, yes we the newer Adafruit Datalogger shields as they were purchased about a month ago. I'll have a look into updating the RTC libraries and will let you know how we get on. Thank you so much again for replying.


8 years ago

I think ill have to send you some photos !


8 years ago

Yes i do have an Arduino i connected it and i run a code i found and i changed the values. My problem now is that its very fussy the screen shuts when i have it connected sometimes it
do anything when i shake no reaction in the monitor , some other times it doesn't stop running values on the monitor, some times it works fine only when i shake and when i stop it stops as it should , also sometimes it delays to show value on the monitor but the pedometers screen displays the steps normally. Thank you for your ideas and your interest in my project! If you have any comments to my findings please tell me! You might know why my pedom is so weird!!


Reply 8 years ago

It sounds like you've gotten pretty far in your project. Congratulations!

Okay, this sounds like a hardware problem. This type of problem is usually caused by an intermittent connection. This could be a cable like the USB cable connecting your computer to the Arduino. Try a different one if you have one.
More likely: if you have a shield on your Arduino and you added circuitry to connect it to your pedometer. Look carefully for intermittent connections, bad solder joints and wires touching where they shouldn't be.
It's hard to troubleshoot long distance. One of your best tools is your eyes. Carefully inspect everything. Look for cold solder joints(grey instead of shiny), wires touching where they shouldn't be, discolored or burnt parts.
Good luck. If you still can't get it going maybe pictures would help.



8 years ago

Well basically im doing an experiment and writing my thesis on how people hate numbers and what can i do to replace numbers with anything else. How i can give the feedback in non numeric values. So the pedometer tells me km kcal and steps and i need to "translate" that in LEDs ,vibrations, audio or anything else that exists to make it FANTASTIC !


Reply 8 years ago on Introduction

Sorry, I wrote a response but I guess I forgot to post it. One idea I had was to use an LED bar graph. The more steps the more bars light up. Here's a good tutorial:
You would just have to change the potentiometer to number of counts.

I'm not very musical, but another idea was to change tones, more steps high frequency. Here's a starting point:

Also, I was thinking you could do something with step rate. Easy would be to flash an LED or beeper for each step. Harder would be to increase the LED brightness with faster step rate (or increase frequency of speaker).

What do you think?



8 years ago

My main issue is that i dont understand much of the softwares i have help for that, but not much ,so if you have in mind something simple but impressive you would help me a lot !


Reply 8 years ago on Introduction

Do you have an Arduino and have you played around with it? I think it's pretty hard to learn programming with no experience but maybe my Instructable is a starting point:
or Arduino and AdaFruit both have good ones that I mentioned.

So basically, your design will only have one input from the pedometer. This Arduino page should help with that:

Now your output could be digital, like an LED or buzzer. This should help:

Now if your output is analog, like generating tones or varying intensity of an LED, this should help:

Let me know if I can help further.



8 years ago

No what i mean is i know how you did everything . Its crystal clear its just im doing something a bit different and im wondering where you got the code from cause i cant find it in the arduino lib . Did you write it yourself? Thanks for answering by the way !


Reply 8 years ago on Introduction

Yes, I wrote the code myself but much of it was based on libraries from the AdaFruit datalogger.
AdaFruit (and Sparkfun) have really good documentation on their products and usually have supporting Arduino libraries.
But to do anything useful, you do have to write your own code that is specific to what you have connected and what you are trying to do.
If you're not familiar with Arduino Sketches, I just wrote a beginners guide to Arduino software:

Let me know what you're trying to do with what kind of sensors and I'll try to help you out.



8 years ago on Introduction

I'm not quite sure what you are looking for but I'll try to give you some general information.
The program basically takes the date, time, temperature, relative humidity and steps and writes it to the SD card.

It is written using the Arduino environment:
The code (usually called sketches by Arduinoites) is written in a language using the following rules:
This is basically a programming language called C++

How it works: The code is written on a computer. The computer is connected to an Arduino (or clone) The Arduino program takes the code and compiles it (this converts the C++ code into language that the Arduino microcontroller can understand and sends it to the Arduino. Then the Arduino can run the program.

I hope this helps. If you need more specific information, let me know.



8 years ago

Hi , my name is Angela and im studying creative technology in the uk. I could really use your help! Could you please tell me more about the code you used? My dissertation thesis has something very similar and id really appreciate it if you helped me.