Because this is driving the stepper at a low level, the maximum speed is rather limited, to drive a stepper fast you need to use an autonomous stepper controller (such as a trinamic stepper driver), or use a driver such as an A4988 with DMA driven i/o to maintain precise timing.
The use of bluetooth means that only Raspberry pi's with bluetooth on board can be used - so It should work on Pi3, Pi4 and Pi Zero-W.
The hardware driver is a simple ULN2003 driver chip.
Short video here.
Find our more about the excellent bluedot here.
Setup / installation
Any version of raspbian can be used for this, for pi zero particularly, I recommend using Raspbian Lite. This setup was tested on raspbian Buster, on a Pi Zero W.This setup tested on a clean build of Raspbian Lite (Buster).
- After initial preparation of the sd card, and the usual updates.......
sudo apt install python3-pigpio git python3-pip
- and then
sudo pip3 install bluedot
- Now get the bluedot app on an android phone or setup a second raspberry pi to use as the controller. Follow the appropriate instructions from the bluedot documents.
- Pair the 2 devices - Note: if you use command line on the raspberry pi, you need
sudo bluetoothctl
- Finally get the app from github. I use a folder 'gitbits' and put the git software there, if you change this the start.sh script will need to be amended.
cd ~/
mkdir gitbits
cd gitbits
git clone https://github.com/pootle/bluepystepper.git
Testing
Start the pigpio daemon if it is not already running:sudo gpiodOn the Raspberry pi with the motor, in a command prompt (either via ssh or through a terminal window):
- or -
sudo gpiod -c 256 # -c 256 makes the daemon run at high priority
cd ~/gitbits/bluepystepperNow on the controller (android device or another Pi). Run the bluedot app and connect to the motorised Pi. Once the big blue dot appears, you can control the stepper by adjusting the speed.
python3 blueclock.py
- or- if on raspbian lite:
sudo python3 blueclock.py
The motor is set to stopped when blueclock.py starts, and each tap on the blue dot changes the speed:
- tapping on the centre of the dot sets speed to 0.
- tapping on the right of the dot sets speed to 1 if the motor is stopped, doubles the speed if the motor is going forward, and halves the speed if the motor is going backwards.
- tapping on the left of the dot sets the speed to -1 if the motor is stopped, doubles the speed if the motor is going backwards, and halves the speed if the motor is going forwards.
Setting up to auto-start on boot
There are 2 steps required:- arrange for pigpiod to start automatically on boot
- arrange for the python app to start automatically on boot
Starting the pigpio daemon on boot
I use crontab to arrange to start the pigpio daemon on boot.sudo crontab -eNote the first time you run crontab it prompts for an editor - use the number for your preferred editor, I use nano (option 2):
no crontab for pi - using an empty one
Select an editor. To change later, run 'select-editor'.and add the line (amend the location if whereis shows it is somewhere else):
1. /bin/ed
2. /bin/nano <---- easiest
3. /usr/bin/vim.tiny
@reboot /usr/bin/pigpiod -c 256The -c 256 parameter runs the daemon in realtime mode - that is it is given a high CPU priority.
Starting the app on boot
Again I use crontab, but this time as a user:
(Note: if running raspbian lite use 'sudo crontab -e' instead)
crontab -eand add this line:
@reboot sleep 7; /home/pi/gitbits/bluepystepper/start.sh