Arduino has an official CLI app now



  • https://github.com/arduino/arduino-cli

    Has anyone tried using it to create a MySensors device?

    To try it:

    sudo wget https://downloads.arduino.cc/arduino-cli/arduino-cli-0.3.2-alpha.preview-linuxarm.tar.bz2
    

    then

    tar xvjf arduino-cli-0.3.2-alpha.preview-linuxarm.tar.bz2
    

    and finally

    ./arduino-cli-0.3.2-alpha.preview-linuxarm 
    


  • No, I haven't. I guess I don't plan on it either. Have you heard of platformio?

    It's pretty damn handy. For those that wish, it has a better IDE than Arduino, fetches dependencies as specified, and above all has a great CLI. If you're interested in compiling and uploading binaries from the CLI, I would recommend you have a look at:

    https://docs.platformio.org/en/latest/core.html

    I know it doesn't answer your question, but I like to have a proper C++ linter running, letting a computer work for me, documenting exactly what I did to get code compiling and uploading, and to edit code in a proper editor.

    A quick start with platformio could be:

    pip install platformio
    git clone https://github.com/oneyb/template-mysensors-platformio blink
    cd blink
    # Do some stuff
    $EDITOR platformio.ini src/*cc
    # and finally:
    pio run -t upload
    

    I hope that helps you to be more efficient. It sure has helped me.



  • I installed platformio a while back for experiments with ice40. I've avoided it ever since because I found it way overcomplicated (and I generally prefer CLI environments - it just seemed that by trying to tackle everything it was reinventing too many wheels and had too many dependencies).

    But inspired by your delightfully simple example, I reinstalled it and had another go. It up did some updates (including to ice40, which surprised me), but failed in building blink with :

    Compiling .pioenvs/mysensors_htu21d/FrameworkArduino/HardwareSerial0.cpp.o
    src/mysensor-code.cc:64:1: error: 'HTU21D' does not name a type
    HTU21D myHumidity;
    ^
    src/mysensor-code.cc: In function 'void setup()':
    src/mysensor-code.cc:97:3: error: 'myHumidity' was not declared in this scope
    myHumidity.begin();
    ^
    src/mysensor-code.cc: In function 'void readHTU21DTemperature(bool)':
    src/mysensor-code.cc:148:16: error: 'myHumidity' was not declared in this scope
    float temp = myHumidity.readTemperature();
    ^
    src/mysensor-code.cc: In function 'void readHTU21DHumidity(bool)':
    src/mysensor-code.cc:171:16: error: 'myHumidity' was not declared in this scope
    float humd = myHumidity.readHumidity();
    ^
    Compiling .pioenvs/mysensors_htu21d/FrameworkArduino/HardwareSerial1.cpp.o
    
    

    It looks like something is still out of date. Is there anything obvious I missed or do I have to start digging ?



  • @oneyb said in Arduino has an official CLI app now:

    $EDITOR platformio.ini src/*cpp

    You missed a bit of 'digging' :).

    I cleaned up the code and pushed it so it will compile, but eventually you will want to dig. Blinking an led gets old.
    Pull in my changes please and then it will compile for you. Then you can start with some fun.
    If you like it, a possible workflow is to fork it and rename it to whatever. As you wish. I hope it helps.



  • @oneyb Thanks, but Platformio was a bit too complex for me too. I prefer the Arduino IDE. It's designed to make Arduino sketches, and nothing else.

    Especially for education it's undefeated I think. It's the same with Processing - a great first step after working with Scratch.

    If anything, I'd like the interface to be even simpler.

    That's why I'm hoping to use this CLI to create a web-based tool that can flash simple sketches.



  • @oneyb Thanks - that works for me now.
    It does complain (of course) that it couldn't open /dev/ttyUSB0.
    Is there a better way to deal with local specifics like this ? Maybe a convention of named links to specific ports that might exist ? So I could

    ln -s  ~/.platformio/local/serial/Uno  /dev/serial/by-id/usb-Arduino__www.arduino.cc__0043_95335343136351D0D1E0-if00
    


  • That's funny. I can't stand the Arduino IDE for the same reason. I have to remember where to get a dependency from which menu, select the correct port, and deal with a different editor than I am used to. I also didn't like how it would doctor the code with function declarations etc. It's C++. Why hide that fact? Sure, beginner-friendly is nice and it helped me for blinking LEDs, but afterwards it was annoying. Now I am pretty fast when working with a new board.

    CLI to create a web-based tool that can flash simple sketches.
    That sounds a little funny. So you want to have your web browser (indirectly) accessing hardware ports or at least determining the correct port? I guess that would be ok. I have a bunch of extensions which may not be so secure. I guess for beginners that would be nice. How would you deal with library dependencies? I guess the CLI tool would be advanced enough for that.

    If you are used to python the CLI from platformio is pretty simple. I guess my approach is for those who write code for a significant portion of their day.



  • @artag I don't know how to do that generally.

    A quick look at the results of:

    pio device list
    

    will get you the information to insert into platformio.ini. Their doc is pretty good. Maybe try it to the serial id. I haven't gotten so advanced yet. They have some nice examples.
    https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#custom-options-in-platformio-ini


 

467
Online

7.9k
Users

8.7k
Topics

93.6k
Posts