Arduino and Teensy libraries
Back to Basebot
Installation of Arduino and Teensy support
This is probably not needed if you intend to use MS Visual Studio.
Arduino (version 2.xx)
- Install the newest Arduino - see https://www.arduino.cc/en/software.
Add Teensy board support
- Add the Teensy hardware support - see https://www.pjrc.com/teensy/td_download.html, including
- Add https://www.pjrc.com/teensy/package_teensy_index.json to the file->preferences
- In the boards manager (Tools->Boards->Boards manager), search for Teensy and install support for Teensy boards.
Add libraries
- In the Library manager (Tools->Manage libraries), search for "MPU9250_asukiaaa" and "Adafruit GFX library" and install both, including dependencies. These are used to interface the IMU and support for the small display.
Board select
Select the Teensy 4.1 board (tool->board->Teensy->4.1).
Select the port the robot is connected to - it is easier to connect it first.
Arduino command line interface
See https://docs.arduino.cc/arduino-cli/
Install Arduino CLI
Get the install script and let it install arduino-cli into the directory ~/bin. It will detect the download platform and install an appropriate version.
cd curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh cd bin pwd
Add this directory to the PATH.
nano ~/.bashrc
Add at the end (assuming your login name is local)
export PATH=$PATH:/home/local/bin
Add Teensy boards
Make a configuration file (in a hidden file called ~/.arduino15/arduino-cli.yaml).
arduino-cli config init
Copy the URL for Teensyduino https://www.pjrc.com/teensy/package_teensy_index.json and add it to the configuration file.
nano ~/.arduino15/arduino-cli.yaml
Make it look like this:
board_manager: additional_urls: ["https://www.pjrc.com/teensy/package_teensy_index.json"]
After this, update the index
arduino-cli core update-index
Install Teensy support
Find the install name of the board type to install
$ arduino-cli core search teensy ID Version Name teensy:avr 1.59.0 Teensy (for Arduino IDE 2.0.4 or later)
Then, install and configure the Teensy support
arduino-cli core install teensy:avr
Install libraries
Robobot need (especially) these libraries.
- Adafruit GFX Library
- MPU9250_asukiaaa
If the exact name is not known, then search, e.g.:
arduino-cli lib search name:"Adafruit GFX Library"
Install
arduino-cli lib install "Adafruit GFX Library" arduino-cli lib install "MPU9250_asukiaaa"
Compile
With the board connected, find the board type name:
$ Arduino-cli board list Port Protocol Type Board Name FQBN Core /dev/ttyACM0 serial Serial Port (USB) Unknown /dev/ttyAMA10 serial Serial Port Unknown usb3/3-2 teensy Teensy Ports Teensy 4.1 teensy:avr:teensy41 teensy:avr
In this case, the key name is "teensy:avr:teensy41"
Command line compile the teensy_firmware_8.ino in the directory ~/svn/robobot/teensy_firmware_8
cd ~/svn/robobot/teensy_firmware_8 arduino-cli compile --fqbn teensy:avr:teensy41 --build-path build ../teensy_firmware_8
The compile for Teensy 4.1 is copied into a script called compile (remember to chmod +x compile).
$ cat compile #!/bin/bash arduino-cli compile --fqbn teensy:avr:teensy41 --build-path build ../teensy_firmware_8
It takes a while to compile and should have a few warnings only.
The compiled code is in the build directory.
Upload
The arduino-cli upload for Teensy requires a graphical interface, but there is a command line alternative.
Install command line uploader
cd cd git git clone https://github.com/PaulStoffregen/teensy_loader_cli.git cd teensy_loader_cli make
This makes the executable binary teensy_loader_cli. This compiled file can be copied to /usr/local/bin for easy access.
sudo cp ~/git/teensy_loader_cli /usr/local/bin
The upload
The hex file is in the build directory.
cd ~/svn/robobot/teensy_firmware_8/build teensy_loader_cli -v -w --mcu=TEENSY41 teensy_firmware_8.ino.hex