Main goal of this project was develop access system which will use RFID cards and Fabman API.
Custom electronics for access management & communication with remote server.
To make the experience fit your profile, pick a username and tell us what interests you.
Main goal of this project was develop access system which will use RFID cards and Fabman API.
We started to develop this in March 2018 and finished it in May 2019, and I did most of the coding (with big help of my friend @Lubos Moravec) and all HW development. I did not work on this every day, as I´m not full time developer and it was big challenge for me as I had to learn basic coding on this project. There will be still some development, but core stuff is done and we will probably do just some code repairs and minor changes.
This HW could be used, with some changes, on other printers and services. I looked at "stock" Marlin and Repetier firmwares, and both have some functions to store similar values as we use to get out data from printer. These informations could be also just stored in some SQL database, from which any system can take needed information.
For now, we can share hardware design, since we want to keep firmware side just for us, but maybe we can share firmware compiled binaries, as it this device can be setup like original HW from Fabman service.
We have quite a few other cool integrations and you can look at those here.
SW side of this project turned out to be the hardest part as we had to make everything from scratch. Development could be divided in two parts. Prusa firmware development and ESP32 firmware development.
1) Prusa firmware development
We started to look at firmware code and we tried to find some similar behavior in the firmware for our use. We did find it in "Farm mode", which is basically separate screen on top of a regular printer menu. This screen is shown when Farm mode is active when printer receives some set of information through UART. When this is done, printer unlocks this screen and let you play with printer as normal. Farm mode is used in Prusa Research factory on their printing line.
We copied function which is responsible for this behavior and changed it to our needs and here is the result (this time we handle unlock by long press of the knob):
After that we had to find out how to communicate with printer. The easiest way was change the default serial port to number 2, which will disable USB communication, but we do not need this one anyway, as all messages are transfered to serial port num. 2 . USB port still works for uploading firmware to the printer.
We made Fabman.h file, which contains functions and these are called from ESP32 by custom gcodes.
For better user experience, and also if there is some problem with the print, we are showing name of the user which is using the printer at top of the printer menu.
We also implemented sending of IP address and ESP32 firmware version to the printer Support menu which looks like this:
There are also some functions which handle responses from the server to inform user that something is not quite right, like "You do not have active package. Please buy one.", "You do not have required training course!!", "You are not allowed to use this printer outside opening hours", "Sorry, I am not online right now. Please try me later." so anyone knows what is wrong.
You can look at changes to Prusa Firmware at Github.
2) ESP32 firmware development
On ESP32 first thing what we needed to make work was RFID reader, which communicates through serial line, but just transmit what read from the card. We found out that reader transmits data as plain characters, so we just need to grab part of the data which matches our format and that is all what has to be done. With right ID from the card, we could move forward and combine it with printer firmware. Here is the result:
Printer works this way:
Power on -> access screen ON -> user swipes is card -> if user is allowed to use printer -> access screen OFF -> start of the print -> flag that printer is printing -> printing -> end of the print -> take data which updates printer statistics -> push this data to ESP32 -> user is logged off -> access screen ON.
We are sending data about finished & not-finished prints, so we should cover all prints on printer. With amount of printed filament, we also send file name of the print so users can know how much did each print cost.
This data is shown in our eshop, where user can with just one click put print/prints in to the shopping basket and pay for them.
When this is done, print is marked in our database as "Print paid" and by this flag, our eshop will know that it should not be shown to the user again.
We implemented OTA updates, so device can be anywhere on the Internet. It can be also set up with different Fabman account through build-in captive portal, which is triggered if at startup the log-off button is pressed. In our firmware we also use the Telnet server, so we can see debugging...Read more »
First of all, we need hardware which will interact with firmware of the printer. Since we like and heavily use ESP32, the choice was easy. Basically we need UART communication with printer electronics, some status LEDs and UART to RFID reader. We wanted this to be as simple as possible, so we will use LCD on printer for status messages. Also we want this to be affordable as much as possible, we looked online and found this RFID reader at Aliexpress.
This reader just reads the card and transmits ID of the card to UART port.
Because we think that best place to have this reader would be in LCD cover, our member (Jan Chromec) redesigned LCD cover to accommodate RFID reader & ESP32. These will sit at side of the LCD and can be powered from printer. I designed first PCB and to be sure that everything lines up together, I made prototype from cardboard on laser cutter. I glued connectors to their place to ensure that they will fit in hole and will not collide with anything. You can see how it looks like on next picture. This is just one prototype of the PCB, with spacer and RFID reader in place.
Here is revision A of the board:
Revision A did not make it to the PCB factory and I redesigned whole board to revision B quite early I finished it. Here is revision B :
I designed this board so it can be hand soldered and does not need reflow oven, but it can be baked in it as well. Because of limited space and requirement of low price I did not include UART to USB interface and instead of that, board is programmed by external UART to USB converter. For there is on board Boot button with Reset button. 4-pin header is for external UART converter, 5-pin header is for power and UART communication with printer, RFID TX is for data line from RFID reader, Stop button is for sending end of the user session to server. Rest of the parts are just resistor & capacitors for power and voltage level shifters from 5V to 3V3. Red LED is signalization that board is powered and Green LED is showing information if we are connected to WiFi .
This board served as main horse for development of the firmware. Through development I did find out that I made mistake with pins for UART (printer side) and I had to cut the traces (or not to populate some parts) to make it work. Not long time ago I made revision C, where I repaired my mistakes and also changed composition of the parts to follow recommendation for placing ESP32 modules.
Most recent board look like this:
Here is already made board placed in our custom LCD cover:
Here is sandwich (RFID reader -> spacer -> ESP32 board) in LCD cover which is just for showcase.
We had no problem with this board so far and we are using it on 10 printers right now (mostly revision B).
Hardware is done, now it's up to the software :) .
If you are interested in HW, or you want to just look, here is link for design files.
We are, at Fablab Brno, using Fabman service for management of our members, with which we can be opened 24/7 and do not have to be on site all the time. We can manage members access, their training's & bookings at one place and from anywhere. They offer Fabman Bridge which read RFID card, connect to server, look if member can use device and grant or not access to that device. If access is granted, bridge will switch on power for device. This is very good idea because of versatility of that bridge, but it is bit uncomfortable with thin cables which have to by managed near device.
This made us think, what we can do about it in case of 3D printers? Our current system was not perfect as our members would have to slice their file for 3D printer, find out amount of filament from SW which should go through 3D printer and pay this amount in our eshop up front. This had major flaw in failed prints and payment for those and dealing with payments which was already paid for that failed print. We started to think how we can automatize that?
As we have mostly Prusa i3 printer, MK2´s at the time, we focused on those. We knew that printer keep records of all prints which were printed in EEPROM and there is time and amount of filament which was printed. As printer FW code is open source, it did not take so much work to find save_statistics(); function and take needed information from it.
We also need to store these information somewhere and because Fabman had no support for this at that time, we met with Raphael & Roland from Happylab Vienna and we ask them, if it is possible to add such thing and they did it. They extended their API for Fabman, so we can store our data and use those as well afterwards.
So our journey began with our development.
Become a member to follow this project and never miss any updates