Raspberry Pi elevator program
Python Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This Python program, elevator.py, controls a model of an elevator with four floors using a Raspberry Pi.


I have been interested in the principals of controlling elevators for a long time, without studying the subject. A while ago I decided to just go forth and build me a model that I then could control with my Raspberry Pi. The result is here in this repository.

At this moment (January 1, 2017) It is working reliably.


RPi control


I constructed the code in two python programs. the original program I started out with is called elevator.py. It contains all of the main control code and the command interpreter. It used to ask for commands of the keyboard, but when it was doing that tha processing did not proceed properly.

So I rebuilt that part to accept it's commands from a sequential file. I then had to build a second program to insert commands into that sequential file. This second program is appropriately called elevator_remote.py.

And because I didn't want to have two terminal screens open, as a third part I created a script elev that starts the main engine in the background and then boots up the remote.

Later I rebuild the code to make use of the MQTT message broker instead of a sequential file.

Program messages were just printed to the terminal screen, causing the need for the elevator control program to be open during operation. I rebuild the code to spit out messages to another MQTT queue for the elevator_remote program to fetch is and display them on a curse windowed screen.


The libraries used in this project are:

  • ADAFRUIT_MotorHAT, used for
    • motor control
  • paho.mqtt - message broker, used for
    • communicating between remote control and elevatir
  • collections - deque, used for
    • the creation of a queue mechanism
  • atexit, used for
    • registering a routine that is executed at program end
  • curses
  • os for interaction with the system
  • gawterm, using curses for
    • creating a windowed screen to streamline output better
  • pigpio, used for
    • controlling the input switches
      • callback interrupt routines
    • controlling the output LED's
  • time, used for
    • knowing the time, timing interrupts


When the program is running, it presents the user with a prompt: "Remote input >" to indicate it expects a command. type h or help to see which command are available.

License / availability

This software is available under the conditions of the GNU General Public License. See the License file for further details.

Use at own risk

Usage of this program is at the user's own risk, author will not be held responsible for any damage to your hardware. Especially the connection of wires to the correct Pi terminals has to be done with the greatest possible care.

See also:

Readme file

Roadmap or TODO file

License file