I have had success getting my daily step count from my FitBit to display on my motorized slide potentiometer, (circuit below) but then I ran into a problem: My FitBit was out of battery, and showed only “0” steps for the day. (I lost my charger– ugh! everything should be USB compatible without a stupid dongle charger!)
Anyway, I realized that I needed another way to control my device for testing purposes and to demonstrate its function, so I don’t have to do jumping jacks throughout my thesis presentation to show it change.
I decided to create another webpage that could communicate with the slider as if it were the FitBit. I could run the server that looks for FitBit on my laptop, or I could run this new one for testing purposes and not need to change the code on my Arduino.
On this page, moving the slider would set the same value as the FitBit (“steps”).
The trouble I had, and have been having, is understanding the difference between data types when sending data between code languages, across the internet, or from API’s. This is a really hard thing for me to grasp. In this case, I mashed up the “Express Basics” and “JS Client Thermostat” examples from Tom Igoe’s network examples. I discovered that after receiving the value of the slider (example “14” above) on the YUN, it was in Ascii.
So, I would need to convert the value to a string on the server:
(My first try is still commented out)
And then convert it back into a number on the Arduino side:
Ok, so this seems to be working! OMG so happy! Thanks to Tom for helping me understand what needed to be done.