user47480: I googled about it, but can't find the answer. As I would guess I would have to inherit from the Print class and somehow pass to its print methods the part of my object I would like to be printed. But I am not sure how to go about it or if it is even possible.

user4143: There is a class called Printable. If you inherit from that, and implement the size_t printTo(Print& p) function, your object can then be passed to the print functions:
class myClass : public Printable {
    private:
        int _val1;
        int _val2;

    public:
        myClass(int v1, v2) : _val1(v1), _val2(v2) {}
        size_t printTo(Print& p) const {
             size_t r = 0;

             r += p.print("One: ");
             r += p.print(_val1);
             r += p.print(" Two: ");
             r += p.print(_val2);
             return r;
       }
};

Then:
myClass ob(4, 5);

Serial.println(ob);
=> One: 4 Two: 5


47480: <p>I googled about it, but can't find the answer. As I would guess I would have to inherit from the Print class and somehow pass to its print methods the part of my object I would like to be printed. But I am not sure how to go about it or if it is even possible.</p>
 4143: <p>There is a class called <code>Printable</code>. If you inherit from that, and implement the <code>size_t printTo(Print&amp; p)</code> function, your object can then be passed to the print functions:</p>

<pre><code>class myClass : public Printable {
    private:
        int _val1;
        int _val2;

    public:
        myClass(int v1, v2) : _val1(v1), _val2(v2) {}
        size_t printTo(Print&amp; p) const {
             size_t r = 0;

             r += p.print("One: ");
             r += p.print(_val1);
             r += p.print(" Two: ");
             r += p.print(_val2);
             return r;
       }
};
</code></pre>

<p>Then:</p>

<pre><code>myClass ob(4, 5);

Serial.println(ob);
=&gt; One: 4 Two: 5
</code></pre>
