-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This guide describes all function calls in the application programming interface in the MiP Power Up-D1 mini library. Function calls are organized into 18 groups and explained are in API Reference Index. Below are links to various examples which demonstrate how to use the functions in the library.
Table of contents
- The MPU-D1 mini.
- An optional FTDI adapter to enable debugging over serial port.
- The Arduino IDE.
- The ESP8266 Arduino library.
- Your favorite telnet program for reading the debugging port.
MiP is a unique robot in that it must expend energy to stay upright. This unique quality can at times make it difficult to program and debug via serial cable, especially while MiP is moving around. Therefore, in addition to providing debugging over serial line, I have integrated JoaoLopesF's RemoteDebug library which enables debugging over wireless telnet. However, the debugging library in turn is limited to offering output from the Arduino loop() function only. Judiciously using both serial and telnet debugging will aid in the development of your sketch. An example is provided for debugging using telnet.
Ensure the latest Arduino IDE (>2.x) is installed, along with the ESP8266 board package. If you plan to use the hardware debug port on the MPU, install PuTTY or some other telnet-capable software.
Once the MPU is installed on MiP, we're ready to program it. Launch Arduino IDE, make sure the port number for the D1 mini is selected from Tools->Port and upload the blink sketch from Arduino IDE's examples.
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Working? Great! Now we do the fun stuff. Let's modify the blink sketch to enable Internet-connectivity. While esp8266's guide offers a robust implementation for performing OTA, presented here is the bare minimum sketch to connect MiP to wifi. Be sure to edit the sketch with the access point and password for the network you will connect to. Launch the serial monitor using the COM port for the FTDI adapter that is connected to the MPU's debug port prior to programming it so that we can observe the results of the next sketch.
#include <ESP8266WiFi.h> // These three headers are necessary to enable wifi
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h> // This header enables OTA
const char* ssid = "............."; // Fill in the SSID for your wifi network
const char* password = "............."; // Fill in the password for your wifi network
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial1.begin(74880);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial1.println(F("Connection Failed! Rebooting..."));
delay(5000);
ESP.restart();
}
ArduinoOTA.begin();
Serial1.println(F("Ready"));
Serial1.print(F("IP address: "));
Serial1.println(WiFi.localIP());
}
// the loop function runs over and over again forever
void loop() {
ArduinoOTA.handle();
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
If everything works the serial monitor will show the IP address assigned to MiP. If you have access to your WiFi router, check your DHCP assignments. You should see the IP address that was reported in the serial monitor assigned to a device with a name like "ESP_9337DA."
That's it! MiP is now a cloud-connected robot. Next, it is time to start reviewing the examples provided below, especially the BareMinimumWiFi example which is tailored to configure MiP for our environment and is a good place to start your own sketch. Be sure to read the documentation for the API. Good luck!
These examples are organized into two sections. The first section contains the original, "offline" examples taken from the original ProMini Pack library and describe how to use the API. The second section contains examples illustrating how to employ the WiFi capabilities of the D1 mini.
Try the examples below in any order to learn how to use the API.
- ChestLED: Take control of the RGB LED in MiP's chest.
- Clap: Send descriptive messages to a serial monitor about each clap event MiP detects.
- ContinuousDrive: You want to control the motion of MiP in real time? This is the example for you.
- DisconnectApp: Disconnect all apps, including this sketch and any app that may be connected to Bluetooth.
- DistanceDrive: Tell MiP exactly how far to travel and forget about it.
- DriveForwardBackward: Tell MiP how long to drive forward/backward and forget about it.
- EnableGameMode: Cycle through each of the game modes available.
- EnableMiPDetectionMode: Allow MiP to be discovered by others.
- FallDown: Tired of standing around? Command MiP to fall flat on his face.
- Gesture: Use your hand to make gestures to MiP. Send descriptive messages about each detected gesture.
- GestureRadarMode: Want to learn more about how to enable/disable IR based gesture and radar measurements? Check out this example.
- GetUp: If MiP falls down, learn how to have him try getting back up on his wheels.
- HeadLEDs: Take control of the four individual eye LEDs in MiP's head.
- Odometer: How far has MiP been traveling around your personal robot laboratory? This example shows you how to find out and reset its measurement.
- PlaySound: Learn how to get MiP vocalizing under your control!
- Radar: Is there anything in front of MiP? This example sends descriptive messages when it detects changes in the obstacles around it.
- RawSendReceive: You found a command in WowWee's protocol specification that isn't supported by this library? This example shows you how to experiment with these new commands.
- ReadWriteEEPROM: Read and write your own data to MiP's EEPROM. This is useful for storing data across power cycles. See also ZeroEEPROM.
- ReadDongleCode: Reads IR code sent from another MiP. See also SendDongleCode.
- SendDongleCode: Sends IR signals to another MiP. See also ReadDongleCode.
- SRSdemo: MiP made an appearance at the Seattle Robotics Society meeting on April 21st, 2018. This is a cloud-enabled modification of the original code adamgreen demonstrated at the meeting.
- Shake: Is someone shaking poor little MiP? This example shows you how to detect such rudeness and report it.
- SoftwareHardwareVersion: This example shows you how to peek under the covers and see what hardware / software is running inside MiP.
- PersistentMemory: Learn how to use the D1 mini's SPI flash file system (SPIFFS). This example writes a password to a file in SPIFFS and then reads in back. If the data that is read from the file matches what was written, MiP's chest LED will turn a violet color.
- Status: Detect changes in MiP's battery level or pose and report them.
- Stop: Danger! Danger! Stop MiP in his tracks before he gets itself into more trouble.
- TurnLeftRight: Tell MiP exactly how many degrees to turn and forget about it.
- Volume: MiP is too loud? Turn down the volume with this example.
- Weight: Detect weight changes in what MiP is carrying and report them.
- ZeroEEPROM: Write zeroes to each available byte in EEPROM. See also ReadWriteEEPROM.
These examples are designed to walk you through connecting MiP to the cloud.
- BareMinimumWiFi: This is the bare minimum sketch you need to get MiP connected to WiFi. There is a lot going on in this example but it's all necessary to get connected.
- TelnetDebug: Learn how to debug your WiFi sketches using a serial monitor and telnet.
- TimeWiFi: Turn MiP into a clock! After reading Network Time Protocol (NTP), MiP flashes the time, one digit at a time, using its head LEDs.
🔗 Quick Links: Main Repository • Report an Issue • Wiki Home
An open-source API for the WowWee MiP Robot. Licensed under Apache-2.0.
- MiP
- MiPChestLED
- MiPClapSettings
- MiPDebug
- MiPHardwareInfo
- MiPHeadLEDs
- MiPIRDongleCode
- MiPSoftwareVersion
- MiPStatus
- MiP_Battery
- MiP_ChestLED
- MiP_Clap
- MiP_EEPROM
- MiP_Gesture
- MiP_HeadLEDs
- MiP_Infrared
- MiP_Mode
- MiP_Motion
- MiP_Odometer
- MiP_Position
- MiP_Radar
- MiP_Serial
- MiP_Shake
- MiP_Sound
- MiP_Version
- MiP_Weight
- MiP_WiFi