-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the MiP_ESP8266_Library wiki!
Here you will find all documentation for the MiP_ESP8266_Library. This is a guide to install the required hardware and software and describe all function calls in the API. Functions calls are organized into 17 groups identified in the table below and explained in separate pages listed to the right. Below are links to various examples which demonstrate how to use each function in the library.
Table of contents
- 4-pin ZH JST connector.
- The Wemos D1 mini or a compatible board.
- Arduino IDE.
- The esp8266 Arduino library.
- JoaoLopes' RemoteDebug library.
- Python - The guide provided by esp8266 will walk you through the process of installing Python and performing over-the-air (OTA) updates.
MiP is a unique robot in that it must expend energy just to stay upright. This unique quality can at times make it difficult to program and debug, especially while it's moving around. With this project enabling MiP to connect to the cloud, printing informational and error messages to the serial port using Serial.print()
and Serial.println()are not supported. Instead, debugging MiP is enabled using JoaoLopesF's [RemoteDebug](https://github.com/JoaoLopesF/RemoteDebug) library which in turn has the limitation of only being able to print messages from the Arduino
loop()` function.
There are a few excellent guides available on opening MiP and tapping its UART port.
- SparkFun's Hacking the MiP - No need to create a hole in MiP's body (step 6). The D1 mini will fit entirely inside MiP's otherwise empty head once it's connected.
- Macetech's Quick tear-down guide.
- Adamgreen's post, What's inside my MiP.
MiP's operating voltage ranges from 4.8 volts using the recharge kit or rechargeable AAA batteries up to 6 volts using standard alkaline AAA batteries. The D1 mini operates at 3.3 volts. Fortunately, there is an ME6211 onboard that can regulate voltage from a rated maximum of 6 volts down to the 3.3 volts the D1 mini requires. If you are concerned that 6 volts is too high, consider placing a power resistor between the MiP and the D1 mini. I use NiMh rechargeable batteries which keep the voltage at a safe maximum of 4.8 volts.
Using the 4-pin JST connector, connect the MiP and D1 mini using the following table. Be sure to note that MiP's transmit line needs to be connected to the D1 mini's receive line and vice versa.
MiP UART | D1 mini or compatible |
---|---|
GND | GND |
RX | TX |
TX | RX |
VCC6V | 5V |
Until OTA updates are enabled, leave the D1 mini outside MiP's case. This is done for two reasons: First, we need to program the D1 mini using the USB port and second, the RX and TX lines need to be disconnected each time the D1 mini is programmed otherwise the Arduino IDE can't find the board to program it. During development I leave an arm off and pass the JST cable through the arm hole. Once OTA updates are enabled you can tuck the D1 mini into MiP's head, but be careful! OTA support needs to be included with every sketch you upload to MiP. The first time you forget to include the OTA code, you'll need to open MiP again and re-program the D1 mini using it's USB connector.
Now that the hardware is connected to MiP, connect the D1 mini to your development workstation using a micro USB cable. 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. Remember, before sending this sketch to the D1 mini, disconnect the RX/TX pair between the D1 mini and MiP. Launch the serial monitor prior to programming the D1 mini 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);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.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 not a cloud-connected robot. Now it's time to start reviewing the examples provided below and reading the documentation for the API. Good luck!
- ChestLED: Take control of the RGB LED in the chest of the MiP.
- Clap: Send descriptive messages to the Arduino IDE about each clap event deteced by the MiP robot.
- ContinuousDrive: You want to control the motion of the 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 the MiP robot exactly how far to travel and forget about it.
- DriveForwardBackward: Tell the MiP robot how long to drive forward/backward and forget about it.
- EnableGameMode: Cycle through each of the game modes available.
- EnableMiPDetectionMode: Allow your 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 gesture to your MiP robot. Send descriptive messages to the Arduio IDE about each gesture event detected.
- GestureRadarMode: Want to learn more about how to enable/disable IR based gesture and radar measurements? Check out this example.
-
GetUp: If your MiP robot falls down, learn how to have him try getting back up on his
feetwheels. - HeadLEDs: Take control of the 4 individual eye LEDs on the MiP robot's head.
- Odometer: How far has your MiP robot been traveling around your personal robot laboratory? This example shows you how to find out and reset its measurement.
- PlaySound: Learn how to get the MiP robot vocalizing under your control!
- Radar: Is there anything in front of your MiP robot? This example sends descriptive text to the Arduino IDE 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.
- ReadIRDongleCode: Reads IR signals sent from another MiP. See also SendIRDongleCode.
- SendIRDongleCode: Sends IR signals to another MiP. See also ReadIRDongleCode.
- SRSdemo: MiP made an appearance at the Seattle Robotics Society meeting on April 21st, 2018. This is a cloud-enabled modification of the code 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 your MiP robot.
- Status: Detect changes in the MiP robot's battery level or pose and report them to the Arduino IDE.
- Stop: Danger! Danger! MiP Robot! Stop your MiP robot in its tracks before it gets itself into more trouble.
- TurnLeftRight: Tell the MiP robot exactly how many degrees to turn and forget about it.
- Volume: Your MiP robot is too loud? Turn down the volume with this example.
- Weight: Detect weight changes in what the MiP is carrying and report them to the Arduino IDE.
- ZeroEeprom: Write zeroes to each available byte in EEPROM. See also ReadWriteEeprom.