Ad Widget



No announcement yet.

SoftwareSerial Arduino - Manually include SoftwareSerial.h inside MatesController.h

This topic is closed.
  • Filter
  • Time
  • Show
Clear All
new posts

  • SoftwareSerial Arduino - Manually include SoftwareSerial.h inside MatesController.h


    I observed that we need to manually uncomment the #include <SoftwareSerial.h> in MatesController.h inside library for SoftwareSerial to work.
    Is there a way to handle this automatically? or may be keep this SoftwareSerial.h file included by default for Arduino.
    I would like to avoid touching any library code by myself to have some functionality to work.
    Please check and confirm.

  • #2
    Good day!

    Were you able to read the following articles already?If you take a look at any of these project, you should be able to notice how to use Software Serial properly even without modifying the library.

    In Global:
    #include "MatesController.h"
    #include <SoftwareSerial.h>
    #define debugSerial Serial
    SoftwareSerial matesSerial(2, 3);
    // library uses the Software Serial to connect to BBM module (ex. TIMI-96)
    // MatesController mates = MatesController(matesSerial);
    // also prints messages from library to assigned debugSerial
    MatesController mates = MatesController(matesSerial, debugSerial);
    In Setup:
    matesSerial.begin(9600); // this should match Mates Studio project baudrate
    debugSerial.begin(115200); // Serial Monitor needs to be opened in this baudrate
    Notice that besides assigning the appropriate Serial to the library. You also need to initialize it before initializing the library.

    Furthermore, it would be good to note that this method also supports other alternatives to Software Serial such as AltSoftSerial.

    Lastly, SoftwareSerial isn't available to all Arduino programmable boards. This is the main reason why it is commented out in the library.

    As you said, it is not really ideal for anyone to modify the library when not required, so please try to use the method above.

    I hope this helps.
    Juniel Cruz


    • Ujwal Nandanwar
      Ujwal Nandanwar commented
      Editing a comment
      Got it . It works now without modifying library using above method We just need to make sure to begin the SoftwareSerial before beginning MatesController .
      Thanks for your quick help . All good now.