Introduction: Indoors Workout Stepper With Raspberry Pi & Arduino Iot

About: Raspberry Pi & Arduino explorer

Hello everybody.
The purpose of this project is to use an indoors workout stepper with the Raspbery Pi and Arduino. This kind of stepper usually have small display and you have to watch down during your workout to see your steps.In this tutorial we will use Raspberry Pi and Arduino for:

1.Send the steps of our workout to the browser of our screen instead of the small display.

2.During our workout watch a video in youtube.

3.Stream the steps of our workout to an online visualization tool like Plotly.

Lets start with the components that we will use.

Step 1: List of Hardware Components.

These are the components that we will use:

1.Indoor workout stepper.

2.Raspberry Pi. (I have a Raspberry Pi model B).

3.Arduino (I have an Arduino Leonardo).

4.Power for the Raspberry Pi and a usb micro-cable to connect the Arduino to the Raspberry PI.

5.Some jumper cables male to male.

6.Wifi dongle (This is optional if you connect your Raspberry Pi with an ethernet cable, I use wifi to connect to my home network).

7.A breadboard and a common resistor.

Step 2: List of Software.

The software that we will need:

1.The latest Raspbian image for the Raspberry Pi (I use Raspbian Wheezy fully updated, i don’t know if this project works with Raspbian Jessie.) https://www.raspberrypi.org/downloads/raspbian/

2.Pyserial. If your image is fully updated you don’t have to install it, if you have to here is how.

https://learn.adafruit.com/arduino-lesson-17-email...

3.Arduino IDE. (I strongly recommend to install version 1.6.0. to your system. i am using 1.6.0.)

4.Bootle.py http://bottlepy.org/docs/dev/index.html

5.Arduino Serial to Browser https://github.com/whichlight/Arduino-Serial-to-B...

6.Plottly (Plotly is an online analytics and data visualization tool.) https://plot.ly/

7.Atlas-scientific file from here https://github.com/plotly/atlas-scientific

7.Connection to the internet.

Step 3: Connect the Stepper With the Arduino.

We start by pulling away the old display of the stepper.

We can see that the stepper will act as a simple on/off switch.We connect 2 jumper cables to the stepper and now we are ready to connect them to the Arduino.

We will use the breadboard, the resistor and some jumper cables.

At the one end of the resistor we will connect the one cable of the stepper. At the same end of the resistor, we will connect a jumper cable, witch we will lead it to Arduino digital pin number 2.

Next at the other end of the resistor we will connect a jumper cable that will go to the GND pin of the Arduino.

Finally the second jumper cable of the stepper will go to the 5V pin of the Arduino.

Step 4: Connect the Arduino to the Raspberry Pi, First Test.

This is an easy step.

Take the mini usb micro-cable and connect the Arduino to one of the usb ports of your Raspberry Pi. That means that the Arduino will power-on through the Raspberry Pi.

In this point we have already installed all our software from step 3 and we are ready for the first test to see if our code is working.

The Arduino code is a simple button on/off. We make one step the button is on, another step the button is off. With these simple code we can count our steps.

Open the Arduino IDE and upload the code to your Arduino, open the Serial monitor from the IDE, start making steps to the stepper and see if it counts to the serial monitor.

Now that our code is working we are going to the next step.

Step 5: Arduino Serial to Browser and Embed Video.

In this step we will change the html code so we can watch youtube videos to our browser and we will transfer the steps that we do to our stepper, from the serial monitor of the Arduino IDE to the browser.

First go to the Arduino-Serial-to-Browser folder of your Raspberry Pi and open the index.html file with a text editor. Copy and paste the code from the attachment at the start of your file.Save and close.

Second load the Arduino code from the previous step to your Arduino. Open a terminal, go to your Arduino-Serial-to-Browser folder and type the following command sudo python browser_vis_serial.py.

Third open the browser and type http://127.0.0.1:8080 and start making steps to your stepper. If everything goes well you will be able to see your steps in front of you and also stream the video of your choice.

*In my demo video i didnt stream the youtube video because i used the wifi of the Raspberry Pi to control it through vnc and connect to the internet, so it was already stretch to his limits.I recommend to use a Raspberry Pi model 2 with the 1 gig memory for extra power.

Step 6: Stream Your Workout to the Internet.

First you need to create an account to https://plot.ly/

This is very simple, you just need an email, a username and a password. Create the account, verify it with your email and we are ready.

Login to https://plot.ly/ go to the Settings of your account. To the API Settings, down below generate your token and keep 3 things.

1.Username

2.API Key

3.Streaming API token

Second we will use only a file from here https://github.com/plotly/atlas-scientific go and download the atlas-pi.py. Open it with a text editor and set your Username, API Key and Streaming API token at the fields. token = 'stream_token' username = 'plotly_username_here' api_key = 'plotly_api_key_here' , at the same file find usbport = '/dev/ttyAMA0' and change it with your own serial port. Mine is /dev/ttyACM0. Save, close and ready for the stream.

Third load the arduino code to your arduino. Open a terminal, go to the folder with the atlas-pi.py and type sudo python atlas-pi.py and start your steps. If everything goes well the browser will open (or you can open it) and you will be able to see and stream your steps. You can find the stream address to the terminal.