Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please, help me to set up Clion + Arduino.

Clion has an arduino plugin which I've installed. Here is some instruction on Github but I'm fully noob about cmake and other things which are talking about in instruction. I have only used Arduino IDE before for my simple projects. Now in clion I can create an Arduino projects but autocompletion doesn't work. Actually it works but does it on true C, not for Arduino code.

So if you can please explain like for complete idiot, what I should change to get working Arduino autocompletion.

share|improve this question
    
What do you mean by Arduino autocompletion? – Avamander Feb 3 at 20:53
1  
look here – Kvach Feb 3 at 21:08
    
It can't autocomplete what it doesn't know about. Have you installed all the libraries correctly according to what the plug in requires? (Try to compile the Blink example included with the Arduino IDE, do you get any errors?) – Avamander Feb 3 at 21:22
    
If u explain how to do, I will do it. – Kvach Feb 3 at 21:43

Rather than using any plugin, I am using CLion with PlatformIO, which supports several IDEs. CLion then not only gives you code completion, but also full support for refactoring, Git, and much much more.

From its documentation:

[...] generate project via platformio init --ide command:

platformio init --ide clion --board %TYPE%

# For example, generate project for Arduino UNO
platformio init --ide clion --board uno

Then import the project in CLion and you're about done.

Some hints:

  • Make sure your code is in the src folder, and include the main file in the generated CMakeLists.txt. This needs to have a .cpp extension, like:

    add_executable(projectname src/main.cpp)
    
  • For other files: either rename all .ino files to use .cpp, or tell CLion to associate the .ino extension with C++ files. (Preferences, Editors, File Types.)

  • Whenever adding libraries to the lib folder (and using #include to refer to them), just run the above init command again.
  • If you're using ESP-boards and changed platform.txt for an alternative esptool, then note that PlatformIO needs a different hack.
  • Rather than using the CLion Serial Monitor plugin, I simply use a Terminal within CLion to upload and start the monitor as soon as possible:

    pio run -t upload; pio serialports monitor -b 115200
    
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.