Uduino Compatibility with Adafruit Thermal Printer

Create issue
Issue #12 new
Quinn created an issue

Hi, just to start off let me just say that I'm new to electronics, so I apologize if I'm making any obvious mistakes here. I have looked through the tutorial about including external libraries a few times, and incorporated what I read there into a sketch using Arduino and Adafruit's thermal printer (https://www.adafruit.com/product/2752). When I upload the original Uduino base sketch onto the board, the Uduino manager recognizes my board immediately. However, when I upload the code incorporating the printer library and the Uduino library, I get the error attached.

I am unsure as to why this is happening. I am going to send a screenshot of the code I'm using that has Adafruit's printer library and the Uduino one. Is there something I am missing?

It says in the external library tutorial that any library can work. I have a feeling that is the case and I'm just missing something. Please help!

(Also, I'm using the Arduino Uno and Mac High Sierra.)

Comments (8)

  1. Marc Teys repo owner

    With Uduino it is important to not write any information in the Serial console before the instance is detected by unity. If printer.println()writes in the console, you'll have to encapsulate it under : if(uduino.isInit()) { //.. your code } (as well as the rest of your code)

  2. Quinn reporter

    Thanks for your fast response! I tried what you suggested, and I'm going to attach another screenshot of the code to make sure I formatted it correctly. I still seem to be getting the same error message when I click discover ports. I am new to this, so let me know if I misinterpreted what you said.

    Screen Shot 2017-12-08 at 12.12.43 PM.png

  3. Marc Teys repo owner

    The uduino.isInit() has to be put in the loop.

    Your code should look like :

    #!cpp
    #include<Uduino.h>
    Uduino uduino("advancedBoard");
    
    void setup()
    {
    // nothing else here except the printer initialization like mySerial.begin() etc
     // additionnal commands
       uduino.addCommand("customCommand", DoStuff);
    }
    void DoStuff() {   } 
    
    void loop()
    {
      uduino.readSerial();
      if(uduino.isInit()) {
    
      // ... any code once the board is detected ! 
    }
    }
    
  4. Quinn reporter

    Okay, this code makes a lot more sense to me than what I previously had haha, thank you. Still dealing with the same issue, unfortunately. Another screenshot attached.

    Completely lost as to what to do at this point. Thank you again for helping me in a timely way - I have a project for school using this printer due Tuesday and am just trying to figure out how to move forward.Screen Shot 2017-12-08 at 10.12.26 PM.png

  5. Marc Teys repo owner

    Almost ! The printier initialization should not be in the function "DoStuff" but below printer.begin(). The "addCommand" function is here to trigger commands from arduino (see section Trigger a command with parameters; it will be the next step for you !

  6. Quinn reporter

    I should've explained that actually, me moving the rest of the printer initialization to the "DoStuff" command was a last ditch effort switch up to see if that would work haha, I did initially try this code and got the same error as usual.

    Attaching a screenshot again for clarity.Screen Shot 2017-12-09 at 11.25.34 AM.png

    Is it possible that Uduino is not compatible with this library or is there something else I am missing?

  7. Quinn reporter

    Just was messing around with the code and seeing what could work and what couldn't, I found that if I didn't define the Serial and moved the printer initialization (including what the printer actually prints) to DoStuff the board could be recognized by Unity. The only issue is that I need the Serial to be defined as the RX and TX pins for the printer to be powered.

    Here's the code that actually lets the board be recognized: Screen Shot 2017-12-09 at 12.35.23 PM.png

    Not sure what this means, just was messing around and figured I'd share in case it means anything.

  8. Log in to comment