Comments (23)
If the blue LED lights up and stays on, the connection should be solid. The printer's communication protocol may not be compatible and that would prevent it from working beyond connecting. Try connecting to it from a simple BLE app like Nordic's nRF Connect and just sending it ASCII text followed by a carriage return. It should print simple text directly. If that works, then I'm not sure what the problem is without seeing the rest of your code.
from thermal_printer.
from thermal_printer.
hmm - if you're running the code successfully on another printer, then it sounds like the protocol of the failing one is different. If you're not familiar with how the code works, then it will be challenging to diagnose the problem remotely. Printer vendors either use the standard printing protocol (like the MTP-2) or they go it on their own. Can you send a purchase link to the one you're having trouble with? Maybe I'll buy one to figure out the issue.
from thermal_printer.
Sorry, I didn't mean the code was working on another printer. I meant I have another app on my phone (just called Bluetooth Print) that works with this printer.
The printer is one of these: https://www.tomtop.com/pt/p-os1228uk.html?currency=EUR&Warehouse=CN&aid=gttpmaxptth&gclid=Cj0KCQiA54KfBhCKARIsAJzSrdoLMBOW7jGu-iI_cN29RniFMp02ffVEvifo-S74sCrAGvIVnX3cy9gaAr_nEALw_wcB
from thermal_printer.
I have and support that printer; I forgot because I have so many. Now I'm really curious as to why you're unable to get it working.
from thermal_printer.
That's why I was a bit unsure when it didn't work, too, as I saw you specifically have the MTP-3 in the list.
Could it be anything to do with any other settings for the ESP32? I've only used arduinos before - this is my first attempt with an ESP32 and I see there are lots of extra settings under the tools menu of the arduino IDE, that I don't understand yet. Currently, I'm using the "ESP32 Dev Module" board setting, as per the attached guide for the devices I have.
ESP-32 Dev Kit C V2_EN.pdf
If it helps, this is what I get from the serial monitor when restarting the device:
15:33:03.586 -> ets Jun 8 2016 00:22:57
15:33:03.586 ->
15:33:03.586 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:33:03.586 -> configsip: 0, SPIWP:0xee
15:33:03.586 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:33:03.586 -> mode:DIO, clock div:1
15:33:03.586 -> load:0x3fff0030,len:1344
15:33:03.586 -> load:0x40078000,len:13836
15:33:03.586 -> load:0x40080400,len:3608
15:33:03.618 -> entry 0x400805f0
15:33:03.976 -> Preparing image buffer...
15:33:03.976 -> Scanning for BLE printer
15:33:09.682 -> Found a printer!, connecting...
And that's as far as it gets. That's running the Thermal_Printer_Demo sketch, with the only change being specifying the device name in the scan.
from thermal_printer.
Looks ok. I need to retest. Each time Espressif releases an updated support package for Arduino they break something. What version of ESP32 support are you using? I'll retest with your version to see if I can reproduce the problem.
from thermal_printer.
from thermal_printer.
I've tried the previous few versions, and it seems to be the same.
from thermal_printer.
ok, thanks for the info. I'll test on my equipment.
from thermal_printer.
Thanks a lot. Hope you manage to find something!
If it helps, I've been playing a bit more, and with the demo sketch it just stops at "found printer, connecting" so I tried adding the following into the main loop, just to see if it was freezing completely, or if it was still running and maybe would try to connect again:
void loop() { // put your main code here, to run repeatedly: delay(5000); if (tpIsConnected()) { Serial.println("Still Connected"); tpSetFont(1, 0, 0, 0, 0); tpPrint((char *)"9x17 plain text\r"); } else if (!tpIsConnected()) { Serial.println(tpIsConnected()); tpConnect(); } }
With this, it does carry on trying, and after a few attempts, it does say "connect failed":
18:29:38.516 -> Scanning for BLE printer
18:29:44.184 -> Found a printer!, connecting...
18:29:49.742 -> 0
18:29:54.739 -> 0
18:29:59.733 -> 0
18:29:59.733 -> Connect failed
18:30:04.722 -> 0
18:30:04.722 -> Connect failed
18:30:09.739 -> 0
18:30:09.739 -> Connect failed
18:30:14.751 -> 0
18:30:14.751 -> Connect failed
So, it seems to be that the printer thinks they are connected, but that information isn't getting sent back to the esp for some reason.
from thermal_printer.
I've been fiddling a little more (just because I'm bored!) and getting some strange stuff now.
First off, I did manage to get nRF connect to send text to the printer, it's just that it would only work if i sent enough text to run over one line.
Then I tried stripping the code right down to just the following:
void setup() { // put your setup code here, to run once: Serial.begin(115200); Serial.println("Scanning for BLE printer"); if (tpScan((char *) "MTP-3", 5)) { Serial.println("Found a printer!, connecting..."); if (tpConnect()); { Serial.println("Connected!"); tpSetFont(1, 0, 0, 0, 0); tpPrint((char *)"9x17 plain text with lots of text so it goes over one line\r"); } } Serial.println(tpIsConnected()); }
Oddly, it is now getting as far as the "Connected!" line, but still doesn't print anything. Then, when it prints the IsConnected check at the end, it comes back as false. But I'm also now getting other lines on the serial monitor that I haven't seen before:
18:25:48.662 -> Scanning for BLE printer
18:25:54.592 -> Found a match for MTP-3
18:25:54.592 -> Printer type = 1
18:25:54.592 -> Found a printer!, connecting...
18:25:55.844 -> Came back from connect
18:25:56.329 -> Connected!
18:25:56.329 -> 0
I have no idea what's going on! Is it likely I just have a weird messed up printer? Do you think it's worth me getting a different one? If so any particular one you recommend?
from thermal_printer.
I just tried it with my MTP-3 and an Arduino Nano 33 BLE. I added the name in the tpScan() method and it immediately found the printer and successfully printed.
from thermal_printer.
from thermal_printer.
I just tested it with the ESP32 (generic LOLIN32 board), and it worked perfectly.
from thermal_printer.
from thermal_printer.
Looks like I might struggle to get another one locally. In the meantime, if you get bored and if it helps, I loaded the demo code again with the core debug mode set to debug and verbose, so I don't know if those might show any reason for it not working?
esp32_thermal_printer_debug.txt
esp32_thermal_printer_verbose.txt
from thermal_printer.
I did manage to find another printer. A PT-210. It still doesn't find it automatically, I have to add the name (in this case "MTP-II_7867"), but then it's exactly the same. It gets as far as connecting (bluetooth indicator comes on), but still doesn't print anything.
from thermal_printer.
Related Issues (20)
- Convert bmp logo to hex? HOT 1
- Phomemo T02 support HOT 13
- Support dodocool printers HOT 8
- Error when compiling example from latest source ?
- New GOOJPRT PT-210 don't match HOT 1
- NimBLE support for ESP32 via MACRO HOT 1
- I want to connect to a printer without scan HOT 1
- expose tpWriteData HOT 1
- Phomemo t02 problem HOT 6
- CAT Printer YHK-B9AA HOT 7
- PeriPage printer not feeding paper while printing JPG from ov2640 camera HOT 3
- Error when installing HOT 1
- Peripage A9 Max HOT 1
- GOOJPRT PT-210 issue HOT 1
- tpConnect(const char *szMacAddress) do not connect.
- peripage a2 very light text and images HOT 2
- How to Get a opensource of ESCPOS Commands HOT 2
- How to convert bmp to printer ? HOT 1
- Crash on M5stack-atom HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thermal_printer.