Connecting to sources…

How to build Petoi Bittle X: the whole process

163 steps to build Petoi Bittle X, from buying parts, printing and assembly to software, calibration and training, with the bill of materials, shop links and the…

Bittle X US$319, Bittle US$289 (vendor page)

Buy parts

  • Prepare the NyBoard and servos

    Use a NyBoard customized Arduino board based on ATmega328P with up to 12 high-performance servos for the Bittle robot.

  • Choose optional expansion hardware

    Optional extensions include a sensor pack, an intelligent camera module, and Raspberry Pi, Nvidia Jetson Nano, or other AI co-processors connected by wired or wireless links.

Print and make

  • Download and Print the Stand

    Download the stand's STL file from the linked MakerWorld model, then print it at home, through an online printing service, or at a local maker space.

  • Print the wide feet

    Download the Wide Feet model from the linked STL directory and 3D-print wide feet for Bittle or Bittle X.

  • Print the fox head

    Download the Fox head model from the linked STL directory and 3D-print it for Bittle or Bittle X.

  • Print a playful bone

    Download the Bone model from the linked STL directory and 3D-print a bone for Bittle.

  • Print the Servo-Mounted Cat Head

    Download Don Patrick's model and 3D print the cat head with hollow eyes and a servo-powered rotatable head.

  • Print the Triceratops Head and Tail

    Download Michael W's models and 3D print the triceratops head and counterweight tail for the Petoi Bittle.

  • Download the STL files for each accessory

    The STL files and design resources for each accessory are located on the external links shared in that accessory's section.

  • Pick PLA as the default print material

    Material selection depends on the application and safety requirements: PLA is ideal for most educational applications, PETG offers a balance of strength and flexibility, and ABS is better for parts requiring durability and heat resistance.

  • Print accessories without owning a printer

    A 3D printer is not required: files can be sent to online printing services such as Shapeways or Printables, or printed at local maker spaces, libraries, community workshops and fab labs, or shared educational institution resources.

Assemble

  • Secure the Robot on the Stand

    Place the robot on the stand for assembly and code testing. The stand holds it securely and prevents unwanted movement, accidental falls, and damage during programming.

  • Install the wide feet

    Fit the printed wide feet to Bittle to increase surface contact, improve traction, and help it handle uneven terrain.

  • Replace the dog face

    Replace Bittle’s dog face with the printed Beetle Horn. Use the horn like an arm for pushing objects or friendly robot battles.

  • Swap in the fox head

    Replace Bittle’s head with the printed fox head. Remove it when you want to restore the dog character quickly.

  • Place the bone in Bittle’s mouth

    Position the printed bone in Bittle’s mouth for photos, demonstrations, and engaging student activities.

  • Install the Cat Head and Sensor

    Mount the cat head on a servo, fit an ultrasonic distance sensor in the hollow eyes, and connect it to the Bittle. Route the sensor wiring through the built-in gaps and accessible connections; either SG90 hobby servos or Petoi servos are compatible.

  • Fit the Dinosaur Head and Tail

    Fit the triceratops head to the existing servo while preserving servo rotation. Clip the counterweight tail onto the rear bar without extra hardware so the Bittle remains balanced.

  • Prepare the robot for calibration

    Follow the subpage instructions for the robot's mainboard. For Bittle X+Arm, install the short wire servo in the robotic arm's servo slot.

  • Install and align servo components

    For a robot built from a kit, install the servo-related components according to the calibration-pose picture. Ensure the upper leg is perpendicular to the torso and the lower leg is perpendicular to the upper leg; insert components directly into the servo output shaft without turning it.

  • Install the Construction Kit Screws

    After completing the joint calibration, install the center screws to fix the components and servo gears.

Software

  • Delete the WebSocketsServer library and restart Arduino IDE

    Go to ~/Documents/Arduino/libraries/, delete the "WebSocketsServer" folder, then restart Arduino IDE so only the "WebSockets" library remains.

  • Let Arduino IDE choose the library automatically

    The code will work with either library; Arduino IDE will use the first one it finds.

  • ESP8266 generates a unique SSID after upload

    After uploading, the ESP8266 generates a unique SSID in the format Petoi-AP[XXXX], where XXXX is a random 4-digit number.

  • SSID and random number are saved to EEPROM

    The SSID and random number are saved to EEPROM and persist across reboots.

  • WiFiManager creates a configuration portal when no credentials are saved

    If no saved WiFi credentials exist, WiFiManager will create a configuration portal with the generated SSID.

  • Change the WiFi Name

    Send `n[newName]`, such as `nLittleDog`, `nMyRobot`, or `nBittle`. The SSID becomes `[newName]-AP`, removing the random number.

  • Clear Saved WiFi Credentials

    Send `w!` to clear saved WiFi credentials. The device will show the configuration portal on the next restart.

  • Reset Saved WiFi Credentials

    Send `r` to clear saved WiFi credentials. The device will show the configuration portal on the next restart.

  • Erase All EEPROM Data

    Send `E` to clear all stored data, including the SSID and WiFi settings.

  • Use the Serial Monitor

    Open the Serial Monitor at 115200 baud, send any of the above commands, and restart the device for the changes to take effect.

  • Connect the Example Web Client

    Use the supplied HTML/JavaScript example to connect to `ws://192.168.4.1:81`. Enter a command and click Send; the client sends JSON containing `command` and `wait: 0`, displays received messages in `output`, and updates the status to Connected or Disconnected.

  • Send a Base64-Encoded Command

    Place `b64:QgoBDgERAX4=` in the `commands` array and send JSON with `type: "command"` and `taskId: "12345"`. The system detects the `b64:` prefix, decodes the Base64 data, and sends the raw bytes with the proper terminator; the example decodes to `[0x42, 0x0A, 0x01, 0x0E, 0x01, 0x11, 0x01, 0x7E]`.

  • Configure Intelligent Timeout Management

    Configure the web coding module using the OpenCatEsp32/PetoiWebBlock timeout configuration.

  • Add Task Completion Tracking

    Provide detailed progress tracking for commands with a taskId so web clients can monitor execution.

  • Send Immediate Acknowledgment

    Immediately return an acknowledgment response with type ack and the command name.

  • Record Task Completion Results

    After completion, return the taskId, completed status, and results array.

  • Handle Task Error Status

    When a task fails, return the taskId, error status, and error details such as timeout.

  • Clear the Serial Buffer

    Clear the serial buffer before sending commands so old data does not interfere.

  • Terminate by Command Type

    Automatically select and send the appropriate terminator for the command type.

  • Wait for Complete Robot Responses

    When collecting a response, wait for the robot to return a complete response.

  • Add Timeout Protection

    Use timeout protection to prevent indefinite waits for serial responses.

  • Optimize Serial Buffer Management

    Set the serial buffer management timeout to 40 ms.

  • Extend Movement Response Waiting

    Use an extended response waiting time for movement commands.

  • Optimize JSON Parsing

    Optimize JSON parsing with ArduinoJson 7.x.

  • Configure Smart Heartbeat

    Set the smart heartbeat mechanism timeout to 25 seconds.

  • Save Memory and Optimize Storage

    Place the global Base64 alphabet in PROGMEM to save RAM, and optimize string operations, buffer clearing, and settings storage.

  • Download Petoi Desktop App

    Download the latest Petoi Desktop App release for the computer you will use. The app supports Nybble and Bittle with NyBoard, and Bittle X with BiBoard.

  • Connect Mainboard With USB

    Connect the robot's mainboard to the computer with a USB cable. Follow the model-specific instructions on the subsequent sub-pages for your mainboard.

  • Open App and Select Options

    After connecting the USB uploader, open UI.exe on Windows or Petoi Desktop App on Mac. Select your Model and Language.

  • Start the Firmware Uploader

    Click the Firmware Uploader button in the Petoi Desktop App. The app then displays the serial-port prompt.

  • Follow Serial Port Prompt

    If no serial port or more than one serial port is detected, follow the prompts in the message box after clicking Firmware Uploader. Complete the prompts within 10 seconds so the app can automatically identify the connected serial port.

  • Select Serial Port Manually

    If unplugging and plugging the USB interface on the computer takes more than 10 seconds, the app enters manual serial-port selection mode. Click OK in the Warning box, refresh or select a port such as COM3, then click OK in Manual mode to open the Firmware Uploader interface.

  • Verify Replug Detection

    Once the Firmware Uploader interface is open, unplug and replug the USB cable on the computer side. The desktop app will automatically identify the serial port connected to the robot, such as COM5.

  • Choose firmware software version

    Select software version 2.0, which is the default. Version 1.0 is obsolete and should only be used with CodeCraft.

  • Select the matching board version

    Select NyBoard_V1_0, NyBoard_V1_1, NyBoard_V1_2, BiBoard_V0_1, BiBoard_V0_2, or BiBoard_V1_0. BiBoard_V0_1 and BiBoard_V0_2 are for Bittle X, while BiBoard_V1_0 is for Bittle X V2 only.

  • Choose product and operating mode

    Select Bittle, Nybble, or Bittle X, then choose Standard, RandomMind, Voice, Mind+, Camera, Ultrasonic, RandomMind_Ultrasonic, Light, Touch, PIR, Gesture, or IR distance. NyBoard supports all 12 modes; for BiBoard, upload only Standard mode and switch modes later with serial port commands.

  • Select the firmware serial port

    Use automatic detection or select the serial port manually. Identify the correct port by unplugging and replugging the USB socket on the computer side.

  • Upload and confirm firmware completion

    Upload the firmware and watch the status bar for the success or failure result. A successful upload displays the message window "Firmware upload complete!".

  • Inspect the upload failure log

    If the upload fails, inspect the displayed message box and the log file location shown in the images. When contacting support@petoi.com, attach the log file to the email.

  • Run the uploader from terminal

    If an OS compatibility issue prevents normal operation, run the app directly from the terminal.

Calibrate and test

  • Connect your phone or computer to the ESP8266 WiFi network

    Connect to the ESP8266's WiFi network from your phone or computer.

  • Open the captive portal or navigate to 192.168.4.1

    A captive portal should open automatically; otherwise navigate to http://192.168.4.1.

  • Select Configure WiFi and pick your home network

    Select "Configure WiFi" and choose your home WiFi network.

  • Enter the WiFi password and click Save

    Enter your WiFi password and click "Save".

  • Device restarts and connects to your WiFi network

    The device will restart and connect to your WiFi network.

  • Note the IP address shown in the Serial Monitor

    Note the IP address displayed in the Serial Monitor.

  • Generate the Default SSID

    On first boot, the system generates a random 4-digit number and uses the `Petoi-AP[XXXX]` format for the SSID. The number is saved to EEPROM and reused on subsequent boots.

  • Power on the robot

    Connect the battery to the mainboard. Long-press the battery button for more than 3 seconds to power on the robot.

  • Enter the calibration state

    After powering on the robot with the battery, use either of the two illustrated methods to enter the calibration state.

  • Set the zero calibration pose

    Rotate all servos to their zero angles, type ‘c’ in the serial monitor, and attach the prepared head, tail, and legs to the body. Position them generally perpendicular to their linked body frames as shown in the calibration pose.

  • Check the calibration direction

    Viewed from the robot body's left side, counter-clockwise rotation from a joint's zero state is positive. Viewed from the right side, positive and negative rotation directions are opposite.

  • Reset all joint offsets

    When prompted, answer `Y` to reset the joint offsets.

  • Calibrate the IMU

    Place the robot flat on a table and answer `Y`. After six long beeps, the robot reads the sensor data, saves the offsets, and beeps when calibration is complete.

  • Calibrate the joints

    Boot the robot with one side facing up to enter calibration mode, or perform joint calibration directly through the Serial Monitor.

  • Use the Calibration References

    Use the stand's calibration references as guides for precise robot setup and calibration.

Use it

  • Connect to the WebSocket

    Connect to the WebSocket server on port 81 of the ESP8266 at `ws://[ESP8266_IP]:81`.

  • Send a Task JSON Command

    Send a JSON object containing `type`, `taskId`, `commands`, and `timestamp`. The command sends `?` to the robot.

  • Send a Token JSON Command

    Send a JSON object containing `token` and `command`. The command sends `ksit` to the robot.

  • Send a Command-Only JSON Message

    Send a JSON object containing only `command`. The command sends `khi` to the robot.

  • Send a Plain Text Command

    Send the plain text `ksit` directly. The robot receives `ksit`.

  • Send a Base64 Command

    Send `b64:QgoBDgERAX4=`. It decodes to the binary music command `B 10 1 14 1 17 1~` and sends the raw bytes to the robot.

  • Send the rest position

    Send `d\n` to put the robot in its rest position.

  • Send the greetings command

    Send `khi\n` to make the robot perform its greeting.

  • Send the push-up command

    Send `kpu\n` to make the robot perform push-ups.

  • Send the walk forward command

    Send `kwkF\n` to make the robot walk forward.

  • Send the trot forward command

    Send `ktrF\n` to make the robot trot forward.

  • Send the sit command

    Send `ksit\n` to make the robot sit.

  • Turn on the gyro

    Send `g\n` to turn on the robot's gyro.

  • Turn off the gyro

    Send `G~` to turn off the robot's gyro.

  • Send indexed binary movement

    Send `I~` to perform indexed simultaneous binary movement.

  • Send indexed simultaneous movement

    Send `i0 90\n` to perform indexed simultaneous movement.

  • Control all joints binary

    Send `L~` to control all joints in binary mode.

  • Send indexed sequential movement

    Send `m1 45 0 45\n` to perform indexed sequential movement.

  • Query the joint angles

    Send `j\n` to query the robot's joint angles.

  • Read the gyro value

    Send `gu\n` to read the robot's gyro value.

  • Send Base64 music

    Send `b64:QgoBDgERAX4=`; the Base64 data decodes to `B 10 1 14 1 17 1~`.

  • Send a binary beep

    Send `B~` to run the binary beep command.

  • Send an ASCII beep

    Send `b12 8 14 8\n` to run the ASCII beep command.

  • Handle the connected event

    When the client connects, handle `WStype_CONNECTED`; the server sends a welcome message.

  • Handle the disconnected event

    Handle the `WStype_DISCONNECTED` event when the client disconnects.

  • Handle a heartbeat message

    Send `{"type":"heartbeat"}`; the system responds with a timestamp.

  • Clear the serial buffer first

    When handling a client text command, remove existing serial-buffer data before sending the command.

  • Parse JSON command formats

    Parse either `{"token":"k", "command":"sit"}` or `{"type":"command","taskId":"123","commands":["ksit"]}`.

  • Combine token and command

    Combine the token and command, then send `ksit` to the robot.

  • Decode a Base64 command

    Decode commands prefixed with `b64:` to handle binary data such as music commands.

  • Add the correct terminator

    Uppercase commands A-Z get `~`, while lowercase commands get `\n`, such as `G~`, `i0 90\n`, and `m1 45\n`.

  • Send immediate acknowledgment

    Immediately return the acknowledgment `{"type":"ack","command":"ksit"}` after sending the command.

  • Configure command timeouts

    Movement, complex skill, music or binary command, and heartbeat timeouts are 30 seconds, 30 seconds, 30 seconds, and 25 seconds respectively; sensor readings and simple commands time out after 5 seconds.

  • Wait for movement confirmation

    For movement commands, wait until token confirmation is received before detecting a complete response.

  • Return a task response

    Return `{"taskId":"123","status":"completed","results":["robot_reply"]}` when a task command completes.

  • Return a regular response

    Regular commands return `{"type":"response","data":"robot_reply"}`; a timeout returns a task error or `{"type":"timeout","command":"ksit"}`.

  • Open the Status Page

    Access the WebSocket server at the root path `/` to view the status page.

  • Read JSON Status Information

    Access `/status` to retrieve status information in JSON format.

  • Control and exit the robot

    After the script starts, enter serial port commands in Terminal to control Nybble or Bittle; type quit or q to exit.

  • Write a behavior command list

    In testSchedule, the kbalance command makes Bittle stand normally; the number in the list indicates the delay in seconds after the command finishes. You can also refer to the stepUpSchedule list in stepup.py and write a behavior list according to your needs.

Common problems

  • Firmware exceeds onboard storage and memory, causing compilation failure #2 #65
  • Main firmware lacks sensor output and cannot use gyro with ultrasonic sensors together #77 #93
  • Missing dependencies, camera example errors, and lint violations break builds #5 #38 #41
  • Zero-position storage is incorrect and calibration may divide by zero #3 #12
  • Serial ports and resource paths are misdetected on Linux and Raspberry Pi #16 #70 #88
  • Serial commands are sent, but the robot does not execute the requested motion #19
  • Bluetooth failures or firmware updates block robot programming and control #42 #64 #67
  • Apps crash on Apple Silicon while voice and mobile sessions lose connectivity #31 #47 #62

Datasets

Parts

  • Box contents not listed on the page checked; Arduino-based controller

Tools

  • Not stated

Skills

  • C++, Python or block coding

Software

  • OpenCat

Documents