The new Lab management software to implement pay-per-use concept for the Fab Lab Siegen
This project is prototype and still in development. There is no setup script or so. The code is just a snapshot to show how the concept could work.
- Monitor and Assign available printer to visiting customers in the lab
- Access control via ESP8266 and RFID-reader by connecting/disconnecting OctoPrint to printer
- Store and retrieve print usage details
- Calculate, view and manage cost of each print
- Manage Maintenance of each printer by tracking print hours
Implementation for the ESP8266 that controls the RFID-Reader, interprets OctoPrint events and publishes MQTT commands to the broker
Path : ESP_RFID/ESP_RFID.ino
- Open the file ESP_RFID.ino in Arduino IDE (or) any preferred IDE
- Add required libraries (ArduinoJson, MFRC522, PubSubClient) to the IDE
- Search for the string "# WARNING", then Add Wi-Fi credentials and MQTT connection details
- Search for "# WARNING add RFID tag" and add RFID tag corresponding to the printer
- Setup NodeMCU with RFID
- Upload the code
Back-End of the application is a REST api built using Django rest framework with Postgres-DB.
-
If you wish to run your own build, first ensure you have python globally installed in your computer. If not, you can get python here.
-
After doing this, confirm that you have installed virtualenv globally as well. If not, run this:
$ pip install virtualenv
-
Then, Git clone this repo to your PC
$ git clone https://github.com/FabLabSiegen/Lab-Manager.git
-
-
Cd into your the cloned repo as such:
$ cd Lab-Manager
-
Create and fire up your virtual environment:
$ virtualenv venv -p python3 $ source venv/bin/activate
-
Dependencies such as django-rest-framework a powerful and flexible toolkit for building Web APIs, psycopg2 (PostgreSQL database adapter for Python), django-cors-headers (for allowing resources to be accessed on other domains), simplejson as json encoder/decoder are used to build the API. Install the dependencies needed to run the app:
$ pip install -r requirements.txt
-
- Add credentials and db name in
settings.py
- Add credentials and db name in
-
paho-mqtt as MQTT client is used to connect to an MQTT broker to publish messages, and to subscribe to topics and receive published messages. In the file lab_manager\mqttservice.py, search for "WARNING add MQTT Host" and add MQTT host details
-
Make those migrations work
$ python manage.py makemigrations $ python manage.py migrate
-
-
Fire up the server using this one simple command:
$ python manage.py runserver 8080
You can now access the api endpoints on your browser.
-
GET, POST
printers detail available in Lab:api/printers
GET, PUT
each printer detail available in Lab:api/printers/{string:id}
GET, POST
user detail available in Lab:api/user
GET, PUT
each user detail available in Lab:api/user/{string:user}
GET, POST, DELETE
usage detail available in Lab:api/usage
GET, PUT, DELETE
each usage detail available in Lab:api/usage/{string:id}
GET
filament detail available in Lab:api/filament
GET, PUT
each filament detail available in Lab:api/filament/{string:filamentname}
GET, PUT
default material usage details:/api/material/{string:id}
GET, PUT
default printer usage details:/api/printer/{string:id}
GET, PUT
default operating usage details:/api/operating/{string:id}
Path : Lab-manager/Front-End
To get the Front-End application running locally:
-
Install Node JS. Refer to https://nodejs.org/en/ to install nodejs.
-
Install create-react-app npm package globally. This will help to easily run the project and also build the source files easily. Use the following command to install create-react-app
$ npm install -g create-react-app
- Navigate to folder Lab-Manager/Front-End from command line
$ cd Lab-Manager/Front-End
- Install all required dependencies. The Front-end is built using packages Bootstrap as css framework, React-Hooks for state management, Axios as HTTP client,
$ npm install
- Start the local server (this project uses create-react-app)
$ npm start
Local web server will use port 8081 instead of standard React's port 3000 to prevent conflicts with some backends like Node. Port can be onfigured in scripts section of package.json
. Once the Django API is running, Front-end starts interacting with the API.
OctoPrint is used to control and monitor every aspect of your 3D printer and your printing jobs right from within your browser.
-
Setup OctoPrint based on your device, refer to https://octoprint.org/download/
-
For installing OctoPrint on your local windows machine, refer to https://community.octoprint.org/t/setting-up-octoprint-on-windows/383.
-
Once the OctoPrint is installed, create account and connect to Virtual Printer (The Virtual Printer plugin provides a virtual printer to connect to during development. The virtual printer has been included in OctoPrint by default. This plugin allows you to debug OctoPrint’s serial communication without connecting to an actual printer. Furthermore, it is possible to create certain edge conditions that may be hard to reproduce with a real printer).
-
Add MQTT plugin and MQTT Subscribe plugins to the OctoPrint to Pubilish/Subscribe messages from MQTT Broker. Refer procedure for adding plugins in OctoPrint https://plugins.octoprint.org/help/installation/
-
Configure MQTT plugin by entering MQTT connection details under Broker tab and configure topics using base topic: OctoPrint as shown
-
Configure MQTT Subscribe plugin as shown.