Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrouch committed Dec 12, 2024
1 parent aaa343c commit ffc0736
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 315 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
arduino-board-fqbn: esp32:esp32:m5stack-atoms3:CDCOnBoot=cdc
arduino-platform: esp32:[email protected]
platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
required-libraries: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],Adafruit SGP30 [email protected],Adafruit BME680 [email protected],Adafruit VEML7700 [email protected],SparkFun AS7331 Arduino [email protected],SparkFun AS3935 Lightning Detector Arduino [email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
required-libraries: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],Adafruit SGP30 [email protected],Adafruit BME680 [email protected],Adafruit VEML7700 [email protected],SparkFun AS7331 Arduino [email protected],SparkFun AS3935 Lightning Detector Arduino [email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
sketch-names: "*.ino"
sketch-names-find-start: bbn_*
extra-arduino-cli-args: "--warnings default"
Expand Down
13 changes: 7 additions & 6 deletions i2c_ads1115.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef i2c_ads1115_h
#define i2c_ads1115_h

#include "m5_ads1115.h"
#include <M5_ADS1115.h>

#include "NmeaXDR.h"
#include "Nmea0183Msg.h"

Expand All @@ -15,7 +16,7 @@
#define M5_UNIT_VMETER_EEPROM_I2C_ADDR 0x53
#define M5_UNIT_VMETER_PRESSURE_COEFFICIENT 0.015918958F

ADS_1115 i2c_ads1115_sensor;
ADS1115 i2c_ads1115_sensor;
bool i2c_ads1115_found = false;

float resolution = 0.0;
Expand All @@ -32,7 +33,7 @@ void i2c_ads1115_report() {

void i2c_ads1115_try_init() {
for (int i = 0; i < 3; i++) {
i2c_ads1115_found = i2c_ads1115_sensor.begin(&Wire, M5_UNIT_VMETER_I2C_ADDR, G2, G1, 100000U);
i2c_ads1115_found = i2c_ads1115_sensor.begin(&Wire, M5_UNIT_VMETER_I2C_ADDR, G2, G1, 400000U);
if (i2c_ads1115_found) {
break;
}
Expand All @@ -41,9 +42,9 @@ void i2c_ads1115_try_init() {
if (i2c_ads1115_found) {
gen_nmea0183_msg("$BBTXT,01,01,01,VOLTAGE found ads1115 sensor at address=0x%s", String(M5_UNIT_VMETER_I2C_ADDR, HEX).c_str());
i2c_ads1115_sensor.setEEPROMAddr(M5_UNIT_VMETER_EEPROM_I2C_ADDR);
i2c_ads1115_sensor.setMode(ADS_1115_MODE_SINGLESHOT);
i2c_ads1115_sensor.setRate(ADS_1115_RATE_8);
i2c_ads1115_sensor.setGain(ADS_1115_PGA_512);
i2c_ads1115_sensor.setMode(ADS1115_MODE_SINGLESHOT);
i2c_ads1115_sensor.setRate(ADS1115_RATE_8);
i2c_ads1115_sensor.setGain(ADS1115_PGA_512);
// | PGA | Max Input Voltage(V) |
// | PGA_6144 | 128 |
// | PGA_4096 | 64 |
Expand Down
14 changes: 6 additions & 8 deletions i2c_qmp6988.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
#ifndef i2c_qmp6988_h
#define i2c_qmp6988_h

#include <M5Unified.h>
#include <M5UnitUnified.h>
#include <M5UnitUnifiedENV.h>
#include <M5UnitENV.h>

#include "NmeaXDR.h"
#include "Nmea0183Msg.h"

#define QMP6988_SLAVE_ADDRESS_L (0x70)
#define QMP6988_SLAVE_ADDRESS_H (0x56)

m5::unit::UnitQMP6988 i2c_qmp6988_sensor(QMP6988_SLAVE_ADDRESS_L);
QMP6988 i2c_qmp6988_sensor(QMP6988_SLAVE_ADDRESS_L);
bool i2c_qmp6988_found = false;

void i2c_qmp6988_report() {
if (i2c_qmp6988_sensor.updated()) {
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_QMP6988", i2c_qmp6988_sensor.celsius()); // C
gen_nmea0183_xdr("$BBXDR,P,%.2f,P,PRES_QMP6988", i2c_qmp6988_sensor.pressure()); // Pa
if (i2c_qmp6988_sensor.update()) {
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_QMP6988", i2c_qmp6988_sensor.cTemp); // C
gen_nmea0183_xdr("$BBXDR,P,%.2f,P,PRES_QMP6988", i2c_qmp6988_sensor.pressure); // Pa
}
}

void i2c_qmp6988_try_init() {
for (int i = 0; i < 3; i++) {
i2c_qmp6988_found = Units.add(i2c_qmp6988_sensor, Wire) && i2c_qmp6988_sensor.begin();
i2c_qmp6988_found = !i2c_qmp6988_sensor.begin(&Wire, QMP6988_SLAVE_ADDRESS_L, G2, G1, 400000U);
if (i2c_qmp6988_found) {
break;
}
Expand Down
7 changes: 0 additions & 7 deletions i2c_sensors.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#ifndef i2c_sensors_h
#define i2c_sensors_h

#include <M5Unified.h>
#include <M5UnitUnified.h>

m5::unit::UnitUnified Units;

#include "i2c_ads1115.h"
#include "i2c_sht30.h"
#include "i2c_qmp6988.h"
Expand All @@ -14,11 +9,9 @@ void i2c_sensors_scan() {
i2c_ads1115_try_init();
i2c_sht30_try_init();
i2c_qmp6988_try_init();
Units.begin();
}

void i2c_sensors_update() {
Units.update();
}

#endif
14 changes: 6 additions & 8 deletions i2c_sht30.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
#ifndef i2c_sht30_h
#define i2c_sht30_h

#include <M5Unified.h>
#include <M5UnitUnified.h>
#include <M5UnitUnifiedENV.h>
#include <M5UnitENV.h>

#include "NmeaXDR.h"
#include "Nmea0183Msg.h"

#define SHT3X_I2C_ADDR 0x44

m5::unit::UnitSHT30 i2c_sht30_sensor(SHT3X_I2C_ADDR);
SHT30 i2c_sht30_sensor(SHT3X_I2C_ADDR);
bool i2c_sht30_found = false;

void i2c_sht30_report() {
if (i2c_sht30_sensor.updated()) {
gen_nmea0183_xdr("$BBXDR,H,%.2f,P,HUMI_SHT3X", i2c_sht30_sensor.humidity()); // %
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_SHT3X", i2c_sht30_sensor.celsius()); // C
if (i2c_sht30_sensor.update()) {
gen_nmea0183_xdr("$BBXDR,H,%.2f,P,HUMI_SHT3X", i2c_sht30_sensor.humidity); // %
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_SHT3X", i2c_sht30_sensor.cTemp); // C
}
}

void i2c_sht30_try_init() {
for (int i = 0; i < 3; i++) {
i2c_sht30_found = Units.add(i2c_sht30_sensor, Wire) && i2c_sht30_sensor.begin();
i2c_sht30_found = i2c_sht30_sensor.begin(&Wire, SHT3X_I2C_ADDR, G2, G1, 400000U);
if (i2c_sht30_found) {
break;
}
Expand Down
Loading

0 comments on commit ffc0736

Please sign in to comment.