Gym Bud with Fitbit + Alexa and RPi Development Platform

Introduction

This challenge was created to demonstrate the power of Amazon Alexa and Raspberry Pi for IoT purposes. IoT stands for Internet of Things and is currently taking the world by storm. Seamless intergeneration of devices and gadgets has become very important to consumers and the industry has been forced to respond. Amazon has now joined the market with the invention of Alexa and its ability to have control of voice commands. When you ask Siri the temperature, she will give you a good response and shut off. However, when you ask Alexa the temperature, you have the authority to turn on air conditioning if the temperature is too hot, or heating when it is too cold.

alexa-picture

Our Submission

For our submission we wanted to mimic something like IBM Bluemix so we interfaced Amazon Alexa with the mighty workflow, drag and drop power of Node-Red. By transforming a Raspberry Pi 2B+ into a secure apache web server Amazon Alexa skills could be directed towards the Pi. Thus, leaving endless possibilities to any level of developer. We believe a very important aspect of IoT is the ability to customize, this becomes difficult with the vast amount of APIs and platforms needed to be explored in order to create integration of products. This takes hours of searching through documentation, learning new programming languages, and copying and pasting Stack Overflow code ;). By using Node-Red, we eliminate the need to learn a bunch of APIs as there are custom nodes already built for most devices and social medias.

Our project has the functionality to log weights during a workout, log cardio, and to play music on command. There is a MYSQL database setup on the pi that contains weeks of your current workout plan. When you ask Alexa for the workout of the day, she will give you the muscle group and the exercises you will be working on. Once you are at the gym/home working out, all you have to say is “log 25” and it will insert that weight into the database, and respond with telling you the next exercise you have to do. The point of this was to give a hands-free experience to gym users like ourselves who hate having to bring in a book and pen to the gym. Pages start getting torn out, the pen gets crushed by your max deadlift, and who wants to write anything down after you've done your third set of pull-ups to failure? No, you don't. Alexa knows where you are in your workout from the moment it begins, all you have to say is “log {weight}” and she will tell you what is coming next. The next thing our project does is log runs using the Fitbit API. My Fitbit Flex has UI on the device and I have to manually put in my cardio, because of this we have another database set up for logging runs. Just tell Alexa when you start your cardio and she will log your current steps, distance, and calories of the day. Once the run is over she will enter the new current steps, distance and calories to take the difference with the starting information. The result is a response from Alexa telling you how well your cardio went! It will also keep the logs in the database to track your progress. Last but not least, we have the ability to play music off the pi for home workouts. Tell Alexa you are starting a workout and she will play your workout playlist, tell Alexa to plat mood music and she will check the weather to plat a specific playlist based on the forecast.

Conclusion

Our main goal of this project was modularity and customization for IoT developers. Dynamically being able to add more and more functionality to any unique project. We used fitness as the basis of our project because this is what we are interested in, but with the system we set up you can do so much more. Using Node-Red and Raspberry Pi does not just aide our fitness applications, it helps any developer for any purpose. We hope that developers follow our tutorial and realize how easy it to swap out nodes and add functionality. If you are open-minded, you won't just see voice controlled workflows that allow you to log workouts, turn on playlists, and interface with Google, Fitbit, or Twitter. You will see the potential to replace nodes to log recipes, turn on sprinklers, and even control drones with the power of Amazon Alexa and Raspberry Pi.

Setting Up Everything!

There was a lot of setup in this project, we will go through each process individually to reduce confusion and maintain repeatability of making this system from scratch again. So hold on to your hats! This is gonna be a learning experience for everyone.

Setting up Secure Apache Server on Raspberry Pi

  • First write the Raspbian Jessie image onto a SD card and put it into the Raspberry Pi
  • Keep a copy of the original files you manipulate for this step (such as the files in the etc/apache folder) because if something goes wrong it is much easier to replace the files then to redo step 1.
  • Make sure to also set up port forwarding on port 443 as this is the secure http port that is needed to work with Amazon Alexa
  • If you use DNS Dynamic for your free hostname (like in the tutorial) make sure you go to navigation bar ->Webclient and then click Start, in order to properly activate your domain. If you do not do this it will not properly connect with other online devices.
  • We bought our SSL certificate from NameCheap.com for $11/year , but you can make your own for free using openssl.
  • When you buy your SSL Certificate, NameCheap will give you very clear instructions on how to setup your SSL Certificate on your computer. It is a very quick and painless process. You can see my final configuration file at the end of this section.
  • When you setup all the SSL components you may realize that it is not activated yet. To update the apache server with the SSL certificate you must go into the raspberry pi terminal and type the command sudo a2enmod ssl, followed by typing the command sudo service apache2 restart
  • Bam! You should now have secure apache web server running on your pi that can be accessed by the world wide web! 😀 The last step is to go into the file where you put the SSL certificate information (my path is /etc/apache2/sites-enabled/000-default.conf ) and change the DocumentRoot variable to /var/www/php, as shown below.

 

Read More:  Gym Bud with Fitbit + Alexa and RPi Development Platform


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top