loading

UPDATE: CHECK OUT MY OTHER TWO PROJECTS >>

SweeperBot - Roomba-like Robot With Bluetooth

Alarm Clock with Infrared and Bluetooth Speakers

Hi folks! Last few days I've been obsessed with the idea to make my own watch from arduino parts, but something cool I could use and say I did it myself. So I found out there was a sensor board (commonly named GY-87) which had three sensors on it: HMC5883L (compass), BMP085 (pressure, altitude, temperature) and MPU6050 (accelerometer and gyroscope). With it, via I2C, I could add an Arduino Pro Mini, and an I2C Oled Display and make a watch capable of having all this information, plus a pedometer (by analysing accelerometer data).

Cool enough, it was incredibly easy to make, and you will just need some cheap parts, a small amount of Eagle PCB knowledge, some skill on making your own PCB board, and preferably a cheap watch to unmount and get the bracelet / carcass.

Before start, I'll just post some pictures of previous versions I made so you can have an idea of the challenges you'll face, and stuff you can add if you like. Let's get going!

Observation: forgive me if my english is not good enough, this is not my native language, for I am brazilian. XD

Step 1: Previous Versions

There were two previous versions of the watch. The first one was an attempt to put compass and bluetooth together. It succeeded. The watch was small in size, but too thick. The first three images are it. It could communicate with my Windows Phone via bluetooth, get automatically the time and date, and also my next calendar appointments and display them. It was also sending many times per second the current compass position, and the phone would display it. Yeah, I had to make the WP app. I think I have it here, so I'll post it with the instructable. However there were some problems with the Project:

  1. The bluetooth consumes A LOT of energy, and the battery lasted just for an hour or so;
  2. There was no real advantage in using the bluetooth, because the date and time you could put also using the buttons, and if the battery could last a day long, you would charge before running out, so you wouldnt have to put date and time again;
  3. The calendar thing was great, but was kind of useless, because you could always check it on the phone, and as the watch had limited memory space, you couldnt download all the calendar;
  4. Plus, each alteration of calendar would require to sincronize again;
  5. Sending the compass back to the phone and spinning a compass on the display was great too, but of course useless, because the watch already did that;
  6. The watch had resistors on each button, something I found out later that was useless, because arduino already has pull up resistors on each digital input pin, you just have to turn it on;

So I tried to make another with the bluetooth, but one that you could turn it on with a switch. It turned out that switching it on and off resets the arduino . I figured out that I didnt need the bluetooth, so I made a second version, with an MPU9150 (compass, accelerometer and gyro). The second version is on the next 13 images. It was a pretty better unit, also with two buttons (I still used resistors on them), larger in size, and less thicker than the original. The battery was smaller, and I managed to make a carcass to wear it. It got kind of steampunk look, but wasnt something I would wear on the street (lol). The battery lasted 14 hours! Amazing! Problems as follow:

  1. I could have desoldered the two leds that there are on the boards: one on the arduino and one on the MPU9150 to spare energy;
  2. There was no need to use resistors;
  3. There was no need to have two buttons, because I could implement via software two functions to the same button;
  4. It was too thick;
  5. The carcass wasnt great, and was too big;
  6. The charging was made via a two pin conector on the side, and if just one time you got confused and put the conector inverted could burn the system - it had to be fool proof;
  7. I glued everything with silicone glue, however I found out silicon glue oxidate the copper and the tin, conducting current, so it was a problem;

The third version was the first to be one I could use on street and is pictured on this instructable: it is on the last four images. The battery lasts 24 hours easily, and I took out one led from the GY-87 sensors board. I left one led because I forgot to take out, but ended cooler this way. However there are some stuff I can improve on future versions:

  1. I drilled the hole for the button and for the charging conector too distant one from the other;
  2. I could have placed the parts better, sparing space;
  3. I could have designed the pcb on Eagle way better, voiding short circuits;
  4. I could have programmed better the pedometer;

Next step we assemble the componentes!

UPDATE: the battery lasted 26 hours on regular use.

Step 2: The Parts:

  1. 10DOF sensor (HMC5883L, MPU6050 and BMP180) Ebay (1);
  2. Arduino Pro Mini 3.3V (or compatible) Ebay (2);
  3. Cellphone battery (3.7 - 4V);
  4. I2C Oled Display (blue color) Ebay (3);
  5. Copper pcb board Ebay (4);
  6. Ferric chloride Ebay (5);
  7. DC Female Power connector 2.5mmx0.7mm Ebay (6);
  8. Tactile switch (side button) Ebay (7);
  9. An old or cheap watch you can unmount (preferably big enough);
  10. Solder wire, soldering iron, solder sucker, etc;
  11. After, of course, you will need the battery charger, wich wont be inside the watch, Ebay (8);

Step 3: Connecting the Parts and Eagle Board:

I included the zip file to my Eagle design, but I advise you that it has mistakes, because I was learning how to use the software at the time. I intend to make a better version on my next try. However, it is really easy to understand how the parts should be connected. It goes as follow:

1- Arduino:

  • PIN 2 - Button output;
  • VCC - on VCC from the charging connector, VCC of display and sensor;
  • GND - GND from charging, button input, and sensors / display GND;
  • A5 PIN - on I2C SCL pin from display and sensor;
  • A4 PIN - on I2C SDA pin from display and sensor;

2 - Button:

  • One pin on GND;
  • Other pin on Digital input pin 2 from arduino;

3 - Display:

  • VCC pin;
  • GND pin;
  • SCL pin on arduino A5;
  • SDA pin on arduino A4;

4 - GY-87 (sensor board):

  • VCC pin on VCC from arduino;
  • GND pin;
  • SCL pin on arduino A5;
  • SDA pin on arduino A4;
  • Other pins are not connected! Including the 3.3V VCC, wich wont be used!

You can now opt to take out both leds, one from the arduino (near the reset button), and the one on the sensors board. Both are useless and consume around 1.5mA each constantly, which we cant afford. Now you have to make your own pcb board with the copper board and ferric chloride. I wont get to details here because there are plenty instructables on this, like this one. In my project I also used a laser printer for better results.

Step 4: The Code:

As written before, I made three versions of the watch. However, the second and third versions are very similar one to the other, so I uploaded here the first and the last versions. The first because had the support to the bluetooth syncronization with the windows phone, having calendar. I also uploaded the code for the windows phone app, with the compass. Hope everything is still working. The libraries I used:

  • Wire.h;
  • I2Cdev.h (included to download);
  • MPU6050.h included in I2Cdev;
  • Ug8lib.h (included to download);
  • Time.h (included to download);
  • HMC5883L.h (included to download);
  • Adafruit BMP085.h (also included);

The older version of the watch also used the library:

Step 5: The Pedometer:

Usually, pedometers are made by calculating the pulse on accelerometers on the Z axis, because the sensor is placed on a belt near the chest of the person. This time, how the watch was on the wrist, it wouldnt make sense reading just the Z value, because the wrist moves in many ways. However, the arm goes forward and backwards when walking or running. So initially I figured out that the sum of the values S = |X|+|Y|+|Z| would increase and decrease on each step. By calculating the moving average of the last N values for S (Av = SUM(S)n/N) and comparing them with the current moment of S I could say: if Sn-1<= Av and Sn>Av then add one step to counter (image 1).

Of course, if you bounce or move your arm, the counter would add a step (false reading). So I added a minimum limit for Av, such as on the image, it could be 22000. Below this would mean you are moving your arm, but not walking. Higher values for Av, such as 30000 mean you are running (easily seen on the image).

After some tests, I discovered that moving the arm had a sum of accelerations really close to walking, so I had to find a way to identify one from the other. I did that by:

  • S = |X|+|Y|+|Z| for a given moment;
  • SM = the maximum value for S over the last N moments;
  • AVM = the moving average of SM for M given iteractions;
  • AVM <= 37000 =>doing nothing useful;
  • AVM > 37000 ans <50000 =>walking;
  • AVM >= 50000 =>running;

The excel file with all my tests is included.

Step 6: Conclusion

I hope you guys like it! I pretend to make a better (and final) version of this watch in the near future, improving the pcb, the code, the part calculating the steps to differentiate walking and running from driving a car(this one is hard). And I am open to ideas, so if you think of something cool, please tell me! I could make a better version buying the components and making the board be smd, and solder them individually, but right now I feel it would be really hard and for now I am lazy enough (lol). That stays for a distant future from now. See you in my next instructable. Dont forget to check my other ones!!

Ben Hur Gonçalves.

<p>Hi,</p><p>I am looking to make something that requires a pedometer function like the one in your code but i don't need all of the extra. Can you specify where the pedometer code begins/ends because I am a little lost trying to get it right.</p><p>Thank you</p>
<p>how much is the clock with all the parts?</p>
<p>hello,</p><p>i wanted to know if the 10DOF sensor measure the temperature, cause i don&acute;t see this spec on the description of ebay.</p><p>thank you</p>
<p>Thanks for the link though had i searched properly I would of seen you <br>had already posted one on the list of parts used, so I apologise about that. I had another <br>question, how are you logging or outputting the data for the pedometer, <br>you have it charted and on an excel, I was curious how you were <br>outputting that from the mini. Im planning to make one with a nano v3 <br>and use it as a wearable device in clothing so will need to test the <br>pedometer to match where it will be worn.</p>
<p>And also i saw that there was a problem with the PCB. Do you know where I can upload it online and order it?</p>
<p>Sorry man, but I dont pan to make updates to the project.</p>
I am getting a fuzzy display at the OLED. Uploaded the same code and also verified the connections. Is it regarding the refresh rate?
<p>No. Probably because your display is different from mine. Each display has a different configuration. Uploading the same code will generally never work, because probably the parts are slightly different one from the other. Test the code part by part.</p>
<p>is it possible to send the pedometer data to a device such as mobile</p>
<p>Yes, but you have to solder a bluetooth board to it. Perfectly possible, but will drain the battery even faster.</p>
<p>Where did you find this sensor im having a few problems finding one with all the features you mentioned</p>
<p>Look for GY-87, or HMC5883L, BMP085 and MPU6050 on Ebay and Aliexpress.</p><p>https://www.aliexpress.com/</p>
Hi, <br>Thx for your post, it's a great project. <br>I'm beginning in arduino coding, i managed to get the data from the accelero but i'm struggling with the detection of a peak, to count the step..is there any chance i see your code ? <br>Thank you so much
<p>Good job. I like it.</p>
<p>please guide me from the first step.</p>
<p>hey man......i desperate to make it any how....guide me for where i will start that thing and from where i start to work on it</p>
<p>Hi Very Nice ! good job !!</p><p>But... i have a problem with the code :</p><p>RelogioRedondo.ino: In function 'void setup()':</p><p>RelogioRedondo.ino:122:11: error: 'class HMC5883L' has no member named 'SetScale'</p><p>RelogioRedondo.ino:123:19: error: 'class HMC5883L' has no member named 'SetMeasurementMode'</p><p>RelogioRedondo.ino:123:38: error: 'Measurement_Continuous' was not declared in this scope</p><p>RelogioRedondo.ino: In function 'void leitura()':</p><p>RelogioRedondo.ino:277:3: error: 'MagnetometerScaled' was not declared in this scope</p><p>RelogioRedondo.ino:277:22: error: expected ';' before 'scaled'</p><p>RelogioRedondo.ino:278:17: error: 'scaled' was not declared in this scope</p><p>Do you have a idea !!?? (Im a nerd.. and sorry with my bad english :( </p>
<p>Any idea how much battery the display consumes?</p><p>I'm thinking of making one with a bluetooth module and no display.</p>
<p>It consumes around 8mA... you can see my blog post about that http://bengoncalves.net/2015/10/01/oled-display-and-arduino-with-power-save-mode/</p>
<p>Then I think keeping the display would be better. I was thinking of using only the accelerometer sensor and a pulse sensor so that it can become a fitness tracker.</p>
Cool! I also wanna do a project about a watch based on Arduino. I image the watch could recognize body gesture instead of control by button. And now the question is how to recognize the gesture by the data received from the sensor?
Excuse me, can you please mail me the schematic for the watch please? It Because i really dont understand the way you tell how to install all of the electronic in word :).. im kind of person that can understand by picture and not by read ..sorry
<p>I put the schematic to download inside the file Eagle.zip that you can find above. Thanks.</p>
Hey man, its me again...just want to ask you how do i put 2 more button in the circuit ?since it look pretty dificult to use only one button .
<p>oh, my bad.. i didnt see the file haha... thanks </p>
<p>Saw your project through twitter.<br>Looks promising!</p>
<p>Wow, and thank you so much for sharing your process. Out of curiosity how long did it take you from start to finish? ... presuming you had all the parts on hand</p>
<p>It took two days. But I copied part of my code from my other previous projects.</p>
Hey man it me again,umm you know I buy the sensor board from the link that you suggest and the thing is the sensor didn't arrive at me yet, and it already over from the estimate days that they mention,I bought all item from the link that you give and all of them has already arrive except the sensor board and it really worry me out since the price for that item was really expensive for me and I have complain about that problem to the seller using email and I didn't get any reply . So I hope you can help me about that because I really getting pump up to build this watch :(
<p>Well if it helps you, I bought a lot of items from that seller and all of those arrived just fine. Perhaps its the way he posted it on the mail. Do you have tracking code? Here in Brazil these chinese items can take up to three months to arrive. But I trust the seller. Hope you item arrive soon.</p>
Well maybe you right...BTW I live in Malaysia so usually it only take two or three weeks to arrive, maybe I'm too impatient.
<p>You will face many problems during you Project. I'm making a blog to write about the next version of my watch http://bengoncalves.net/</p>
Yeah thats true. And I will surely checkout the blog that you create
<p>Excuse me . I want to ask a question . I do the step like you , but my OLED can't display the screen like yours . What may be the problem I had ?</p>
<p>This is my situation .</p>
<p>Are you using my code? or did you write one yourself?</p>
I am using your code
<p>I updated the code. See if it works.</p>
<p>It works , but there still are something wrong . I can't push the button to switch the mode. Will the button affect it ? I use the four leg button . </p>
<p>Otherwise , the second changes too late . </p>
<p>On this latest version I put the arduino to sleep, and all the sensors to sleep. It is easier to take this part of the code out because It messes with the button and with the timer. </p>
<p>Excuse me . Is the code &quot;wire.beginTransmission(0x68)&quot; different from 0x3D or 0x3C ?</p>
<p>0x68 is 104 in decimal and 3D is 61 and 3C is 60.</p>
<p>If I use different address , should I have to change other code like 0x6A of wire.write(0x6A) ? Or the only different problem to all ssd1306 is address? </p>
<p>Again, I cant understand what you are saying. What problem do you have with your circuit? Which sensor is not working? Each sensor has its own address. Mine are these. Only the 50 and 51, that I added extra right now.</p>
<p>Sorry about that . I'm not native speaker ,too . I'm a little poor at English . I means that the program only find 0x3C . Should I adjust the number code in wire.beginTransmisson and wire.write to 0x3C ? I using the scanner code here, http://playground.arduino.cc/Main/I2cScanner .</p>
<p>And there are something wrong happen again . </p>
<p>No, it's not the code. If i2cscanner dont find all your sensors, it means that they are no connected right. The problem is on the board. Check your connections. The 0x3c means the arduino is only finding the display, but no sensor. In the picture it seems your sensor is on, with VCC and GND right (led on), so I would guess you connected wrong SDA and SCL (you inverted them). Check that. Post results.</p>
Ok
<p>this is the all thing I got .</p>

About This Instructable

59,933views

637favorites

License:

More by benhur.goncalves:GSM Shield Home Alarm Arduino Chess Clock - Multi-game Box Arduino Pedometer Watch, With Temperature, Altitude and Compass! 
Add instructable to: