Sunday, May 2, 2010

bluetooth wireless bathroom scale with fatsecret integration



Not exactly a keyboard, but I'd argue that a datalogging scale is an imput device... In any case, this is a project I did a while ago (~2 years ago). Start with a cheap bathroom scale from ikea, then strip out all the hardware except for the load cells. Add in the following:

microcontroller (AT90USB162)
roving networks bluetooth serial module


24 bit ADC (AD7799)


4 AA batteries +linear regulator (don't want switching noise here)+ input ORing diodes to allow powering from batteries or USB without damaging either (handy during development)

After assembling the above hardware, the microcontroller code was fairly straightforward- when a user taps a corner of the scale I take repeated ADC readings until the "running STD" (STD of last N measurements) drops below a certain threshold. At this point the scale will have a stable zero point to normalize the subsequent weighing. When the user stands on the scale I do the same thing- take ADC readings till STD< threshold. I chose the threshold such that the delay before convergence was short, at the expense of some accuracy. Left to run long enough the scale was able to detect the difference between my bodyweight and my bodyweight plus one US quarter. With the current threshold the scale appears to be repeatably accurate to within 0.1 lbs which for my purposes is acceptable. I was actually pretty happy to get that level of performance considering I didn't lay out a board for the ADC and just used a schmartboard instead.

One other metric I was happy about is the battery life - approximately > 9 months when used once or twice a day. I coded things such that the microcontroller is in a deep sleep until the user touches a corner of the scale. I could have taken a hardware approach and actually disconnected the uC power with a transistor until the user touched the scale, thus arming a delay circuit, but the software approach yielded more than acceptable results. The uC current draw is in the microamp range when sleeping and I use transistors to disconnect power from the bluetooth module and ADC while sleeping so I probably shouldn't have been surprised.
I think for a future revision of this project I'll actually spin my own main board. This would allow for a much more compact footprint and allow me to power from a smaller 3.3V source instead of the stack of 4 AAs. This latter arrangement was needed to avoid extensive rework of the olimex board where certain bits of hardware expect 5V.

On the PC side of this project I'm using bluez rfcomm server to listen for inbound serial connections and then run some other code when a connection is established. That other code consists of python scripts that insert the current reading in a sqlite database (which is then visible from my ruby-on-rails site) and submits the reading to fatsecret via its API. This data submission is done using OAuth, so the whole process requires no human intervention and I avoid any ugly hacks involving plaintext saved passwords.

Fatsecret is great because:
(1) it has an API
(2) it has an android version
(3) it can scan barcodes to fetch associated calories and nutritional content
Here's a screenshot from my phone showing a graph of weight readings for the last few months.


One final aspect of the scale which I find interesting is the means by which the user interacts with it. I intentionally made it so that scale does not have an LCD to show the current weight reading. Day to day fluctuations are not reflective of what really matters- long term trends. Usage of the scale thus boils down to the following:
(1) User taps lower corner of scale to initiate auto-zero sequence
(2) The scale turns on its sole LED to indicate that the zero process is ongoing
(3) The scale switches its status LED from solid red to blinking to indicate the zero process is complete.
(4) User stands on scale until LED turns off, indicating the reading has stabilized.
(5) User reviews cumulative weighing data at some later time (either via phone, or at their PC)

For fun, I added an additional means of relaying data to the user- spoken weights. By feeding the stabilized weight reading to festival (text to speech engine), the scale can "announce" the most recent weighing.

13 comments:

  1. That Looks Awesome

    ReplyDelete
  2. This looks very convenient, would you be willing to share some of the code files?

    ReplyDelete
  3. Wow!

    This is by far the best approach that I have seen.

    Have you considered a consumer-ready version? This could be a very hot item.

    ReplyDelete
  4. Hello!

    Could you please share more details about the wiring/circuit of the ADC <-> load cells?

    I also did the same as you but I went to get the data from the LCD pins of the scale. I shared the firmware and Android software here: http://code.google.com/p/casainho-projects/wiki/SdCardBathroomScale

    Thank you.

    ReplyDelete
  5. Hi to all, the blog has really the dreadful information I really enjoyed a lot.
    Compression Load Cell | Shear Beam Load Cell

    ReplyDelete
  6. Start with a cheap bathroom scale from ikea, then strip out all the hardware except for the load cells. Add in the following:speech recognition software

    ReplyDelete
  7. If you find that your Bluetooth devices are not working properly, the device drivers probably need to be updated.check out wolffofcanada.com

    ReplyDelete
  8. What is the impact of termites on human health Best anti-termite company in Dammam?

    A company that fights white termites causes many diseases to humans includingشركة مكافحة حشرات بحائل
    شركة رش مبيدات بحائل
    شركة الانوار لمكافحة الحشرات
    شركة رش مبيدات بسكاكا

    ReplyDelete
  9. minuman penyegar seperti bentrap original cod di tambun utara sekarang ini banyak digemari oleh pria untuk memelihara stamina agar tetap perkasa saat berhubungan badan. produk bentrap asli cod karawang ini banyak diminati karena sudah memiliki sertifikat halal yang keabsahan bisa anda yakini 100% dapat memberi manfaat bagi pria yang ingin mendapatkan klimaks saat berhubungan badan. bentrap asli cod bandung dikemas dalam bentuk serbuk dengan aturan pakai seperti minuman yang mudah dikonsumsi bagi siapapun tanpa pengecualian sekalipun bagi pria yang menderita penyakit seperti diabetes. viagra asli dapat diterima oleh semua kalangan dan hasilnya juga sangat memuaskan bagi setiap pasangan yang ingin menjaga keromantisan dalam bercinta agar selalu optimal setiap libido memuncak. wanita bisa merasakan kebosanan kalau pasangannya tidak dapat memberikan kepuasan seksual saat diranjang, untuk itu anda sebagai pria harus mencari solusi dengan cara mengonsumsi permen soloco cod di tembalang sebagai obat untuk meningkatkan libdo serta membuat ereksi lebih keras dan tahan lama. klik seterusnya .

    ReplyDelete