From 0d6baa00e47674d3afa3c721d7b45b7b4ff135fc Mon Sep 17 00:00:00 2001 From: fb-pilot Date: Mon, 6 May 2024 11:42:31 +0200 Subject: [PATCH] add options for INA3221 driver (#21310) * Add files via upload * Add files via upload * Add files via upload * Delete tasmota/xsns_100_ina3221.ino --------- Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com> --- tasmota/my_user_config.h | 3 +++ tasmota/tasmota_xsns_sensor/xsns_100_ina3221.ino | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 132f72b82..f3e9b0ea4 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -737,6 +737,9 @@ https://rya.nc/tasmota-fingerprint.html" // // Both settings together allow to limit searching for INA3221 to only a subset of addresses // #define INA3221_CALC_CHARGE_AH // calculate charge in Ah // #define INA3221_CALC_ENERGY_WH // calculate energy in Wh +// #define INA3221_SUPPLY_SIDE 0x7777 // the driver adds the measured Shunt Voltage to the Bus Voltage + // for the cannel with a negativ shunt (shunt <0) thus showing the values of the supply side (IN+) + // additionaly the bits set (bit 0,1,2) enable the scanning of the voltage in the according channel // #define USE_PMSA003I // [I2cDriver78] Enable PMSA003I Air Quality Sensor (I2C address 0x12) (+1k8 code) // #define USE_GDK101 // [I2cDriver79] Enable GDK101 sensor (I2C addresses 0x18 - 0x1B) (+1k2 code) // #define GDK101_SHOW_FW_VERSION diff --git a/tasmota/tasmota_xsns_sensor/xsns_100_ina3221.ino b/tasmota/tasmota_xsns_sensor/xsns_100_ina3221.ino index d104c3028..c78f0658c 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_100_ina3221.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_100_ina3221.ino @@ -1,7 +1,7 @@ /* xsns_100_ina3221.ino - INA3221 3-channels Current Sensor support for Tasmota - Copyright (C) 2021 Barbudor and Theo Arends + fb-pilot 2024-4-4, 2024-4-20 + Copyright (C) 2021 Barbudor and Theo Arends + fb-pilot Based on Barbudor's CircuitPython_INA3221 This program is free software: you can redistribute it and/or modify @@ -472,12 +472,14 @@ bool Ina3221CmndSensor(void) float shunt = CharToFloat(ArgV(argument,2+channel)); Ina3221SetShunt(device, channel, shunt); } +#ifdef INA3221_SUPPLY_SIDE if (!Ina3221WriteConfig(device)){ #ifdef DEBUG_TASMOTA_SENSOR DEBUG_SENSOR_LOG(D_INA3221 "error write configuration %d", device+1); #endif return false; } +#endif } Response_P(INA3221_SENSORCMND_START, XSNS_100, device +1, Ina3221Data[device].i2caddr); for (int channel = 0 ; channel < INA3221_NB_CHAN ; channel++ ) {