Skip to content

RobotZero Setup Tutorial

TinyCircuits RobotZero product photo

This tutorial covers the basic setup for the RobotZero, including all the software you will need and how to upload your first program with it.


Description

RobotZero is one of TinyCircuits' second-generation processor boards, adding performance upgrades and additional features to the original TinyDuino including (4) Wireling connectors, (2) motor ports, (4) servo ports, and a built-in 9-Axis sensor. RobotZero is based on the Atmel SAMD21 32-bit ARM Cortex M0+ processor (the same one used in the Arduino Zero) and provides a USB connectivity port, power management and battery charger in a single 30x30mm board.We've kept our standard TinyShield expansion port, allowing for use with our current shields.

Main Features:

  • Atmel SAMD21 processor (same as is used on the Arduino Zero)
  • More memory compared to TinyDuino (both Flash and RAM)
  • Power switch, regulator, lithium battery management on board
  • Precision clock crystal and Real-Time Clock hardware built-in, low power standby
  • Populated 9-Axis Sensor: 3D accelerometer, 3D gyroscope, and 3D magnetometer
  • (4) Wireling Ports
  • (2) Motor Ports
  • (4) Servo Ports
  • Up to 10 ADC inputs, up to 10 PWM outputs, up to 16 external interrupts
Technical Details
  • Atmel ATSAMD21G18A 32 bit ARM processor at 48MHz, Arduino Zero compatible
  • 32.728KHz clock crystal, RTC hardware built-in with standby mode down to 0.2mA
  • Expandable with our full lineup of stackable TinyShield boards
  • Ultra-compact size and weight (smaller than a US Quarter!)
    • 30mm x 30mm (1.18 inches x 1.18 inches)
    • Max Height: 3.2mm (0.13 inches)
    • Ultra-thin 0.61mm (0.024 inches) PCB
    • Weight: 3 grams (0.11 ounces)
  • Atmel 32-bit ATSAMD21G18A ARM Microcontroller
    • ARM Cortex M0
    • 256KB Flash, 32KB SRAM
    • 12-bit ADC, 10-bit DAC
    • Default Clock speed: 48MHz
    • TI DRV8834 H-bridge Stepper or DC Motor Driver
      • This board features (2) of these motor drivers for driving two separate stepper motors, or DC motors
      • Output Current 1.5-A Continuous, 2.2-A Peak per H-Bridge
      • Wide Power Supply Voltage Range: 2.5 V to 10.8 V
    • TI PCA9544A Low Voltage 4-Channel I2C Multiplexer
      • Channel Selection via I2C Bus
      • 0 to 400kHz Clock Frequency
      • Low Standby Current
      • Four Active-Low Interrupt Inputs
      • Active-Low Interrupt Output
    • ST LSM9DS1 9-Axis 3D accelerometer, 3D gyroscope, 3D magnetometer
      • 3 acceleration channels, 3 angular rate channels, 3 magnetic field channels
      • ±2 / ±4 / ±8 / ±16 g linear acceleration full scale
      • ±4/±8/±12/±16 gauss magnetic full scale
      • ±245/±500/±2000 dps angular rate full scale
      • 16-bit data output
      • Embedded temperature sensor
      • "Always-on" eco power mode down to 1.9mA
      • Embedded FIFO
      • Position and motion detection functions
      • Click/double-click recognition
    • Atmel ATtiny841 8-bit Microcontroller
      • 8 KB Flash Memory
      • 512 Bytes SRAM and EEPROM
      • Voltage: 1.7V - 5.5V
    • 2.7V – 5.5V operating voltage with built-in 3.3V regulator
    • Current: 20mA
    • 20 IO pins available- up to 10 ADC inputs or up to 10 PWM outputs
    • Arduino compatible bootloader with CDC Serial port, plug and play on OSX and Windows 10

    Notes

    • To send text to the Arduino IDE Serial Monitor, use the SerialUSB object instead of Serial
    • If you were able to upload a sketch to the RobotZero and now it does not respond, you may need to force this into bootloader mode. To do this, plug a USB cable into the RobotZero and your computer, and power off the RobotZero using the slide switch. Then press and hold the button on the bottom of the RobotZero while sliding the switch to the ON position. Select the new available COM# Port under the Tools tab, then try uploading your program to the RobotZero and it should work. You may need to try this several times if it does not work the first time.

    Materials

    Hardware

    For the bonus example:

    Software


    These are the steps this tutorial will cover to help you start using the RobotZero:

    • Step 1. Configuring the Arduino IDE, so you have somewhere to write software that understands how to interface with your hardware
    • Step 2. Connecting to the RobotZero board. This should just be a simple connection with a USB cable, and a few selections made in the Arduino IDE to ensure you are programming the correct board-type through the correct port of your computer.
    • Step 3. Uploading your first program to the RobotZero. How exciting!
    • Troubleshooting/Bootloader mode: Reference this at any point throughout the tutorial if you are having issues. If this doesn't resolve your problems, you can look through past Forum posts, create your own, or email us for help at info@tinycircuits.com

    Step 1: Configure Arduino Software IDE

    • Download and install the latest Arduino Software (IDE) from the Arduino website. (On Windows click Yes/Install when it asks 'Do you want to install this device driver/software?' You can also select the checkbox 'Always trust Arduino')

    • Open Arduino IDE and go to File->Preferences (Windows) or Arduino->Preferences (Mac OSX).

    • Copy and paste the following URL to the box that says 'Additional Boards Manager URLs': http://files.tinycircuits.com/ArduinoBoards/package_tinycircuits_index.json
    • Click 'OK'

    • Go to Tools->Board ->Boards Manager...

    • Select and 'Install' Arduino SAMD Boards (32-bits ARM Cortex-M0+). This may take a few minutes.

    • On the same Board Manager page, scroll down to select and 'Install' TinyCircuits SAMD Boards.

    After those two packages are downloaded, you just need the Wireling Library. If you have not already downloaded the library from under the the Software section above, do that now and save the library to the proper folder. For some options on installing into a library, check out our Library Installation Help Page.


    Step 2: Connect to RobotZero

    • Connect the RobotZero to your computer using the microUSB cable. At this point, make sure your RobotZero's power switch is turned to ON.
    • Mac and Windows(10 and above) users can skip to the next step. Windows 7/8 users click here for device driver installation instructions before proceeding any further. (This link leads to drivers for the TinyScreen+) This driver is necessary for your computer to be able to communicate with and program the RobotZero.
    • In the Arduino IDE, go to Tools->Board and scroll down to select RobotZero.

    • Go to Tools->Port and select the port labeled TinyScreen+. The naming convention will usually look like:
    • Mac: “/dev/cu.usbmodemXXXX (TinyScreen+)”
    • Windows: “COMXX (TinyScreen+)”.

    (The TinyScreen+ and RobotZero share hardware similarities - the SAMD21 processor, so it makes sense that the port will be labeled 'TinyScreen+')*

    • Note: Some USB cables are used only for transferring power and not data signals. If your computer is not recognizing that a device is plugged in, you may need to try a different USB cable. If you've purchased a Micro USB Cable from our online store, you won't have to worry about this issue.
    • If you are having issues determining which port the RobotZero is connected to, you can unplug the microUSB cable and plug it back in to note which COM## disappears and reappears during this process.

    Now you are ready to upload your very first program to the RobotZero!


    Step 3: Upload Your First Program

    The example program included with the Wireling library detects Wirelings attached to it's ports. You can open the program from the Arduino IDE under File/Examples/Wireling/WirelingScanner.

    Or you can open it from your Folder Explorer under Documents/Arduino/libraries/Wireling/examples/WirelingScanner and double-click it to open in the Arduino IDE.

    Wireling Program
    //-------------------------------------------------------------------------------
    //  TinyCircuits Wireling Basic Example
    //  Last Updated 4 December 2019
    //
    //  This example shows how to scan for I2C devices on each port as well as print
    //  out the state of the analog pin on each port.
    //
    //  Written by Ben Rose for TinyCircuits, https://TinyCircuits.com
    //-------------------------------------------------------------------------------
    
    #include <Wire.h>
    #include <Wireling.h>
    
    #if defined (ARDUINO_ARCH_AVR)
    #define SerialMonitorInterface Serial
    #elif defined(ARDUINO_ARCH_SAMD)
    #define SerialMonitorInterface SerialUSB
    #endif
    
    void setup() {
      Wire.begin();
      Wireling.begin();
      SerialMonitorInterface.begin(9600);
    }
    
    void loop() {
      for (byte port = 0; port < 4; port++) {
        Wireling.selectPort(port);
        SerialMonitorInterface.print("Port ");
        SerialMonitorInterface.print(port);
        SerialMonitorInterface.print(": ");
        int nDevices = 0;
        for (byte I2Caddress = 1; I2Caddress < 127; I2Caddress++ )
        {
          if (I2Caddress != 0x68 && I2Caddress != 0x70) { // Ignore the multiplexer and RTC address
    #if defined(_VARIANT_ROBOTZERO_)
            // On RobotZero, ignore the built in IMU, motor current setting digital potentiometer, and servo driver MCU
            if (I2Caddress != 0x1C && I2Caddress != 0x2F && I2Caddress != 0x6A) {
    #endif
              Wire.beginTransmission(I2Caddress);
              if (!Wire.endTransmission()) { // This means that a device has acknowledged the transmission
                SerialMonitorInterface.print(" 0x");
                if (I2Caddress < 16) {
                  SerialMonitorInterface.print("0");
                }
                SerialMonitorInterface.print(I2Caddress, HEX);
                nDevices++;
              }
    #if defined(_VARIANT_ROBOTZERO_)
            }
    #endif
          }
        }
        if (nDevices == 0) {
          SerialMonitorInterface.print("None\t");
        } else {
          SerialMonitorInterface.print("\t");
        }
        int portAnalogPin = A0 + port;
        if (digitalRead(portAnalogPin)) {
          SerialMonitorInterface.print("High");
        } else {
          SerialMonitorInterface.print("Low");
        }
        SerialMonitorInterface.print("\t");
      }
      SerialMonitorInterface.println();
    
    }
    

    This program works best if you have Wirelings to test with, as the Serial Monitor when opened will report the LOW/HIGH status, as well as the I²C address of any device on a given port (0-3). NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.

    If you ever encounter issues later on with Wirelings, you can come back to this program to make sure you are still receiving some type of signal from the port and device you are using.

    Now you are ready to build any Wireling project!


    BONUS 1: Motors, Servos, on-board 9-Axis IMU, and Wireling Sensors!

    The RobotZero includes motor drivers, a servo driver, a 9-Axis sensor, and the capability to use Wirelings all in ONE board, so here's a short example that shows you how to utilize all of that functionality! Be sure to pay attention to the comments for specific insights.

    For this program, you will need to have a few libraries downloaded:

    • The Wireling library (included above)
    • The sketch includes some code for using a Color Sensor Wireling on port 0, so you will need the TCS34725 Arduino library.
    • Motor Driver library: Necessary for the 3-pin Servos
    • The rest of the files you need are included in the zip file of the sketch (so make sure you can see those files):
    • LSM8DS1.ino: This is for the 9-Axis Sensor
    • stepper.ino: For the 4-pin motors

    Download the Basic Example including the additional files here:

    RobotZero Motors, IMU, Wireling Sketch

    RobotZero Basic Program
    /**********************************************************************
     * RobotZero Peripheral Basics
     * This program illustrates the abilities of the RobotZero processor
     * board by spinning any attached motors or servos, while reading the
     * accelerometer data of the onboard 9-Axis sensor and Color
     * Sensor data for a Color Sensor Wireling attached to port 0.
     *
     * NOTES:
     *   - Serial Monitor must be open for program to run.
     *   - Battery must be plugged in to power motors.
     *
     * Hardware by: TinyCircuits
     * Written by: Ben Rose & Laveréna Wienclaw for TinyCircuits
     *
     * Initialized: June 2019
     * Last modified: Jan 2020
     **********************************************************************/
    
    #include <Wire.h>
    #include <MotorDriver.h> // Download latest here: https://github.com/TinyCircuits/TinyCircuits-TinyShield_Motor_Library/archive/master.zip
    #include <Wireling.h>
    #include "Adafruit_TCS34725.h"  // The library used for the Color Sensor Wireling
    
    MotorDriver servo(15);// Value passed is the address- RobotZero is always address 15
    #define SerialMonitorInterface SerialUSB // for SAMD21 processors
    int aX, aY, aZ, gX, gY, gZ, mX, mY, mZ, tempF; // 9-Axis variables
    uint16_t r, g, b, c, colorTemp, lux; // Color Sensor Wireling variables
    
    Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);
    
    void setup() {
      // Enable and Power Wireling
      Wireling.begin();
      Wireling.selectPort(0);
    
      SerialMonitorInterface.begin(9600);
      while (!SerialMonitorInterface); // Halt everything until Serial Monitor is opened
      Wire.begin();
    
      // Initialize stepper motor driver
      stepperInit();
    
      // Initialize 9-Axis Sensor
      IMUInit();
      delay(100);
    
      // Initialize servo driver
      if(servo.begin(20000)){
        while(1);
        SerialMonitorInterface.println("Servo driver not detected!");
      }
    
      // Initialize Color Sensor Wireling
      if (tcs.begin()) {
        SerialMonitorInterface.println("Found sensor");
      } else {
        SerialMonitorInterface.println("No TCS34725 found ... check your connections");
        while (1);
      }
    }
    
    void loop() {
      tcs.setInterrupt(false); // Turn onboard Color Sensor Wireling LEDs off
    
      // Motors go forward
      goForward();
    
      // Command all Servos to rotate
      servo.writeCommand(COMMAND_SERVO_1,1000);
      servo.writeCommand(COMMAND_SERVO_2,1000);
      servo.writeCommand(COMMAND_SERVO_3,1000);
      servo.writeCommand(COMMAND_SERVO_4,1000);
      delay(1000); //delay to allow motors and servos to move
    
      tcs.setInterrupt(true); // Turn onboard Color Sensor Wireling LEDs on
    
      SerialMonitorInterface.println(" ");
      tcs.getRawData(&r, &g, &b, &c);
      colorTemp = tcs.calculateColorTemperature(r, g, b);
      lux = tcs.calculateLux(r, g, b);
    
      SerialMonitorInterface.print("Color Temp: "); SerialMonitorInterface.print(colorTemp); SerialMonitorInterface.print(" K, ");
      SerialMonitorInterface.print("Lux: "); SerialMonitorInterface.print(lux, DEC); SerialMonitorInterface.print(", ");
      SerialMonitorInterface.print("R: "); SerialMonitorInterface.print(r, DEC); SerialMonitorInterface.print(", ");
      SerialMonitorInterface.print("G: "); SerialMonitorInterface.print(g, DEC); SerialMonitorInterface.print(", ");
      SerialMonitorInterface.print("B: "); SerialMonitorInterface.print(b); SerialMonitorInterface.print(", ");
      SerialMonitorInterface.print("Clr: "); SerialMonitorInterface.print(c, DEC);
      SerialMonitorInterface.println(" ");
    
      stopMotors();
      servo.writeCommand(COMMAND_SERVO_1,2000);
      servo.writeCommand(COMMAND_SERVO_2,2000);
      servo.writeCommand(COMMAND_SERVO_3,2000);
      servo.writeCommand(COMMAND_SERVO_4,2000);
      delay(1000);
    
      // Read and print 9-Axis Accelerometer and Temperature data
      //(gyro and magentometer data can also be printed using the gX, gY, gZ, mX, mY, and mZ variables)
      IMURead();
      SerialMonitorInterface.print("X: ");
      SerialMonitorInterface.print(aX);
      SerialMonitorInterface.print(" Y: ");
      SerialMonitorInterface.print(aY);
      SerialMonitorInterface.print(" Z: ");
      SerialMonitorInterface.print(aZ);
      SerialMonitorInterface.print(" Temp: ");
      SerialMonitorInterface.println(tempF);
    }
    
    void goForward(){
      setMotorCurrent(100);
      setMotor(1, 10);
      setMotor(2, -10);
    }
    
    void stopMotors(){
      setMotorCurrent(1);
      setMotor(1, 0);
      setMotor(2, 0);
    }
    

    Be sure to plug in the battery, it is necessary in order to power the motors and servos!

    Stack some TinyShields, add some Wirelings, and build something fun!


    BONUS 2: Using DC Motors with the RobotZero (Rev 3 Modification & Rev 4 Code)

    Rev 4

    You can switch between using Stepper motors and DC motors on the RobotZero processor board. The DC Motor program allows you to switch between the Stepper motors or DC motors using the Boolean variable useDcMotors:

    RobotZero DC Motor & Stepper Motor Example
    #include <Wire.h>
    #include <Wireling.h>
    
    #if defined (ARDUINO_ARCH_AVR)
    #define SerialMonitorInterface Serial
    #elif defined(ARDUINO_ARCH_SAMD)
    #define SerialMonitorInterface SerialUSB
    #endif
    
    int maxPWM = 10000;
    int steps = 300;
    int stepSize = maxPWM / steps;
    
    bool useDcMotors = true;
    
    void setup() {
      SerialMonitorInterface.begin(115200);
      Wire.begin();
      if (useDcMotors) {
        DcMotorInit(maxPWM);
      } else {
        stepperInit();
      }
      delay(100);
      setMotorCurrent(100);
    }
    
    void loop() {
      if (useDcMotors) {
        DcMotorLoop();
      } else {
        stepperLoop();
      }
    }
    
    void stepperLoop() {
      setMotor(1, 10, 1000);
      setMotor(2, -10, 1000);
      while (isMotorSpinning());
      setMotor(1, -10, 1000);
      setMotor(2, 10, 1000);
      while (isMotorSpinning());
    }
    
    void DcMotorLoop() {
      int i;
      for (i = -maxPWM; i < maxPWM; i += stepSize) {
        delay(10);
        setDCMotor(1, i);
        setDCMotor(2, i);
      }
      for (i = maxPWM; i > -maxPWM; i -= stepSize) {
        delay(10);
        setDCMotor(1, i);
        setDCMotor(2, i);
      };
    }
    

    Download the zip file for controlling DC Motors on the RobotZero

    To use DC motors, plug them into the two pins closest in the stepper motor connectors to the USB connector and battery connector. There is a picture in the Rev 3 section with red boxes around the pins to use.

    To modify a DC motor without a JST-SH connector, you can solder a JST-SH Connector Cable to make the motor compatible with the RobotZero


    Rev 3

    The following instructions detail a way to modify a RobotZero Rev3 board to enable DC motor use - this mod is built into Rev4 boards and requires no further modification. If you are not sure what Rev# you have, look at the writing on your RobotZero board to find out.

    If you prefer using DC motors instead of Stepper motors, you can cut some traces on the Rev3 board in order to allow DC Motor control. The following image shows in red where the two traces are located:

    You can make these cuts with a sharp hobby/X-ACTO knife. It is recommended that you use a magnifying glass to ensure clean cuts are made. and no other traces on the board are damaged. After these cuts, it would be difficult to solder the traces back together even with the proper equipment - so you would not be able to use stepper motors after this modification. This is a good solution if you only care about DC motors.

    For using the DC motors after the modification, use the below image showing which pins to use on the RobotZero (the two pins closest to the battery port with power on the left, and ground on the right in respect to the attached image) and an example program with a new DC motor function to control DC motors.

    To test your board modification and DC motors with the RobotZero, use the RobotZero DC Motor Example, and don't forget to plug in a battery! The motors rely on a separate power source that is provided by a battery being plugged in.


    Downloads


    Contact Us

    If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

    Thanks for making with us!