Environment errors

I am using an adafruit feather 32u4 board. I downloaded the Adafruit BluefruitLE nRF51 library. Once installed I copied and pasted the installation tab code into the .ini file. Now when I try to compile I receive this environment error.

This is what my .ini file looks like

platform = atmelavr
board = feather32u4
framework = arduino
lib_deps = adafruit/Adafruit BluefruitLE nRF51@^1.10.0

platform = infineonxmc
framework = arduino
lib_deps =
adafruit/Adafruit BluefruitLE nRF51 @ ^1.10.0
adafruit/Adafruit BluefruitLE nRF51 @ ~1.10.0
adafruit/Adafruit BluefruitLE nRF51 @ 1.10.0

The second environment makes no sense. An infineonxmc environment with no board set, and the library added three times with different versioning styles? Maybe you miscopied it from the examples, but I think you should just delete that part.

The board page (Overview | Adafruit Feather 32u4 Bluefruit LE | Adafruit Learning System) to use the Adafruit BluefruitLE nRF51 library, so you’re good with that one. Note that you also have to include the library in your source code to have it compoile properly. Easiest to take the example files

but rename the .ino to just .cpp. Compiling then gives me

RAM:   [==        ]  19.2% (used 492 bytes from 2560 bytes)
Flash: [===       ]  32.5% (used 9320 bytes from 28672 bytes)
Building .pio\build\feather32u4\firmware.hex
============ [SUCCESS] Took 7.64 seconds ============

wiht your first environment.

So, if I am trying to run At Command, I change the .ino for atcommand to .cpp, then I remove the 2nd env from my .ini?

The .ino to .cpp conversion requires for that file that you predaclare the used functinos, just like the the FAQ says.

// after all #include lines
void getUserInput(char buffer[], uint8_t maxSize);

If you just want to do a quick test and don’t plan to change or add on the code, you can also keep the .ino extension, PlatformIO will autoconvert it to .cpp on compilation.

RAM:   [==        ]  16.1% (used 412 bytes from 2560 bytes)
Flash: [===       ]  32.3% (used 9254 bytes from 28672 bytes)
Building .pio\build\feather32u4\firmware.hex
============ [SUCCESS] Took 5.87 seconds ============

Should be the result.

But after removing the 2nd part of the .ini file I am getting include errors. So how can I only run the atcommand example from the library after installing it to my project?

Have you made sure to use the project environment switcher to select the first environment again? It will show “Reloading tasks” for a while when it’s downloading the lib into that environment, then all include errors should be gone…

I did not do anything, just uploaded a library and hit compile.

Once you add a library via lib_deps you must include it in your main source file so that the library’s dependencies are found correctly. So your initial includes should look like

#include <Arduino.h>
#include <SPI.h>
#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"
#include "Adafruit_BluefruitLE_UART.h"

Thanks so much! it works without error, so to run the atcommand, I just move atcommand.ino and bluefruitconfig.h to the src folder?

Exactly. If you’d done this directly the .ino file already has all the includes and it would compile directly.

So I dont need to move it to src to only compile that file?

Every sketch file that you want to compile should be placed in src, you can’t put it in the root of the project folder.

So this? I deleted the main.cpp, it gave me success in output

Yeah that’s okay. The .h file can also be in the src/ folder alternatively.

Ok thanks, I switched to platformio because arduino ide did not accept my feather 32u4, so I am new to how this works and you have been a life saver for my project!