Introduction: EcoPrinter

Paper use has increased dramatically and the negative impact of this on the environment is significant. Undoubtedly, it is now time for us to take action and reduce the use of paper in our daily lives. That is why we are introducing the ecoPrinter!!! This innovative device which is an implementation of Android Beam and USB Printer Gadget can easily help us replace hard copies with file transferring. And guess what... this can be effortlessly achieved and at a very low cost!!!

EcoPrinter is a device which allows the user to use the NFC protocol with the Android Beam implementation in order to transfer any type of printed work to a mobile device without taking any necessary action apart from unlocking the mobile device! From the user's perspective,meaning those who wish to receive documents on the mobile device, no further action is required (works similar to the NFC Payments). No App installation, no setting up, it just magically "works". From the provider's perspective all it has to be done is to connect ecoPrinter to the computer and run a command to correlate the appropriate Microsoft Driver with the device (No custom drivers, no downloads, no installations - Just a command).This is a one-off procedure and then users can enjoy the benefits of ecoPrinter!

EcoPrinter should not only be considered as a device for personal use but for professional use as well. Imagine how helpful it would be if every business, organisation or authority used the ecoPrinter. Any receipt and other important documents would be saved and organised on your mobile device to be easily accessed any time needed. Undoubtedly, by cutting down the use of paper not only benefits our environment but can also help users to save money from paper and toner usage.

It should be noted that each ecoPrinter has a unique serial number which could be used to have the total spending's per store / category, better management of your financial state, even logs by each supplier.

EcoPrinter will not only help towards reducing the amount of paper we use but it will also help the users organise and keep their receipts, invoices, documents with the minimum amount of effort required from both parties (user & provider)

EcoPrinter is a proof of concept and only the bare minimums have been hereby described.

Let's go paperless!!!

How it works

  • The provider (owner of the device) connects the ecoPrinter and correlates the appropriate driver.
  • The provider of the ecoPrinter functionality simply selects the document to be printed and selects ecoPrinter as the preferable printer device.
  • The file is then send to the Raspberry Pi and is converted to PDF.
  • The WS2812B indicates to the user that it's time to place the device to the ecoPrinter
  • With no other interaction the file is transferred to the mobile device as a PDF.

Detailed explanation of a file transfer using the ecoPrinter (What is the meaning of the different lighting effects)

  1. The Print job has been sent from the computer to the ecoPrinter (same as the standard printing procedure)
  2. Green light ring effect on ecoPrinter means that the device is receiving the print job and converts the file into a PDF.
  3. Red light ring effect means that ecoPrinter is waiting for an NFC Device to connect
  4. Green light ring effect following the red one, means that the NFC connection was successful and ecoPrinter is waiting for the Bluetooth handover
  5. Blue light ring effect, Bluetooth connection initiated and the file is being transferred to your mobile device.


For the provider

  • Raspberry PI Zero W ( Can be used as a USB Gadget, and has WIFI and Bluetooth onboard)
  • PN532 NFCShield(other shields would also work thanks to the great work of Mr.

    Stephen Tiedemann, the creator of the nfcpy library)

  • WS2812 5050 RGB 12 LEDs Ring (optional)

For the end user

  • Android Device with NFC functionality and Android version of 9 (PIE) or previous.
  • Android Beam enabled from the Device's Settings menu.

Step 1: Make the Hardware Connections

The ecoPrinter hardware configuration is very simple and is as follows:

  1. Connect the NFC Board, using Raspberry's UART (GPIOs 14,15). There are different types of NFC Boards but almost all of them support serial communication. Select a board which is compatible with nfcpy library and AVOID devices which connect using the USB because Raspberry PI cannot be a USB Host and a USB Gadget at the same time (So it will not work)
  2. Use GPIO 18 as the DATA pin to control the WS2812B led panel.
  3. Provide power to both boards from Raspberry PI.

Step 2: Raspberry Preparation

  1. Download the last Raspbian (Version: February 2020) from the official page
  2. Prepare the SD card with the Raspbian following the official instructions from here
  3. Create a new file with name ssh (don't use any extension), in the boot partition of the SD Card
  4. Create a new file wpa_supplicant.conf , in the boot partition of the SD Card and enter the following content:
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  5. Append the following lines at the end of the file config.txt in the boot partition of the SD card
    # Enable serial communication - It will be used for communication with the NFC Shield
    # Set GPU memory to 16 MB, as long as we don't use any display
    # Enable dwc2 overlay in order to convert the Raspi to a Printer Gadget
  6. Remove the following text from the file cmdline.txt in the boot partition of the SD card, in order to disable console usage via serial port.
  7. Safely remove the SD-Card from your computer, insert it in the Raspberry PI and boot.
  8. After the boot sequence complete, follow the appropriate procedure for your Operating System (Windows, Windows 10, Mac or Linux) to connect to the device using SSH.
  9. Update Raspbian's repositories and software using the following commands.
    sudo apt-get update
    sudo apt-get upgrade -y 
  10. Set the appropriate modules to be loaded on each boot by using the following commands:
    sudo su
    echo 'dwc2' >> /etc/modules
    echo 'libcomposite' >> /etc/modules
    After typing sudo su, the user indicator will change and all commands will be executed as root.
  11. You can confirm your actions by displaying the /etc/modules files
    cat /etc/modules
  12. Install the required libraries for the WS2812B Neopixel Ring using the command:
    sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel

Step 3: Convert Raspberry PI to a Printer Gadget

  1. Create the directory which will hold the configuration file
    sudo mkdir /usr/bin/nm_gadget
  2. Create the USB Gadget configuration file
    sudo nano /usr/bin/nm_gadget/ecoPrinter
  3. Paste the printer device configuration
    #ecoPrinter Gadget
    modprobe libcomposite
    cd /sys/kernel/config/usb_gadget/
    mkdir -p ecoPrinter
    cd ecoPrinter
    # Device's Information
    echo 0x04a9 > idVendor
    echo 0x1761 > idProduct
    echo 0x0100 > bcdDevice
    echo 0x0200 > bcdUSB
    echo 0x07 > bDeviceClass
    echo 0x01 > bDeviceSubClass
    echo 0x01 > bDeviceProtocol
    # Set English Locale
    mkdir -p strings/0x409
    echo "10000001" > strings/0x409/serialnumber
    echo "Novamostra" > strings/0x409/manufacturer
    echo "ecoPrinter" > strings/0x409/product
    mkdir -p configs/c.1/strings/0x409
    echo 120 > configs/c.1/MaxPower
    mkdir -p functions/printer.usb0
    echo 10 > functions/printer.usb0/q_len
    echo "MFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;" > functions/printer.usb0/pnp_string
    echo "Conf 1" > configs/c.1/strings/0x409/configuration
    ln -s functions/printer.usb0 configs/c.1/
    ls /sys/class/udc > UDC
  4. Use Ctrl + X key combination to close the file
  5. When asked to save changes, press "y"
  6. Press enter in order to skip selecting a new name for the file.
  7. Make the configuration file executable
    sudo chmod +x /usr/bin/nm_gadget/ecoPrinter
  8. Set the configuration file to run on boot by editing the rc.local file
    sudo nano /etc/rc.local
  9. And adding the following line before the "exit" keyword
  10. Install Ghostscript which will handle the conversion from Postscript to PDF
    sudo apt-get install ghostscript -y
  11. The printer device is now ready. Power off your Raspberry Pi:
    sudo poweroff
  12. Connect a usb cable from the Computer to the USB port (not the power port) of the Raspberry PI. Your PI will boot and a notification about a new unknown device, will appear on Windows.
  13. In the Device Manager of your Windows Computer, the Raspberry PI will appear as a Composite Device.

Step 4: Driver Setup on Windows

After connecting the ecoPrinter device using a micro usb cable your computer, open a Command Prompt Window with Administrative Privileges and run the following command:

printui /if /b "ecoPrinter" /f %windir%\inf\ntprint.inf /m "Microsoft PS Class Driver" /r "USB001"

This will correlate the Microsoft PS Class Driver to the ecoPrinter, and a new printer device will appear in your available printers.

If after running the command you receive message Operation could not be completed (error 0x00000704), that means that the device was setup on a different port. Re-run the command changing the USB001 to USB002 or USB003.

If no error appears that means that your device is correctly setup. You can confirm this, by opening the Device Manager and under the Print queues the "ecoPrinter" device is available.

Step 5: Setup Bluetooth Communications

Setup Obex FTP which is required for file transferring, using the command

sudo apt-get install obexftp

Find Raspberry Pi's bluetooth address using the command


Important: Keep a note of the Bluetooth MAC address because we will use it in the configuration file of the ecoPrinter which is required for Bluetooth Handover.

Step 6: Setup NFC Communications

This device uses the nfcpy library to initiate the connection and make the handover to the Bluetooth protocol.

Start by installing the Python Package Installer running the following command:

sudo apt-get install python3-pip -y

and then install nfcpy library using the following command:

sudo pip3 install nfcpy

Make sure that everything is installed and the hardware connections are correct using the command:

python3 -m nfc --search-tty

Your device must appear at serial/ttyS0

Step 7: Copy Appropriate Files From the EcoPrinter Repository

Now your Raspberry is a Printer gadget with Bluetooth and NFC functionality. The last step is to connect all this separate pieces to the final product. First install git:

sudo apt-get install git -y

and then clone the ecoPrinter repository using the command:

git clone

Edit the ecoPrinter.conf file and add your device's Bluetooth MAC address

sudo nano ecoPrinter/code/ecoPrinter.conf

Make a new directory to store the print jobs

mkdir ecoPrinter/code/prints

Set the appropriate permissions to the daemon:

sudo chmod +x ecoPrinter/code/

Edit for another time the rc.local file:

sudo nano /etc/rc.local

And add the following line before the "exit" keyword


Congratulations !! Your ecoPrinter has been successfully set up! Reboot your device and you are ready to go!!!

[Update] May 2019 : All the procedure is now automated using the from the ecoPrinter's repository!
Raspberry Pi Contest 2020

Participated in the
Raspberry Pi Contest 2020

Be the First to Share


    • STEM Contest

      STEM Contest
    • Role Playing Game Challenge

      Role Playing Game Challenge
    • CNC Contest

      CNC Contest