Skip to content

Commit

Permalink
Update bbn_m5atomS3_lite_INA219.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrouch authored Dec 16, 2024
1 parent 9779c99 commit 76cd150
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bbn_m5atomS3_lite_INA219/bbn_m5atomS3_lite_INA219.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
#define INA219_I2C_ADDRESS_2 (0x44) // Bridge A1 (on addresses pad)
#define INA219_I2C_ADDRESS_3 (0x45) // Bridge A0 and A1 (on addresses pad)

Adafruit_INA219 ina219(INA219_I2C_ADDRESS_0);
Adafruit_INA219 ina219_0(INA219_I2C_ADDRESS_0);
unsigned long timeout = 0;

void setup() {
auto cfg = M5.config();
AtomS3.begin(cfg);
Serial.begin(4800);
Wire.begin(G2, G1, 100000UL);
if (!ina219.begin()) {
if (!ina219_0.begin()) {
//Serial.println("Failed to find INA219 chip");
while (1) {
delay(10);
Expand All @@ -28,16 +28,16 @@ void setup() {
range can't measure as large of values but will measure with slightly
better precision.
*/
//ina219.setCalibration_32V_1A();
//ina219.setCalibration_16V_400mA();
//ina219_0.setCalibration_32V_1A();
//ina219_0.setCalibration_16V_400mA();
}

void loop() {
if (timeout < millis()) {
// Read voltage and current from INA219.
float shuntvoltage = ina219.getShuntVoltage_mV();
float busvoltage = ina219.getBusVoltage_V();
float current_mA = ina219.getCurrent_mA();
float shuntvoltage = ina219_0.getShuntVoltage_mV();
float busvoltage = ina219_0.getBusVoltage_V();
float current_mA = ina219_0.getCurrent_mA();

// Compute load voltage, power, and milliamp-hours.
float loadvoltage = busvoltage + (shuntvoltage / 1000);
Expand Down

0 comments on commit 76cd150

Please sign in to comment.