fixed wire and chamber ID
This commit is contained in:
1 parent
97882ed4ea
commit
496abbfec3
2 files changed
+29
-15
No files matched your search
@@ -45,7 +45,11 @@ bool CultivarEnv::begin(TwoWire &wire, uint8_t sda, uint8_t scl, uint8_t bme_add
|
||||
_scl = scl;
|
||||
_bme_addr = bme_addr;
|
||||
|
||||
#ifdef ARDUINO_ARCH_ZEPHYR
|
||||
_wire->begin();
|
||||
#else
|
||||
_wire->begin(_sda, _scl);
|
||||
#endif
|
||||
|
||||
bme_ok = _initBME690();
|
||||
scd4x_ok = _initSCD4x();
|
||||
@@ -69,7 +73,7 @@ bool CultivarEnv::_initBME690() {
|
||||
if (bme_status != BME69X_OK) return false;
|
||||
|
||||
if (_dev.variant_id != BME690_VARIANT_GAS_HIGH) {
|
||||
Serial.printf("[cultivar_env] Warning: variant_id=0x%02X (expected 0x02 for BME690)\n",
|
||||
CULTIVAR_SERIAL_PRINTF("[cultivar_env] Warning: variant_id=0x%02X (expected 0x02 for BME690)\n",
|
||||
_dev.variant_id);
|
||||
}
|
||||
|
||||
@@ -316,13 +320,13 @@ size_t CultivarEnv::toJSON(const CultivarEnvPayload &p, char *buf, size_t len) {
|
||||
|
||||
// ── printPayload ──────────────────────────────────────────────────────────
|
||||
void CultivarEnv::printPayload(const CultivarEnvPayload &p) {
|
||||
Serial.printf("\n══ Cultivar ENV payload [t=%lums] ══\n", p.timestamp_ms);
|
||||
CULTIVAR_SERIAL_PRINTF("\n══ Cultivar ENV payload [t=%lums] ══\n", p.timestamp_ms);
|
||||
|
||||
Serial.println("── Ambient (BME690, heater off) ──────");
|
||||
if (p.ambient.valid) {
|
||||
Serial.printf(" Temperature: %.2f °C\n", p.ambient.temperature);
|
||||
Serial.printf(" Humidity: %.2f %%RH\n", p.ambient.humidity);
|
||||
Serial.printf(" Pressure: %.2f hPa\n", p.ambient.pressure);
|
||||
CULTIVAR_SERIAL_PRINTF(" Temperature: %.2f °C\n", p.ambient.temperature);
|
||||
CULTIVAR_SERIAL_PRINTF(" Humidity: %.2f %%RH\n", p.ambient.humidity);
|
||||
CULTIVAR_SERIAL_PRINTF(" Pressure: %.2f hPa\n", p.ambient.pressure);
|
||||
} else {
|
||||
Serial.println(" [invalid]");
|
||||
}
|
||||
@@ -330,9 +334,9 @@ void CultivarEnv::printPayload(const CultivarEnvPayload &p) {
|
||||
Serial.println("── CO2 (SCD43) ───────────────────────");
|
||||
if (p.health.scd43_present) {
|
||||
if (p.co2.valid) {
|
||||
Serial.printf(" CO2: %u ppm\n", p.co2.co2_ppm);
|
||||
Serial.printf(" Temperature: %.2f °C\n", p.co2.temperature);
|
||||
Serial.printf(" Humidity: %.2f %%RH\n", p.co2.humidity);
|
||||
CULTIVAR_SERIAL_PRINTF(" CO2: %u ppm\n", p.co2.co2_ppm);
|
||||
CULTIVAR_SERIAL_PRINTF(" Temperature: %.2f °C\n", p.co2.temperature);
|
||||
CULTIVAR_SERIAL_PRINTF(" Humidity: %.2f %%RH\n", p.co2.humidity);
|
||||
} else {
|
||||
Serial.println(" [no data]");
|
||||
}
|
||||
@@ -342,25 +346,25 @@ void CultivarEnv::printPayload(const CultivarEnvPayload &p) {
|
||||
|
||||
Serial.println("── Sensor Health ─────────────────────");
|
||||
if (p.health.scd43_present && p.ambient.valid && p.co2.valid) {
|
||||
Serial.printf(" Temp delta: %.2f °C %s\n",
|
||||
CULTIVAR_SERIAL_PRINTF(" Temp delta: %.2f °C %s\n",
|
||||
p.health.temp_delta,
|
||||
p.health.temp_ok ? "✓" : "⚠ WARN");
|
||||
Serial.printf(" Hum delta: %.2f %%RH %s\n",
|
||||
CULTIVAR_SERIAL_PRINTF(" Hum delta: %.2f %%RH %s\n",
|
||||
p.health.humidity_delta,
|
||||
p.health.humidity_ok ? "✓" : "⚠ WARN");
|
||||
} else {
|
||||
Serial.println(" [single sensor mode]");
|
||||
}
|
||||
|
||||
Serial.printf("── Baseline [samples=%u, established=%s]\n",
|
||||
CULTIVAR_SERIAL_PRINTF("── Baseline [samples=%u, established=%s]\n",
|
||||
p.baseline.samples_collected,
|
||||
p.baseline.established ? "yes" : "no");
|
||||
|
||||
Serial.println("── Gas Sweep (BME690) ────────────────");
|
||||
Serial.printf(" %-6s %-6s %-5s %-16s %-7s %s\n",
|
||||
CULTIVAR_SERIAL_PRINTF(" %-6s %-6s %-5s %-16s %-7s %s\n",
|
||||
"Temp°C", "Dur ms", "Zone", "Resistance Ω", "Stable", "Valid");
|
||||
for (uint8_t i = 0; i < p.sweep_count; i++) {
|
||||
Serial.printf(" %-6u %-6u %-5u %-16.0f %-7s %s\n",
|
||||
CULTIVAR_SERIAL_PRINTF(" %-6u %-6u %-5u %-16.0f %-7s %s\n",
|
||||
p.sweep[i].heater_temp_c,
|
||||
p.sweep[i].heater_dur_ms,
|
||||
p.sweep[i].zone,
|
||||
@@ -378,7 +382,7 @@ void CultivarEnv::scanI2C() {
|
||||
for (uint8_t addr = 1; addr < 127; addr++) {
|
||||
_wire->beginTransmission(addr);
|
||||
if (_wire->endTransmission() == 0) {
|
||||
Serial.printf(" 0x%02X", addr);
|
||||
CULTIVAR_SERIAL_PRINTF(" 0x%02X", addr);
|
||||
if (addr == 0x62) Serial.print(" ← SCD43");
|
||||
if (addr == 0x76 || addr == 0x77) Serial.print(" ← BME690");
|
||||
if (addr == 0x6B) Serial.print(" ← QMI8658C IMU");
|
||||
|
||||
@@ -25,6 +25,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// ── Platform shim (Zephyr/ESP32 portability) ──────────────────────────────
|
||||
#ifdef ARDUINO_ARCH_ZEPHYR
|
||||
#define CULTIVAR_SERIAL_PRINTF(fmt, ...) \
|
||||
do { char _b[128]; snprintf(_b, sizeof(_b), fmt, ##__VA_ARGS__); Serial.print(_b); } while(0)
|
||||
#define CULTIVAR_ENV_SDA 0
|
||||
#define CULTIVAR_ENV_SCL 0
|
||||
#else
|
||||
#define CULTIVAR_SERIAL_PRINTF(fmt, ...) Serial.printf(fmt, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include "vendor/sensirion/SensirionI2cScd4x.h"
|
||||
@@ -138,7 +148,7 @@ struct CultivarI2CHandle {
|
||||
// ── Main library class ────────────────────────────────────────────────────
|
||||
class CultivarEnv {
|
||||
public:
|
||||
CultivarEnv();
|
||||
CultivarEnv(const char* chamber_id = "fruiting");
|
||||
|
||||
/**
|
||||
* Initialize sensors.
|
||||
|
||||
Reference in new issue
Block a user