Can I use Python with Leafony?
Use this page with AI
Explore with your favorite AI
Gemini & other AI
Copy this page’s context into your AI to explore how it works and what you can build.
Copy the prompt, then paste it into Gemini’s message box.
View prompt
On this page
On-leaf development is intended to use C/C++ with Arduino IDE, or STM32CubeIDE for STM32 leaves.
For Arduino samples, see the development environment. To use STM32CubeIDE and a debugger with AP03, see connecting a debugger. Arduino sketches and CubeIDE projects use different settings and library integration, so they may require changes when moving between environments.
Python can run on a PC to receive Leafony data, save it, plot it, and analyze it. Write a Python receiver that matches the data sent by the C/C++ program on Leafony.
| Connection | Python options and things to check |
|---|---|
| Serial communication over USB | Receive data with pySerial. Upload a program that outputs serial data, then match the port, baud rate, and data format, including line endings. The leaf needed for USB connectivity depends on the MCU. |
| BLE wireless communication | Use Bleak to read GATT characteristics or receive notifications. Check the PC’s Bluetooth environment and the sample’s connection method, UUIDs, and data format. |
For USB, the STM32 temperature and humidity sample provides an example of serial output. Its baud rate is 115200 bps. First check that values appear in Arduino IDE’s serial monitor, then close the monitor before opening the same port from Python.
For BLE, use the data format and UUID guidance to write a receiver that matches your sample. For a non-connectable beacon, scan its advertising data instead of making a GATT connection.
To run Python on the leaf itself, you need a separate runtime such as MicroPython. MicroPython for ESP32 is available, but a supported chip alone does not mean that every Leafony leaf or sensor will work unchanged. Check the firmware for the board, pin configuration, and sensor drivers. Leafony Docs currently does not include hardware-verified MicroPython setup instructions for AP02 or AP03.
If your goal is sensor data analysis, start with an existing Arduino sample on Leafony and Python on the PC. Also see programming languages for STM32.
