Skip to content

Initialization

Tiogaplanet edited this page Jul 15, 2026 · 3 revisions

Use these functions to initialize MiP.


MiP()

MiP()

Description

This MiP constructor is used to create an instance of a MiP object, whose name you need to provide as in the example below. Only one MiP object should be created in your sketch.

You still need to call begin() to initialize communication with MiP before calling any other MiP functions.

Parameters

None

Returns

Nothing

Example

// Include the MiP library so that you can use its functions.
#include <MPU_D1_mini.h>

// Setup new MiP object.
MiP     mip;

begin()

bool MiP::begin()

Description

Initializes MiP to be controlled by the ESP8266 instead of Bluetooth Low Energy. The LED on MiP's chest will switch from blue to green once communication between the ESP8266 and MiP is established.

Calling another MiP function before begin() has successfully been called will typically generate an error message and your program will be halted so that you can diagnose and correct the problem.

isInitialized() can be called to determine if begin() has been successfully called or not.

Parameters

None

Returns

  • true if MiP was successfully initialized.
  • false if begin() failed to properly initialize MiP.

Example

// Include the MiP library so that you can use its functions.
#include <MPU_D1_mini.h>

// Setup new MiP object.
MiP     mip;

void setup() {
  // Call begin() to initialize the MiP robot.
  // Returns false if it fails to initialize the MiP robot.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial1.println(F("Failed connecting to MiP!"));
    return;
  }
}

end()

void end()

Description

Disconnects from MiP, disables serial communication, and allows the Serial Rx/Tx pins to be used for general input/output.

isInitialized() will return false after end() has been called.

Parameters

None

Returns

Nothing

Example

  mip.end();

sleep()

void sleep()

Description

Puts MiP to sleep. MiP will need to be shut off and back on to wake from sleep. Calling begin() will not wake it.

Parameters

None

Returns

Nothing

Example

  Serial1.println(F("Putting MiP to sleep. Will require power cycle before it will accept UART connections again."));
  mip.sleep();

isInitialized()

bool isInitialized()

Description

Returns whether begin() has been called successfully yet or not.

Parameters

None

Returns

  • true if MiP was successfully initialized.
  • false if begin() failed to properly initialize MiP or end() has been called since the successful begin().

Example

  if (!mip.isInitialized()) {
    // Handle the fact that the MiP robot hasn't been initialized yet.
  }

Clone this wiki locally