For makers and stall sellers with an Arduino Mega and a 58 mm thermal printer. Type your lines below to get the totals, the tax per rate and the receipt exactly as the printer will print it. Set a quantity to 0 to drop a line.
| Item | Qty | Unit price | Tax % |
|---|---|---|---|
Why whole cents: on an Uno or Mega, float and double are the same 32-bit type. Adding 0.10 ten thousand times that way gives 999.9029 ($999.90); in cents it is $1,000.00. This page uses the same integer rounding as the sketches (half away from zero). The invoice number and date on the preview are samples; the sketches take the date you type and the next number from EEPROM.
The 5 sketches that put it on paper: ESC/POS printing on Serial1, invoice numbers kept in EEPROM through power cuts with VOID handling, a 5-button till and a daily Z report with per-rate totals.
One payment, one licence key for this tool. The key is shown right after payment.
Hiring it out: BLS OEWS May 2025 median wage for software developers is $65.38 an hour (series OEUN000000000000015125208). The Adafruit Mini Thermal Receipt Printer was listed at $49.95 (adafruit.com/product/597, 2026-10-18). Code
Buy the full version — $44I have a keyNeed more than this one? ReadyStack Pass opens all 544 files and 493 full versions — $29/month or $199/year. See the Pass →
Paste this code into your page. It runs in your visitor’s browser and stays up to date. Nothing your visitors type is stored.
For businesses: your name and logo instead of ours, and each visitor’s result + e-mail in your inbox (only when they tick consent) — Pro from $19/month. See Pro →
· ReadyStack
Real numbers from this tool, line by line.

For makers printing receipts from an Arduino Mega, a 32-bit float adds 10,000 lines of $0.10 to $999.90 instead of $1,000.00. That is the first thing InvoiceTotalsCents prints, next to a sample invoice it totals in whole cents:
| Line | Amount |
|---|---|
| Repair labour, 2 × $45.00 | $90.00 |
| Relay module, 7 × $1.99 | $13.93 |
| Jumper wire set, 3 × $2.49 | $7.47 |
| Printed manual, 1 × $7.99 (0 % tax) | $7.99 |
| Loyalty discount | -$5.00 |
| Net at 20.00 % / tax | $106.40 / $21.28 |
| TOTAL | $135.67 |
On an Uno or Mega, float and double are the same 32-bit type. It holds about seven significant digits, so a running total drifts as soon as the day gets long. The fix is old and boring: count cents in a long integer, multiply quantity by unit price in cents, and round tax only once, with a rule you choose.
The sketch groups lines by tax rate (basis points: 2000 = 20.00 %), then rounds half away from zero, once per rate or on every line. Your accountant picks the rule; you flip ROUND_PER_LINE. If your shelf prices already include tax, set PRICES_INCLUDE_TAX and the sketch splits each rate back into net and tax. The till sample does exactly that: 2 coffees at $3.50, a cake slice at $4.25 and a jam jar at $6.00 give TOTAL $17.25, with tax $1.87 at 20 % and $0.29 at 5 %.
Most receipt tutorials keep the counter in RAM. Reset the board and the next receipt is number 1 again, a duplicate. InvoiceNumberEeprom keeps the number in two 16-byte EEPROM slots with a CRC-16. Each write goes to the older slot and is read back before it counts. We cut the power in a test halfway through a write: after the reboot the last good number, 2026-000004, was still there, and the next invoice was 2026-000005.
A number is reserved before the printer starts and marked printed afterwards. If the power fails in between, the next boot prints a VOID slip for that number, so the series has no hole and nothing repeats. The year comes from the date you type each morning (D2026-10-18). A new year restarts the series if you want it to, and a date earlier than the last invoice's year is refused.
ThermalInvoicePrint talks ESC/POS on the Mega's second hardware serial port (pin 18), so the USB monitor stays free. Every line is laid out to 32 columns for 58 mm paper. Names are cut to fit; the money column is never cut. A short pause after each line lets the print head keep up, a 3-second lockout turns a nervous double press into one invoice, and no date means no invoice.
TillButtons adds three product buttons, a VOID LAST button and a print button you have to hold for a second. DailyZReport saves the day's totals per tax rate after every sale and resets them only after the Z report has gone to the printer.
Type your own lines into the free calculator on the product page. It uses the same integer rounding as the sketches, draws the exact 32-column receipt, and writes the ITEMS[] block you paste into the sketch. If the total is what you expect, the five sketches put it on paper with a number that survives a power cut. No library to install; all five compile with arduino-cli for the Mega.
This is not a certified fiscal register. Where your country requires one, use that for sales and these sketches for workshop invoices, testing and learning.
It turns an Arduino Mega and a 58 mm ESC/POS thermal printer into an invoice printer. Five sketches add lines in whole cents, split net and tax per rate, keep gapless invoice numbers in EEPROM through power cuts, run a button till and close the day with a Z report. The bundled sample prints invoice 2026-000001 with TOTAL $135.67.
Makers and small sellers who already own an Arduino Mega and a TTL thermal receipt printer: a market stall, a repair bench, a workshop or a makerspace shop that needs printed, numbered receipts. You change your shop name, products, prices, tax rates and currency at the top of each file; the sketches need no extra library.
Free printer libraries print text, but none adds tax per rate in whole cents or keeps an invoice number through a reset. A counter in RAM starts again at 1 after a power cut and repeats numbers. Money in a float drifts: a 32-bit float adds 10,000 × $0.10 to $999.90, not $1,000.00.
The invoice calculator is free with no account: type your lines, see whole-cent totals, net and tax per rate and the exact 32-column receipt the printer would print, and copy the ITEMS[] block for your own lines. The paid pack adds the printing, the EEPROM invoice numbers, the till and the daily Z report.
The pack is $44 once. BLS OEWS May 2025 puts the median software developer wage at $65.38 an hour. CodeCanyon invoice scripts on 2026-10-18 cost $10 to $90 but run on a PC or phone, not on a microcontroller. All five sketches compile with arduino-cli for arduino:avr:mega.
One question, answered by the person who built it. Your email only if you want the answer sent.