Libraries and board definitions
Set up with your favorite AI
Gemini & other AI
Copy the setup prompt into your AI. Work through each step together, from checking your kit to getting it running.
Copy the prompt, then paste it into Gemini’s message box.
View prompt
To upload a program, select the board definition for your MCU and the libraries needed by your leaves and example. First run the initial program in development environment setup, then add the libraries you need.
Choose a board definition
Section titled “Choose a board definition”| Leaf | Arduino IDE | PlatformIO |
|---|---|---|
| AP01 AVR MCU | Arduino AVR Boards → Arduino Pro or Pro Mini → ATmega328P (3.3V,8MHz). Setup | platform = atmelavr, board = pro8MHzatmega328. Setup |
| AP02 ESP32 MCU | esp32 by Espressif Systems → ESP32 Dev Module. Setup | platform = espressif32, board = esp32dev. Setup |
| AP03 STM32 MCU | Use Leafony’s board package. URL and setup | Use Leafony’s LEAFONY_AP03 definition and variant files. File placement and upload settings |
For AP03 in PlatformIO, selecting a name in the board list is not enough. Follow the linked instructions to place the files and set the upload tool and port. For AP01, the reset procedure depends on the USB leaf model; also check the AZ01C instructions if you use it.
AP03B and AP05 are different models. Before reusing the settings above, check each model’s documentation for available software and connection requirements.
Choose the libraries you need
Section titled “Choose the libraries you need”These are the main sources referenced by the published examples. You do not need to install them all. Follow the example’s leaf and library requirements and the distributed project’s platformio.ini. A row does not mean that every library in it works with every MCU or leaf.
| Leaf or function | Source / header | What to check |
|---|---|---|
| Shared 4-Sensors functions | Adafruit Unified Sensor / Adafruit_Sensor.h, Adafruit BusIO / Adafruit_BusIO_Register.h | Also check dependencies required by the sensor library |
| HTS221 temperature and humidity | SmartEverything HTS221 / HTS221.h | Use the implementation specified by the example |
| OPT3001 illuminance | ClosedCube OPT3001 / ClosedCube_OPT3001.h | Search Arduino Library Manager for ClosedCube OPT3001 |
| AI01 acceleration (LIS2DHTR) | Adafruit LIS3DH / Adafruit_LIS3DH.h | The published examples use Adafruit LIS3DH. This is not for AI05’s LIS2DW12 |
| BLE leaf | TBGLib / TBGLib.h | Separate from libraries for ESP32’s built-in BLE |
| AI04 LCD | tomozh/arduino_ST7032 / ST7032.h | See the AI04 notes below |
| RTC on RTC & microSD | RTClib / RTClib.h | Separate from the STM32 internal RTC library |
| AVR timer interrupts | MsTimer2 / MsTimer2.h | For STM32, see HardwareTimer |
| STM32 internal RTC and low power | STM32RTC / STM32RTC.h, STM32LowPower / STM32LowPower.h | Check Arduino Core compatibility |
| Existing LTE-M examples | LteLeafV4 / LteLeafV4.h | Match the communication leaf model to the example |
| Wi-Fi Mary | WiFi101Leafony / WiFi101Leafony.h | Separate from settings for AP02’s built-in Wi-Fi |
| LoRa and signed communication | arduino-LoRa / LoRa.h, arduino-tca9536 / TCA9536.h, SparkFun ATECCX08a / SparkFun_ATECCX08a_Arduino_Library.h | Follow the example for the communication leaf and function you use |
ST7032 library for AI04 LCD
Section titled “ST7032 library for AI04 LCD”The published AI04 examples use arduino_ST7032 by tomozh. LCD_ST7032 and ST7032_asukiaaa are different implementations. For Arduino IDE, download the ZIP from the source and install it as described below.
If you see ST7032.h: No such file or directory, check the installation. Installing the library does not enable LCD power. See AI04 power and initialization and the LCD example for your MCU.
Install in Arduino IDE
Section titled “Install in Arduino IDE”- Check the library name, author and version specified by the example.
- If available in Library Manager, open Tools → Manage Libraries, search by name, check the author and version, and install it.
- For ZIP distributions, download the file using Code → Download ZIP or the source’s download link, then import it with Sketch → Include Library → Add .ZIP Library.
- Compile the example. If a header is missing, compare the filename in the error with the library you installed.
See Arduino’s library installation instructions for details.
Install in PlatformIO
Section titled “Install in PlatformIO”Add lib_deps inside the [env:...] section you use in platformio.ini. If it already exists, add entries to the same list. Dependencies are downloaded during the build. If the example includes a complete configuration file, use its settings.
; Syntax example. Hello World does not need additional libraries.lib_deps = adafruit/Adafruit Unified Sensor adafruit/Adafruit BusIOInstalling from a GitHub URL also requires Git. Restart VS Code after installing it and check that git --version works in a terminal. See PlatformIO’s lib_deps reference for syntax.
Versions in existing examples
Section titled “Versions in existing examples”Earlier lists included the following dependencies. They help you interpret existing projects. Before copying them into a new project, check the example and Arduino Core compatibility.
| Library | Existing PlatformIO dependency example |
|---|---|
| Adafruit Unified Sensor | adafruit/Adafruit Unified Sensor@^1.1.6 |
| Adafruit BusIO | adafruit/Adafruit BusIO@^1.14.1 |
| ClosedCube OPT3001 | closedcube/ClosedCube OPT3001@^1.1.2 |
| Adafruit LIS3DH | adafruit/Adafruit LIS3DH@1.1.2 |
| AI04 LCD | tomozh/ST7032@0.0.0-alpha+sha.501bf64fe6 |
| MsTimer2 | paulstoffregen/MsTimer2@^1.1 |
| RTClib | adafruit/RTClib@^2.1.1 |
| STM32RTC | stm32duino/STM32duino RTC@1.2.0 |
| STM32LowPower | stm32duino/STM32duino Low Power@^1.2.2 |
STM32RTC and STM32LowPower in particular must match the STM32 Arduino Core version. If a build changes after a library update, check the full error, board package and library versions, and include them in the question template.