Nick Dunklee 59cee5c8a0 feat: Integrate BME680 Bosch BSEC support for RAK4631
This is a consolidation of my changes for BME680 on RAK4631 nodes.
I will close my other PRs related to this and link back to this one.

*Background on change:*

This change replaces the Adafruit BME680 driver on RAK4631 with the
Bosch BSEC library. Other boards continue to use the existing
Adafruit path via ENV_INCLUDE_BME680.

This makes the IAQ portion of the sensor functional, and more accurate.
It also contains the math and/or CayenneLPP fixes from my other PRs.
The Bosch code also appears to handle calibrating sensor aging as well,
whereas the Adafruit code is just looking at blind values that can drift
with time. Pretty cool to see this shooting out useful data!

RAK4631 platform.io is set to override to ENV_INCLUDE_BME680_BSEC while
leaving the Adafruit code for other node types. (If this becomes applicable
for other node types in future, awesome! I just don't have hardware
to test against.)

Using the BSEC library introduces IAQ sensor calibration, and saves
the calibration state periodically so it does not have to calibrate
again later.

At startup the IAQ sensor takes 30 minutes to heat and to hit a baseline,
then starts calibrating. Once calibrated, it will save those settings
and will only write settings again if calibration falls back and restores
back to state 3.

This fix also has the gas resistance math fix that was in
[pull 2146](https://github.com/meshcore-dev/MeshCore/pull/2146) so
the adafruit path also can at least show accurate values instead
of looping negative.

Also includes the fix from [pull 2149](https://github.com/meshcore-dev/MeshCore/pull/2149) so the pressure output isn't truncated to 1hPa steps.

*Fixes/Changes:*
- Add bsec_config_iaq[] with the 3.3V/3s-LP/28d calibration profile
- BSEC init applies setConfig() for voltage-correct heater targeting
- IAQ, heat-compensated temperature/humidity, pressure, and altitude
  reported over CayenneLPP
- IAQ accuracy reported as analog input over CayenneLPP (0,1,2,3)
- Calibration state persisted to /bsec_state.bin on nRF52 internal
  flash; written only when iaqAccuracy improves to >= 2, should
  keep write frequency well within flash endurance over device lifetime
- Fix non-BSEC query_bme680: float pressure division, addGenericSensor
  for gas resistance (was addAnalogInput, overflows at > 327 Ohm)
- loop() correctly gated for both GPS and BSEC-only builds
- Add fix_bsec_lib.py extra_script to resolve nRF52840 hard-float ABI
  mismatch in Bosch's PlatformIO packaging, silly Bosch

One general note outside of this code change: I noticed while BME680
_functions_ in companion nodes, since companion nodes run Bluetooth,
BLE preempts the CPU, and can do so mid-I2C-transaction.

This can cause the BME680 to see an anomaly and drop calibration and
start a recalibrate. This is behavior that will exist (and has existed)
regardless of using the Adafruit or Bosch paths.

This particular companion behavior does not seem to occur in sensor
or repeater nodes since their BLE is off. Probably affects other
I2C devices as well.

*Tests:*

- RAK19003
- RAK19007
- RAK19001
- repeater, sensor, companion
2026-05-27 15:33:48 -06:00
2026-04-24 19:37:21 +00:00
2025-01-13 14:07:48 +11:00
2026-04-28 21:39:34 +10:00
2026-05-21 19:58:10 +10:00
2025-01-13 14:07:48 +11:00
2025-06-05 20:35:40 +12:00
2026-04-24 19:37:21 +00:00
2026-02-03 13:47:43 +13:00
2026-03-20 10:23:51 +11:00
2026-03-23 14:26:56 +01:00
2025-01-20 10:20:42 +11:00
2025-01-25 23:09:09 +11:00
2026-03-31 00:51:15 +13:00
2026-05-11 11:37:56 +10:00
2025-03-03 18:08:00 +13:00

About MeshCore

MeshCore is a lightweight, portable C++ library that enables multi-hop packet routing for embedded projects using LoRa and other packet radios. It is designed for developers who want to create resilient, decentralized communication networks that work without the internet.

🔍 What is MeshCore?

MeshCore now supports a range of LoRa devices, allowing for easy flashing without the need to compile firmware manually. Users can flash a pre-built binary using tools like Adafruit ESPTool and interact with the network through a serial console. MeshCore provides the ability to create wireless mesh networks, similar to Meshtastic and Reticulum but with a focus on lightweight multi-hop packet routing for embedded projects. Unlike Meshtastic, which is tailored for casual LoRa communication, or Reticulum, which offers advanced networking, MeshCore balances simplicity with scalability, making it ideal for custom embedded solutions., where devices (nodes) can communicate over long distances by relaying messages through intermediate nodes. This is especially useful in off-grid, emergency, or tactical situations where traditional communication infrastructure is unavailable.

Key Features

  • Multi-Hop Packet Routing
    • Devices can forward messages across multiple nodes, extending range beyond a single radio's reach.
    • Supports up to a configurable number of hops to balance network efficiency and prevent excessive traffic.
    • Nodes use fixed roles where "Companion" nodes are not repeating messages at all to prevent adverse routing paths from being used.
  • Supports LoRa Radios Works with Heltec, RAK Wireless, and other LoRa-based hardware.
  • Decentralized & Resilient No central server or internet required; the network is self-healing.
  • Low Power Consumption Ideal for battery-powered or solar-powered devices.
  • Simple to Deploy Pre-built example applications make it easy to get started.

🎯 What Can You Use MeshCore For?

  • Off-Grid Communication: Stay connected even in remote areas.
  • Emergency Response & Disaster Recovery: Set up instant networks where infrastructure is down.
  • Outdoor Activities: Hiking, camping, and adventure racing communication.
  • Tactical & Security Applications: Military, law enforcement, and private security use cases.
  • IoT & Sensor Networks: Collect data from remote sensors and relay it back to a central location.

🚀 How to Get Started

For developers;

The Simple Secure Chat example can be interacted with through the Serial Monitor in Visual Studio Code, or with a Serial USB Terminal on Android.

MeshCore Flasher

We have prebuilt firmware ready to flash on supported devices.

  • Launch https://meshcore.io/flasher
  • Select a supported device
  • Flash one of the firmware types:
    • Companion, Repeater or Room Server
  • Once flashing is complete, you can connect with one of the MeshCore clients below.

📱 MeshCore Clients

Companion Firmware

The companion firmware can be connected to via BLE, USB or WiFi depending on the firmware type you flashed.

Repeater and Room Server Firmware

The repeater and room server firmwares can be setup via USB in the web config tool.

They can also be managed via LoRa in the mobile app by using the Remote Management feature.

🛠 Hardware Compatibility

MeshCore is designed for devices listed in the MeshCore Flasher

📜 License

MeshCore is open-source software released under the MIT License. You are free to use, modify, and distribute it for personal and commercial projects.

Contributing

Please submit PR's using 'dev' as the base branch! For minor changes just submit your PR and we'll try to review it, but for anything more 'impactful' please open an Issue first and start a discussion. Is better to sound out what it is you want to achieve first, and try to come to a consensus on what the best approach is, especially when it impacts the structure or architecture of this codebase.

Here are some general principals you should try to adhere to:

  • Keep it simple. Please, don't think like a high-level lang programmer. Think embedded, and keep code concise, without any unnecessary layers.
  • No dynamic memory allocation, except during setup/begin functions.
  • Use the same brace and indenting style that's in the core source modules. (A .clang-format is prob going to be added soon, but please do NOT retroactively re-format existing code. This just creates unnecessary diffs that make finding problems harder)

Help us prioritize! Please react with thumbs-up to issues/PRs you care about most. We look at reaction counts when planning work.

Running unit tests

To run unit tests, run the following command:

pio test --environment native --verbose

Road-Map / To-Do

There are a number of fairly major features in the pipeline, with no particular time-frames attached yet. In very rough chronological order:

  • Companion radio: UI redesign
  • Repeater + Room Server: add ACL's (like Sensor Node has)
  • Standardise Bridge mode for repeaters
  • Repeater/Bridge: Standardise the Transport Codes for zoning/filtering
  • Core + Repeater: enhanced zero-hop neighbour discovery
  • Core: round-trip manual path support
  • Companion + Apps: support for multiple sub-meshes (and 'off-grid' client repeat mode)
  • Core + Apps: support for LZW message compression
  • Core: dynamic CR (Coding Rate) for weak vs strong hops
  • Core: new framework for hosting multiple virtual nodes on one physical device
  • V2 protocol spec: discussion and consensus around V2 packet protocol, including path hashes, new encryption specs, etc

📞 Get Support

  • Report bugs and request features on the GitHub Issues page.
  • Find additional guides and components on my site.
  • Join MeshCore Discord to chat with the developers and get help from the community.
S
Description
No description provided
Readme 227 MiB
Languages
C 61.5%
C++ 37.2%
Python 0.9%
Shell 0.3%
Linker Script 0.1%