Finding, adding, and using libraries with Particle cli on Google Colab

Hi there …

I’m new to Particle, and this is my first post on the forum, so just hoping the style and substance of this note comport with local norms.

I’m trying to build some simple tutorials for a course that I teach remotely. I’ve using Jupyter notebooks on Google Colab extensively for teaching data and computationally oriented courses, and am trying a few experiments to see if it could work with Particle, too.

Here’s a proof of concept demonstrating Colab with Tinker: https://colab.research.google.com/drive/1i0wWU-7SnZ19a6OGQN5XnckWlNQDtPR2#scrollTo=ERsWOhNw5NPg

Here’s a proof of concept demonstrating Particle cli on Colab: https://colab.research.google.com/drive/1eybJfx2naCsVBOjTbzEu6GEK6cHu-h5I#scrollTo=ERsWOhNw5NPg

This third attempt is s where the trouble starts: https://colab.research.google.com/drive/1GK5Ogga8ts8vfS9493wmEAExFZ3I3N7u#scrollTo=TcUKDiWOsvt1

There are some issues:

  1. The documentation for the Particle cli library says to use the “add” command to download and install a library. See: https://colab.research.google.com/drive/1GK5Ogga8ts8vfS9493wmEAExFZ3I3N7u#scrollTo=TcUKDiWOsvt1 This seemed to have no effect in the notebook above. But “view” command did download and install a library. Is the documentation correct?

  2. Compiling results in an "Found unsafe content Found: #include “/” error. I could find no documentation on how to override this message. Any advice?

I’m new to Particle, so these are likely newb errors. Any help would be appreciated.

Jeff

Welcome to the community :+1:

For your first point, particle library add will only add a dependency entry to the project.properties file and the cloud build will then pull that referenced library in but the docs don’t tell otherwise either - no mention of downloading and installing the library AFAICT.
If you want to download the library (e.g. to tweak it for your project) you’d use particle library copy which will place the library inside your project at its intended place (particle library view will not do that).

For the second question it’s hard to tell without the code as I’m not going to sign up for the colab link :wink:

Thank you for explanation regarding “add” vs “copy”. It’s now clear that I’m not setting up the project correctly inside Colab, so will tackle that next and see if this will resolve my problems. Thanks.

When running particle library add or particle library copy you should execute that from the location within your project folder where the project.properties file resides.
If you haven’t got one of these you should use particle project create to properly setup a new project structure.

1 Like

Thanks again. This advice has been spot on. I can create a project, add libraries, copy libraries to the /lib subdirectory, and compile an empty project. The problem now is that compiling fails because it can’t find the library subdirectory. Here’s the minimal file

#include “Grove_4Digit_Display”

void setup() {
}

void loop() {
}

Here’s the message

Compiling code for argon

Including:
lib/Grove_4Digit_Display/src/Grove_4Digit_Display.h
lib/Grove_4Digit_Display/examples/NumberFlow/NumberFlow.ino
src/display4.ino
lib/Grove_4Digit_Display/src/Grove_4Digit_Display.cpp
project.properties

attempting to compile firmware
Compile failed: Processing lib/Grove_4Digit_Display/examples/NumberFlow/NumberFlow.ino
Processing src/display4.ino
Checking library Grove_4Digit_Display…
Installing library Grove_4Digit_Display 1.0.2 to lib/Grove_4Digit_Display …
Library Grove_4Digit_Display 1.0.2 installed.
make -C …/modules/argon/user-part all
make[1]: Entering directory ‘/firmware/modules/argon/user-part’

mkdir -p target/
make -f …/…/…/modules/shared/nRF52840/build_linker_script.mk PREBUILD=1
make[2]: Entering directory ‘/firmware/modules/argon/user-part’
Creating target/platform_user_ram.ld …
make[2]: Leaving directory ‘/firmware/modules/argon/user-part’

make -C …/…/…/user
make[2]: Entering directory ‘/firmware/user’
Building cpp file: src/display4.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p …/build/target/user/platform-12-msrc/
arm-none-eabi-gcc -DSTM32_DEVICE -DnRF52840 -DNRF52840_XXAA -DPLATFORM_THREADING=1 -DPLATFORM_ID=12 -DPLATFORM_NAME=argon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD00C -DUSBD_PID_CDC=0xC00C -DSPARK_PLATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DINCLUDE_PLATFORM=1 -DSOFTDEVICE_PRESENT=1 -DS140 -DPRODUCT_ID=12 -DPRODUCT_FIRMWARE_VERSION=65535 -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=“openthread-config-project.h” -DENABLE_FEM=1 -DNRF_802154_PROJECT_CONFIG=“openthread-platform-config.h” -DRAAL_SOFTDEVICE=1 -D_WIZCHIP_=W5500 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DLFS_CONFIG=lfs_config.h -DSYSTEM_VERSION_STRING=1.5.2 -DRELEASE_BUILD -I./inc -I…/wiring/inc -I…/system/inc -I…/third_party/miniz/miniz -I…/services/inc -I…/third_party/nanopb/nanopb -I…/communication/inc -I…/hal/inc -I…/hal/shared -I…/hal/src/argon -I…/hal/network/lwip/esp32 -I…/hal/src/nRF52840 -I…/hal/src/armv7 -I…/hal/src/nRF52840 -I…/hal/src/nRF52840/lwip -I…/hal/src/nRF52840/freertos -I…/hal/src/nRF52840/openthread -I…/hal/src/nRF52840/mbedtls -I…/hal/src/nRF52840/littlefs -I…/hal -I…/hal/network/api -I…/hal/network/lwip -I…/hal/network/lwip/posix -I…/hal/network/openthread -I…/hal/network/lwip/wiznet -I…/hal/network/ncp -I…/hal/network/ncp/at_parser -I…/third_party/lwip/lwip/src/include -I…/third_party/freertos/freertos/FreeRTOS/Source/include -I…/third_party/nrf5_sdk/nrf5_sdk/external/freertos/portable/GCC/nrf52 -I…/third_party/nrf5_sdk/nrf5_sdk/external/freertos/portable/CMSIS/nrf52 -I…/third_party/openthread/openthread/include -I…/third_party/openthread/openthread/src/core -I…/third_party/openthread/openthread/examples/platforms -I…/third_party/openthread/openthread/radio -I…/third_party/openthread/openthread/radio/hal -I…/third_party/openthread/openthread/radio/rsch -I…/third_party/openthread/openthread/radio/rsch/raal -I…/third_party/openthread/openthread/radio/rsch/raal/softdevice -I…/third_party/wiznet_driver/wiznet_driver/Ethernet -I…/gsm0710muxer/gsm0710muxer/include -I…/platform/shared/inc -I…/third_party/nrf5_sdk -I…/third_party/nrf5_sdk/nrf5_sdk/components/toolchain/cmsis/include -I…/third_party/nrf5_sdk/nrf5_sdk/modules/nrfx -I…/third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/drivers -I…/third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/drivers/include -I…/third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/hal -I…/third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/mdk -I…/third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/hal -I…/third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/drivers/src/prs -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/util -I…/third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140/headers -I…/third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140/headers/nrf52 -I…/third_party/nrf5_sdk/nrf5_sdk/components/softdevice/common -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/fstorage -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/experimental_section_vars -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/atomic -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/crc32 -I…/third_party/nrf5_sdk/nrf5_sdk/integration/nrfx/legacy -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/delay -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/log -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/log -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/log/src -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/experimental_section_vars -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/atomic -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/delay -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/queue -I…/third_party/nrf5_sdk/nrf5_sdk/components/softdevice/common -I…/third_party/nrf5_sdk/nrf5_sdk/components/softdevice/mbr/nrf52840/headers -I…/third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140 -I…/third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140/headers -I…/third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140/headers/nrf52 -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/fifo -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/atomic_fifo -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/strerror -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/fstorage -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/atomic_flags -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/usbd -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/usbd/class/cdc -I…/third_party/nrf5_sdk/nrf5_sdk/components/libraries/usbd/class/cdc/acm -I…/third_party/nrf5_sdk/nrf5_sdk/components/ble/common -I…/third_party/nrf5_sdk/nrf5_sdk/components/ble/nrf_ble_gatt -I…/third_party/nrf5_sdk/nrf5_sdk/components/ble/ble_advertising -I…/third_party/nrf5_sdk/nrf5_sdk/components/nfc/t2t_lib -I…/third_party/nrf5_sdk/nrf5_sdk/components/nfc/platform -I…/third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/generic/message -I…/third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/generic/record -I…/third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/lauchapp -I…/third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/text -I…/third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/uri -I…/third_party/nrf5_sdk/nrf5_sdk/external/nrf_cc310/include -I…/third_party/nrf5_sdk/nrf5_sdk/external/utf_converter -I…/third_party/littlefs/littlefs -I…/platform/MCU/nRF52840/inc -I…/dynalib/inc -Isrc -I./libraries -Ilib/Grove_4Digit_Display/src -I. -MD -MP -MF …/build/target/user/platform-12-msrc/display4.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DSPARK_PLATFORM_NET=ESP32 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0xD4000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=6 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,1,1512 -DMODULE_DEPENDENCY2=0,0,0 -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="“app”" -fno-exceptions -fno-rtti -fcheck-new -std=gnu++14 -c -o …/build/target/user/platform-12-msrc/display4.o src/display4.cpp
src/display4.ino:8:33: fatal error: Grove_4Digit_Display: No such file or directory
compilation terminated.
…/build/module.mk:274: recipe for target ‘…/build/target/user/platform-12-msrc/display4.o’ failed
make[2]: *** […/build/target/user/platform-12-msrc/display4.o] Error 1
make[2]: Leaving directory ‘/firmware/user’
…/…/…/build/recurse.mk:11: recipe for target ‘user’ failed
make[1]: *** [user] Error 2
make[1]: Leaving directory ‘/firmware/modules/argon/user-part’
…/build/recurse.mk:11: recipe for target ‘modules/argon/user-part’ failed
make: *** [modules/argon/user-part] Error 2

It should be:

#include "Grove_4Digit_Display.h"

It’s currently missing the .h part.

2 Likes

Well, that was embarrassing. Thanks, I’ve got a skeleton working in Google Colab.

2 Likes

We’ve all been there and we’ll all be back there.

1 Like

Thanks. For what it’s worth, I’m pleased with how these notebook are turning out. I realize that notebooks don’t hold a candle to the Particle IDE, but it is one way to structure a document for teaching and exposition. It works surprising well.

https://jckantor.github.io/cbe-virtual-laboratory/

1 Like