Raspberry Pi with Stepper Motor

Raspberry Pi2 with MOTORplate and Steppermoter



  1. Hardware needed
  2. Setup Raspberry Pi2 with raspbian using Noobs
  3. Steppermotor with MOTORplate hookup
  4. Enable GPIO on Raspberry
  5. Software

1. Hardware needed

There are several pieces of hardware (HW) needed to test this

  • HDMI Monitor (not needed if you install a VNC server)
  • Raspberry Pi-2 or Pi-3 or Pi-3+, I bought it from Pi-Shop (about CHF 40)
  • Raspberry Pi heatsink, I think a must (Pi-shop about CHF 4)
  • 16GB, 32GB or 64GB Memory card (SD card), ex. SAMSUNG EVO Plus 64GB from Microspot (about 30)
  • Power-supply raspberrry Pi, 5.1V, 2.5A (Pi-shop, about 20)
  • Steppermotor, Nema 17 Bipolar 1.8deg, 26Ncm (36.8oz.in), 0.4A 12V, 42x42x34mm, 4 Wires (about 7)
  • MOTORplate, (Pi-shop, about 50)
  • USB mouse (not needed with VNC)
  • USB keyboard (not needed with VNC)
  • HDMI cable (not needed with VNC)
  • Network cable or Wifi

2. Setup Raspberry Pi-2 with OS using NOOBS

  • Download the latest Version Raspberrypi.org, I like the Lite Version because the download is fast and the setup of the SD card as well. During install the raspberry needs to be hooked up to the internet though.
  • Get the SD card ready. Be careful, when your card it >32GB and you want to boot from it, you need to format the SD card with a special tool with a Fat32 filesystem. I used Guiformat
  • Now insert the SD card and boot NOOBS and and install raspbian. If you are using NOOBS-lite and this is the first time your Raspberry Pi and SD card have been used, then you’ll have to select an operating system and let it install. Click on below image to see the install


3. Steppermotor with MOTORplate hookup

Well I cut the connector of from the motor and soldered the ends.

I used the User-Guide from Pi-Plates to determine the steppermotor hookup and the reference card that came with the motor. In addition you need to select an address for each Pi-module so that you can use the software to talk to it. So each Module should have these jumpers to set. Based on the User-Guide I selected address = 6.

4. Enable GPIO on raspberry

By default the raspbian OS has the GPIO interface disabled. I noticed that when I got a run failure on the software.  So use the terminal window and edit config.txt or use the GUI

#sudo nano /boot/config.txt
then uncomment the following line and save your changes and reboot

or use the GUI:
Menu > Preferences > Raspberry Pi Configuration > Interfaces and make sure SPI is set to Enabled.

5. Software

First things first, we update to all the latest OS patches via terminal window

5.1 OS

  1. #sudo apt update
  2. #sudo apt upgrade
  3. #sudo rpi-update
  4. #reboot

5.2 Development Editor

Now we choose our Dev environment, I like Geany
#sudo apt install geany

5.3 Python

Since raspbian is linux and development is usually done in Python I want to go forward with the newer Version of Python 3, the current Version is 3.5. With raspbian it is already installed, what we need though are some libraries from pi-plates.

5.3.1 Pi-Plates

pi@raspberrypi:~/Downloads $ sudo pip3 install Pi-Plates
Collecting Pi-Plates
Downloading https://www.piwheels.org/simple/pi-plates/pi_plates-4.1-py3-none-any.whl
Installing collected packages: Pi-Plates
Successfully installed Pi-Plates-4.1
pi@raspberrypi:~/Downloads $

to update to a newer Version of Pi-Plates:
#sudo pip3 uninstall Pi-Plates
#sudo pip3 install Pi-Plates

In case pip3 is not yet installed:
#sudo apt install python3-pip

Where are the files being installed to?

5.3.2 GPIO

pi@raspberrypi:~/Downloads $ sudo pip3 install RPi.GPIO
Requirement already satisfied: RPi.GPIO in /usr/lib/python3/dist-packages  (already installed)

5.4 MOTORdemo Software from Pi-Plates

Download Demo:

pi@raspberrypi:~/Downloads $ wget https://pi-plates.com/downloads/MOTORdemo.tar.gz
–2018-10-19 09:35:42– https://pi-plates.com/downloads/MOTORdemo.tar.gz
Resolving pi-plates.com (pi-plates.com)…
Connecting to pi-plates.com (pi-plates.com)||:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 11480 (11K) [application/x-gzip]
Saving to: ‘MOTORdemo.tar.gz’

MOTORdemo.tar.gz 100%[============================>] 11.21K –.-KB/s in 0s

2018-10-19 09:35:49 (27.1 MB/s) – ‘MOTORdemo.tar.gz’ saved [11480/11480]

Unzip Demo:

pi@raspberrypi:~/Downloads $ sudo tar -xzvf MOTORdemo.tar.gz

5.5 Create Geany Project

Now we make a few modifications:

  • We need to change the terminal for Geany, Menu – Edit – Preferences
    to verify that xterm is installed, use
    #sudo apt install xterm
  • Now the Build Command change for Python3
    Menu – Build – Set Build Commands
    Notice the python3 in the Compile line and IN the Execute line

5.5.1 Code Modifications

I ran into some minor problems and will tell you the fixes.
in MOTORdemoOOP.py change to the following 2 lines

from Tkinter import *
import tkFont

from tkinter import *
from tkinter import font
#init globals
addr = 6

then search and replace all of the following:
“tkFont.Font” to “font.Font”
“(0,” to “(addr,”


  • tkinter is now lowercase
  • I used font because tkFont is already within tkinter
  • In addition the demo code was hardcoded to Address = 0 and I changed my Pi-Plates MOTORplate to Address ID = 6, so whereever there was a call to a function
    “MOTOR.stepperCONFIG(0, ” it now reads “MOTOR.stepperCONFIG(addr,”

5.6 Run the code

press F5 and the code should run

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published.