top of page

Gym Bud - Internet of Voice Competition


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.

*** Note: The complete tutorial on how to recreate this project can be found in the setup sections of our competition submission. ***

 

Our Submission

For our submission to the IoV Alexa Competition 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.

 

How Its Made!

As you can imagine, all of this work was not done within a few hours. It took weeks of learning and understanding concepts and APIs that we never encountered before. The project was done in many stages and most of the tasks were done in parallel. Everything was first created first using test values that way it was easier to piece it all together and have building blocks once we got Alexa sending information to the Raspberry Pi. For example, We first had Node-Red working with the Fitbit API, where a test input would activate the Fitbit python script to calculate your cardio distance. Then when Alexa was working with the RPi we started using voice commands as inputs. In this blog I will only describe what steps we had to take to make our project come alive and why. The complete tutorial on how to recreate this project can be found in the setup sections of our competition submission. For us to complete the project we had to do the following:

1. Setup a secure apache server on the Raspberry Pi - Alexa voice commands can only be submitted to https endpoints.

2. Setup the Alexa Skill Kit - This is where you define how your commands will look.

3. Setup Alexa Voice Services - This how we got Alexa working with Xamarin on our phone.

4. Install and Setup Node-Red - In order to get the drag and drop power of Node-Red we needed to install it onto the RPi

5. Setup Alexa with Node-Red - This is the flows we used to retrieve the Alexa commands and find the useful information needed to activate the desired skill. Now that we had Node-Red working with Alexa, we wanted to add Alexa skills and their corresponding flows! In other words, we finally got to the fun part of the project :P

6. Setup MySQL - needed for the databasing part of the workout skills. Used to hold the database of workouts and for logging weight lifting and cardio obtained from Fitbit.

7. Fitbit API - required to obtain user information from my Fitbit Flex. We used the Python API to interface with the Fitbit and it worked very well.

8. pygame.mixer.music - required to play music off the RPi. Tried to use Mopidy but there was a steep learning curve and we were getting errors that seemed to be common to RPi Mopidy users. The reason we wanted to use Mopidy is because you can connect it to Spotify and SoundCloud. Due to the time frame of the project we opt-ed out of using Mopidy and switched to pygame.mixer.music. In future, we would like the ability to use Mopidy as it does have Node-Red nodes.

9. OpenWeatherMap API - to get the weather in our region we used the OpenWeatherMap API that had a Node-Red node. It was very quick and easy procedure to get your access code and then use it in the flow.

 

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.

RECENT POST
bottom of page