Want some programming help? [close]

Seeeduino Nano Tutorial

Introduction

Seeed Studio offers an Arduino-compatible Nano board, Seeeduino Nano. It is like an Arduino Nano, but with some noticeable differences:

  • Seeeduino Nano currently costs $6.90 (cheap as $5.85 in bulk) and the Arduino Nano $22.00
  • Seeeduino Nano has a USB-C connector instead of Mini-USB
  • Seeeduino Nano comes with a Grove connector

Otherwise, it has the same Atmega328P procesor, size, and pins. You can use Nano breakout boards like the Grove Shield for Arduino Nano.

This guide will look at the board features, how to compile and upload sketches using the Arduino CLI, and how to use the Grove system modules.

Learn more from the Seeeduino Nano Wiki.

Board overview

  • ATMEGA328P-AU microcontroller processor
    • 16 MHz operating frequency
    • 5V operating voltage
    • 32KB program storage
    • 2KB SRAM
  • Male headers on all GPIO pins
    • 14 digital
    • 6 PWM
    • 8 Analog
  • USB-C power and serial port connector (CP210x drivers)
  • Male headers on top of board for SPI interface
  • 2x15 male headers for GPIO/power pins (Arduino Nano layout/footprint)
  • Grove I2C connector on top of board, next to SPI connector
  • Reset button
  • LEDs
    • Built in LED on pin D13 (orange)
    • Power indicator LED (blue)
    • Serial TX/RX LEDs (red/green)

The board operates on 5v, takes max 2 amps (7-12V) input and no more than 1 amp should be drawn from it.

You can view the Seeeduino Nano PCB schematics as an Eagle file from Seeed Studio's GitHub page. You can also read the ATmega328 datasheet.

For full details, refer to the Seeeduino Nano hardware overview

Initial impression

The USB-C connector is really convenient since my devices mostly use USB-C now. I didn't have to dig up a mini-USB from my closet.

The Grove I2C connector is a nice-to-have. You don't have to use it, so there is no harm in having it, but it does add some additional functionality.

All-in-all, it's a good ol' Nano with the convenient USB-C and the extra Grove I2C interface at about 1/3 of the cost of the Arduino Nano.

Setup

Before writing source code, compiling, and uploading sketches, you need to make sure you have all the proper tools and drivers installed and working. Let's look at what is needed.

USB driver support

When connecting the Seeeduino Nano to your PC with a USB-C, it should show up as Silicon Labs CP210x USB to UART Bridge.

You may need to install these drivers manually, since they don't come with Windows. A computer restart is most likely necessary.

https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

Using the Arduino the IDE

The Seeed Studio Wiki Seeeduino Nano Getting Started page explains how to setup the Arduino IDE for programming the Seeeduino Nano.

If you want to use the Arduino IDE, read through their guide. If you want to use the CLI, then continue on to the next section.

Using the Arduino CLI

First, install the Arduino CLI. To learn more, check out my Arduino CLI Tutorial. Otherwise, simply download the latest release and extract the standalone executable, optionally adding it to your PATH environment variable.

Verify the Arduino CLI is installed and running correctly:

arduino-cli version

Install Seeeduino board support by creating a file named arduino-cli.yaml in your current directory and then running arduino-cli core update-index.

Here is the contents of the arduino-.cli.yaml file:

# arduino-cli.yaml in your current directory
board_manager:
  additional_urls:
    - https://raw.githubusercontent.com/Seeed-Studio/Seeed_Platform/master/package_seeeduino_boards_index.json

Then pull all the boards by running:

arduino-cli core index-update

To verify the Seeed board support was installed, run board listall and ensure you see Seeeduino Nano listed.

arduino-cli board listall

The important value we need from here is the fully-qualified board name. The FQBN for the Seeeduino Nano is Seeeduino:avr:nano. We will need this later.

Sketches

Let's look at the steps needed to create a sketch, compile it for the Seeeduino Nano, and upload it. We'll also look at a couple troubleshooting tips for problems I ran in to.

Write the source code

To get familiar with the board, the first thing to do is just make sure you can compile and upload a program to the board.

This is the most minimal Arduino program you can write:

void setup() {}
void loop() {}

You can also use Arduino CLI to generate a template sketch for you:

arduino-cli sketch new MySketch

If you want to test the built-in LED (pin 13), you can use the blink example:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(250);
  digitalWrite(LED_BUILTIN, LOW);
  delay(100);
}

Compile a sketch

If code is in hello/hello.ino and we are outside of the hello directory, we can run:

# Code should reside in relative path: hello/hello.ino
arduino-cli compile --fqbn Seeeduino:avr:nano hello

Fix: lto1.exe: fatal error: bytecode stream generated with LTO version 4.1 instead of the expected 3.0 compilation terminated.

When compiling with certain Grove libraries, I ran in to an error like this:

lto1.exe: fatal error: bytecode stream generated with LTO version 4.1 instead of the expected 3.0 compilation terminated.

It compiled properly in the Arduino IDE, but failed in the CLI.

I was able to work around this by changing the FQBN from Seeeduino:avr:nano to arduino:avr:nano. I'm not sure what the implications of this are, but the programs

Upload a sketch

Determine the port/device name using mode in windows or dmesg in Linux/Mac. There are other ways as well. Refer to my tutorial How to Connect to Serial Console for more details on determining the port name.

In Windows the port is typically in the form like COM4 and in Linux/Mac /dev/tty* like /dev/ttyACM0.

Use the upload command on arduino-cli with the --port and --fqbn arguments. Then provide it the directory that contains the built binaries.

# Provide the directory name that contains the compiled
# `.elf` and `.hex` files. E.g. `hello/hello.Seeeduino.avr.nano.elf`
arduino-cli upload --port COM9 --fqbn Seeeduino:avr:nano hello

Fix: stk500_recv() and stk500_getsync() resp=0x2b errors

When uploading a sketch to the Seeeduino Nano, you may need to remove any attached devices. I kept running in to an error like this:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x2b

I was able to fix this unplugging all attached device and restarting the board. To be honest, I'm not 100% sure this was the fix though because after plugging the devices all back in it continue to work properly.

Use the Grove system

The Grove system is primarily distinguished by its proprietary connector that has an optional locking system, and the large number of modules that come with the Grove connector. Each module is well documented and comes with code examples.

For example, check out the:

It is very useful for quick prototyping because there is no soldering needed and no breadboards to deal with. You can re-use the same cables to swap out modules and daisy chain them all together.

The Grove modules also have very specific footprint sizes so that that modularly fit together when laid out physically. They even have little notches like puzzle pieces to line up just right. Read more about the size of Grove.

Many of the Grove devices use I2C to communicate allowing them to be daisy chained together. This makes it really easy to connect as many devices as you need, as long as the I2C addresses don't conflict.

Some devices are digital, analog, or UART though instead of I2C. Refer to the Grove Wiki for specific information on the pin standards. All modules, regardless of their programming interface, use the same 4-pin connector.

Connectors and cables

It looks like a JST-PH connect but it's not, it is a proprietary connector.

The connectors can come with or without buckles. The buckle is a clip that locks the connector in place to prevent it from being yanked out.

All of the Grove modules I bought came with cables that did not have buckles, but the package of cables I bought separately came with buckles.

The connectors on the boards all have buckles so they can be used with both cables that have buckles and cables without the buckle.

Grove Shield for Arduino Nano

There is a Grove Shield for Arduino Nano that allows you to plug in the Seeeduino Nano or any other Arduino Nano to expand the number of Grove connectors.

Without the shield, you can only be directly connect a single I2C Grove device to the one connector on the Nano. If is possible to build a cable splitter to allow you to attach many devices to the single connector even without the shield. The shield is incredibly convenient though.

The Nano shield does not just provide I2C connector though. It provides:

  • 1 I2C
  • 1 UART
  • 3 Analog (A0, A2, A6)
  • 3 Digital (D2, D4, D6)

In addition to the 8 Grove connectors, it also provides holes for soldering the 2x15 headers of the Nano to treat the whole board as a shield for something else.

When using a shield, you need to make sure you have a good power source. The computer's USB port is not usually as powerful as a wall plug. If some devices fail to work make sure you have good power source coming in.

Use Grove code libraries

Since there are so many devices and cod examples, you should search in the Grove Wiki and use the left menu to look under the following sections:

Those sections contain details for every Grove module. Each page contains:

  • Pictures
  • Documentation
  • Product links
  • Source code examples
  • Application ideas
  • Project tutorials

The steps for working with a module is generally like this:

  • Find the module you want to use.
  • Identify which pin it connects to. Analog 2? Digital 4? I2C?
  • Connect the module to the right spot. With the Seeeduino Nano, there is only a single I2C Grove connector on top of the board. With the Grove Shield for Arduino Nano that expands to 3 analog, 3 digital, 1 UART, and 1 more I2C.
  • Find the link to download the Arduino code library. This may be a link to a GitHub page where you navigate to the "Relases" section and download a zip. These often come with examples in addition to the library itself. Some modules may not have a library and only a code snippet you copy/paste from the web page. If it is a downloadable Arduino library ZIP, in the Arduino IDE you can import from Sketch -> Include Library -> Add ZIP library. This will import the library for use including the examples that show up in File -> Examples. If using the Arduino CLI, the default library path is %HOMEPATH%\Documents\Arduino\libraries. The library folder should reside there. You can see what libraries are available with arduino-cli lib list. You can search for Grove libraries to install with arduino-cli lib search grove but not every library will be available and they are not all official.

After following those steps, the library should be available to you when compiling. From here, try compiling and uploading any example sketches provided.

Make sure you connect the device to the right pin. For example if you are using the Nano Shield, and you plug in a device to slot D4 then you need to make sure the code example uses pin 4.

Conclusion

After reading this guide, you should understand how a Seeeduino Nano compares to the an Arduino Nano, what the Grove connector is and what makes it so powerful.

Additionally you should know how to program the Seeeduino Nano using the Arduino CLI.

References

Advertisement