Scripts for easily running and scheduling the embedded print quality diagnostics report printout (PQ Diagnostics) on HP printers, away from the printer and outside of HP's official apps. For Windows, MacOS and Linux.
An ink saving alternative to periodically power cycling the printer or running the ink intensive cleaning programs, to prevent the print head nozzles clogging or drying up.
The big question is how often the job should run optimally? Please share your experiences under the issues section.
(At least these scripts work on my HP OfficeJet Pro 8710 / 8715 series printer from Windows, MacOS and Linux devices. Appreciate feedbacks in the issues section on whether the scripts work or not for other HP printers!)
Prerequisites
Installation
Usage
Scheduling
Putting pqdiag in $PATH
Support (or lack thereof)
History and Attributions
- A device running Windows, MacOS or Linux
- curl (comes preinstalled on the above OSes, also on W10 and above)
- A scheduling service, like Windows Task Scheduler or cron on MacOS and Linux, preferably on a machine that is always on or able to wake up when you want, to run the script periodically
(the scripts can of course also be executed manually whenever you want)
- Clone this repository or download it from a release, or just download directly the raw script file that you need for either MacOS/Linux or Windows
- Take note of the scripts' download location/path or copy it to somewhere accessible in your $PATH system environment variable
- On MacOS and Linux, make the bash script executable, e.g.:
sudo chmod 755 ./pqdiag.sh
Put pqdiag in your $PATH environment variable for easy execution from any folder location.
First, in a terminal and from inside the folder where pqdiag.sh is located, make the bash script executable, e.g.: sudo chmod 755 ./pqdiag.sh
Then, run the script like this:
./pqdiag.sh 192.168.0.10
, where 192.168.0.10 must be substituted with the actual IP address of your HP printer.
In a command prompt(cmd) From inside the folder where pqdiag.bat is located, just double-click the file or run the script like this:
pqdiag.bat 192.168.0.10
, where 192.168.0.10 must be substituted with the actual IP address of your HP printer.
Using cron:
sudo crontab -e
- Add whichever of these cron entries suits you the best to the and of the file and substitue /path/to/pqdiag.sh with the actual folder location and 192.168.0.10 with the HP printer's actual IP address:
(or exeriment with your own here: https://crontab.guru)- Wednesdays at 07:00 biweekly (odd week numbers as shown in Norwegian calendars):
0 7 * * Wed expr \( `date +\%s` + 302400 \) / 604800 \% 2 >/dev/null || /path/to/pqdiag.sh 192.168.0.10
- Wednesdays at 07:00 biweekly (even week numbers as shown in Norwegian calendars):
0 7 * * Wed expr `date +\%s` / 604800 \% 2 >/dev/null || /path/to/pqdiag.sh 192.168.0.10
- Wednesdays at 07:00 weekly:
0 7 * * Wed /path/to/pqdiag.sh 192.168.0.10
- Wednesdays at 07:00 biweekly (odd week numbers as shown in Norwegian calendars):
- Save and close the crontab file
https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page
You could also put the pqdiag scripts inside your $PATH environment variable to run from everywhere:
Either move pqdiag.sh to a folder already in your $PATH, or add the folder holding pqdiag.bat to your $PATH like this: https://stackoverflow.com/a/22465399/12802435
Either move pqdiag.sh to a folder already in your $PATH, or add the folder holding pqdiag.bat to your $PATH like this: https://unix.stackexchange.com/a/3820/479692
Either move pqdiag.bat to a folder already in your $PATH, or add the folder holding pqdiag.bat to your $PATH like this: https://stackoverflow.com/a/41895179/12802435
Since everything works as planned already for me and I have spent some time writing this README.md with everything there is to know, this repository will not regularly be visited and updated, and it will NOT be user supported.
However, I have some interest in making this a general and available tool for HP printer users with similar needs, so I will visit now and then and maybe fix some errors or help make it work for other printers than the HP OfficeJet Pro 8710 / 8715.
Please post such feedbacks in the issues section and/or contribute with concrete pull requests.
Having grown tired of dried and clogged up printhead nozzles on my HP OfficeJet Pro 8715 printer, and unsatisfied with the tremendous waste of ink from periodically running the printhead cleaning program or scheduling weekly power cycles in the printer's EWS (embedded web server), I set out on a small journey to see if there was some way to schedule the printer's ink-efficient internal print quality diagnostic report to run often enough from my always-on SBC (Rasperry Pi) or NAS servers to prevent clogging through prolonged periods of little printing.
The journey initially led me to luksfuks' Epson nozzle-check script on Reddit, which convinced me to use the printer's own embedded print quality report, since it activates every nozzle while still using a fairly miniscule amount of ink, with no need to install drivers or anything in addition to tools already provided by most vanilla OS installations.
Then, I stumbled across Jonathan Yang's article on Medium about doing just this from an ESP32-DevKit, which revealed to me the magic XML that needed to be sent to an HP printer to achieve this, which also probably was possible to replicate in an http POST command with curl
, that comes preinstalled on most Windows (starting with W10), MacOS and Linux installations.
Lastly, capturing the http package in question from the HP Utility using Wireshark, comparing the captured package to Yang's above mentioned article and similar XML code in the hp-pqdiag
tool in the Fossies opensource HPLIP (HP Linux Imaging and Printing) repository, studying a bit curl
and cron
, relearning somewhat bat and bash scripting and regex, and playing a little around, it finally resulted in this repo, which I hope will keep my printer operating smoothly going forward by running the scripts biweekly or weekly, and that I also hope others might benefit from...
Additional thanks to:
- MC ND on Stack Overflow for showing the way how to check an argument containing an IP address using regex with
findstr
in at bat script! - Danail Gabensky for the superb answer on Stack Overflow on how to most efficiently check an argument containing an IP address using regex in a bash script!
- pilcrow for a solution on Stack Overflow for how to make biweekly cron jobs!
- grontab.guru for a handy online tool for experimenting with crontab schedules!
- regex101.com for a handy online tool for experimenting with regex patterns!