From c082e25029d37d618ca9a1b1a2f7977829293bee Mon Sep 17 00:00:00 2001 From: Mikhail Grushinskiy Date: Thu, 12 Dec 2024 14:16:04 -0500 Subject: [PATCH] wip --- i2c_ads1115.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/i2c_ads1115.h b/i2c_ads1115.h index 53be6f4..3d01400 100644 --- a/i2c_ads1115.h +++ b/i2c_ads1115.h @@ -22,6 +22,15 @@ bool i2c_ads1115_found = false; float resolution = 0.0; float calibration_factor = 0.0; +void i2c_ads1115_report() { + int16_t adc_raw = i2c_ads1115_sensor.getSingleConversion(); + float voltage = adc_raw * resolution * calibration_factor; + //Serial.printf("Cal ADC:%.0f\n", adc_raw * calibration_factor); + //Serial.printf("Cal Voltage:%.2f mV\n", voltage); + //Serial.printf("Raw ADC:%d\n\n", adc_raw); + gen_nmea0183_xdr("$BBXDR,U,%.3f,V,VOLT", voltage / 1000); // Volt +} + 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); @@ -50,13 +59,4 @@ void i2c_ads1115_try_init() { } } -void i2c_ads1115_report() { - int16_t adc_raw = i2c_ads1115_sensor.getSingleConversion(); - float voltage = adc_raw * resolution * calibration_factor; - //Serial.printf("Cal ADC:%.0f\n", adc_raw * calibration_factor); - //Serial.printf("Cal Voltage:%.2f mV\n", voltage); - //Serial.printf("Raw ADC:%d\n\n", adc_raw); - gen_nmea0183_xdr("$BBXDR,U,%.3f,V,VOLT", voltage / 1000); // Volt -} - #endif