The Balora IoT Platform Library is a comprehensive library developed for the Balora IoT platform, which combines the power of LoRa, Bluetooth, WiFi, IMU, Battery, and the ESP32-PICO-D4 MCU. This library provides a unified interface and a set of convenient functions to simplify the development of IoT applications using the Balora custom board.
- Sparkfun MAX1704x Fuel Gauge Arduino Library
- Adafruit NeoPixel
- RadioLib
- Adafruit MPU6050
- TinyGPSPlus
- ESP32Time
- BluetoothSerial
The supported PCB design will be included in the PCB folder of the repository. This library should be able to work with any ESP32 based board that includes the following:
- Semtech SX1268 LoRa Module
- Adafruit MPU6050 IMU
- Quectel L80-R GNSS Module
- Adafruit NeoPixels (x2)
- microSD Reader
- Sparkfun MAX17048 Battery Monitoring IC
Include the library directly from PlatformIO Registry:
kiosdron/Balora
Add the following line to your platformio.ini
file:
lib_deps = https://github.com/KIOS-Research/Balora.git
OR
- Clone the Repository:
git clone https://github.com/KIOS-Research/Balora.git
- Add the library to you PlatformIO Project:
platformio lib install /path/to/Balora
- Include the library to your project
#include <Balora.h>
Basic Functions | Description |
---|---|
Balora node("node id"); | Initializes core modules and sets the node id. |
node.begin(); | Initializes all modules on board |
node.setLedColor(color); | Sets the color of the NeoPixels LED (color must be in hex format 0xFFFFFF) |
node.setLedBrightness(128); | Sets the brightness of NeoPixels LED (integer values between 0 and 255) |
node.showLed(); | Sets and activates the NeoPixels LED |
node.clearLed(); | Clears the NeoPixels LED |
node.initWiFiClient("SSID","PASSWORD"); | Initializes the WiFi Client with the given SSID and Password (Build Flag: -DUSEWIFI) |
node.initMPU(); | Initializes MPU6050 (Build Flag: -DUSEMPU) |
node.setLowPowerCPU(); | Sets MCU frequency to 80MHz |
node.setHighPowerCPU(); | Sets MCU frequency to 240MHz |
node.initSD(); | Initializes SD Module (Build Flag: -DUSESD) |
node.loraTx("message"); | LoRa Transmission Function (Build Flag: -DUSELORA) |
String loraMsg = node.loraRx(); | Returns LoRa Received String (Build Flag: -DUSELORA) |
float loraRSSI = node.getLoraRSSI(); | Returns the RSSI of LoRa reception in dBm |
float loraSNR = node.getLoraSNR(); | Returns the SNR of LoRa |
node.logBattery(); | Logs the battery level to the SD card (time, voltage, percentage) |
node.writeToSD("message"); | Writes given message to SD. (Build Flag: -DUSESD) |
node.handleBattery(); | REQUIRED ON LOOP to send board to deep sleep if battery < 25% |
node.showBatteryState(); | REQUIRED ON LOOP to display the battery level with NEOPIXELS |
node.setPath("/log_path.txt"); | Set SD Logging Path (default: "/log.txt") (Build Flag: -DUSESD) |
String nodeID = node.getID(); | Returns the ID of the node |
node.getBattery(double& voltage, double& percentage); | Returns by reference the voltage and percentage of the battery |
sensors_vec_t accel = node.getAccel(); | Returns the Accelerometer vector (see Example: IMU Data) (Build Flag: -DUSEMPU) |
sensors_vec_t gyro = node.getGyro(); | Returns the Gyroscope vector (see Example: IMU Data) (Build Flag: -DUSEMPU) |
String macAd = node.getMac(); | Returns the MAC address of the node |
String nodeHash = node.getHash(); | Returns the Hash of the MAC address |
node.initBT("BTName"); | Initialize Bluetooth Serial Communication (Build Flag: -DUSEBT) |
String btMsg = node.btRx(); | Return String from Bluetooth Serial (Build Flag: -DUSEBT) |
node.btTx("Message"); | Send Message via Bluetooth Serial (Build Flag: -DUSEBT) |
To save flash memory, preprocessor directives have been implemented. These directives must be included in the build flags of platformio.ini
. Notice that the Bluetooth and WiFi implementations take up a large amount of the flash memory due to the driver libraries. All the function descriptions include the required build flags. Example environment to use MPU and LoRa:
[env:debugEnv]
build_type = debug
platform = espressif32
board = pico32
framework = arduino
lib_deps = https://github.com/KIOS-Research/Balora.git
monitor_speed = 115200
upload_speed = 921600
build_flags =
-DUSEMPU
-DUSELORA
-DUSEGPS
It is critical for the user to always include the node.begin()
function to initialize the Battery Management module and always use node.handleBattery()
and node.showBatteryState()
in the loop function to avoid damaging the battery.
The Bluetooth communication is achieved with the BluetoothSerial library that utilizes the Android Bluetooth Terminal app.
The Gerber files can be used to manufacture the specific Balora PCB Design.
Everyone is welcome to participate in this project. Whether you are helping others to resolve issues, reporting a new issue that hasn't yet been discovered, suggesting a new feature that would benefit your workflow, or writing code (or tests, or scripts, or ...), we value your time and effort.
The path for contribution starts with the Issues. You can create a new issue in case you discover a new bug or you have a useful suggestion that you’d like to be implemented. If you want to contribute code, fork this repo to your own account. Make your commits on your dev branch (or one based on dev). Once you are finished, you can open a Pull Request to test the code and discuss merging your changes back into the community repository.
The Balora IoT Platform Library is open-source software licensed under the EUPL License.