Compile and Upload Arduino Sketch with PlatformIO in Arch Linux running on PC, Raspberry Pi 2 and 3

Posted by:

Preamble

PlatformIO is a python tool to build and upload sketches for multiple Hardware Platforms, at the moment of writing these are Arduino/AVR based boards. This is the only tool working with Raspberry Pi running Arch Linux so far, and I have been searching for some tool like this for a long time.

NB: The over-bearing minion is there because every time my little one sees it, she giggles.

platformio-logo.png

Installation

Install virtualenv first, detailed instruction here.

Its recommended to use a virtual environment because platformio uses python2 because its based on SCons which does not support python3.

You may need to install PlatformIO with python installer script for it to work.

Usage

  1. Ativate virtualenv

  2. Install platforms

  3. Start with a empty directory

  4. Search for the board types using `platformio boards` command if needed.

  5. Modify platformio.ini file if needed.

  6. Put your source code *.pde or *.ino files to src directory.
  7. Link rest of library files in lib directory, link the whole directory instead of individual .cpp and .h files.

  8. Change working directory to the project’s root where is located Project Configuration File (platformio.ini) and use these commands:

    Output from platformio run:

    Output for upload:

  9. Project Structure after processing

  10. Deactivate virtualenv

Work with ArduinoJson

ArduinoJson works can be installed from Arduino IDE library manager. Issue tracker here.

The easy way

The hard way

  1. Install using the library without Arduino with instruction adapted from official wiki.
  2. Step 1: Download source code into platform project lib folder:

  3. Generate the Makefile for your environment

  4. Step 3: Build

  5. delete test folder, alternatively install with zip package.
  6. update library

  7. all set for platformio compile.

Notes

  1. If you are running Archlinux and running into this error: libncurses.so.5: cannot open shared object file, refer here.

  2. For the following error: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory It seems libreadline.so.7 is backward compatible enough for most utilities to keep working after running:

  3. Works with Raspberry Pi running Arch Linux.
  4. Does not work without virtualenv, Scons error – got to do with the python3 issue.
  5. Does not work with Arduino IDE running.
  6. I often ran into this problem: the serial port will be disabled after a while, i.e. – disappeared from ls /dev/ and Arduino IDE port listing. My working solution is to unplug and then plug it into another USB port.
0
  Related Posts

Add a Comment