This commit is contained in:
@@ -26,7 +26,8 @@ extern SensorData shunt_data;
|
||||
float zero_value = 0.03; // Measured shunt voltage with nothing connected, used to fix measuring offset
|
||||
|
||||
void init_sensor(){
|
||||
ina_sensor.begin(33, 32);
|
||||
Wire.begin(33, 32);
|
||||
ina_sensor.begin();
|
||||
#ifdef USE_INA226
|
||||
ina_sensor.setMaxCurrentShunt(0.02, 4, false);
|
||||
ina_sensor.setBusVoltageConversionTime(7);
|
||||
@@ -47,13 +48,13 @@ void read_sensor_task(void* parameter)
|
||||
// Get Values from sensor
|
||||
#ifndef USE_INA226
|
||||
String chip_id = ina_sensor.get_device_model();
|
||||
LOG(DEBUG, "Chip Model: %s", chip_id.c_str());
|
||||
LOG(ELOG_LEVEL_DEBUG, "Chip Model: %s", chip_id.c_str());
|
||||
#endif
|
||||
|
||||
float bus_voltage = ina_sensor.getBusVoltage();
|
||||
float shunt_voltage = ina_sensor.getShuntVoltage_mV() - zero_value;
|
||||
|
||||
LOG(DEBUG, "RAW Shunt voltage: %F mV", ina_sensor.getShuntVoltage_mV());
|
||||
LOG(ELOG_LEVEL_DEBUG, "RAW Shunt voltage: %F mV", ina_sensor.getShuntVoltage_mV());
|
||||
|
||||
float shunt_current = shunt_voltage / RESISTOR_VALUE;
|
||||
|
||||
@@ -73,8 +74,8 @@ void read_sensor_task(void* parameter)
|
||||
float min_water_level_mA = 4 + min_water_level_mA_over_zero;
|
||||
float max_water_level_mA = 4 + max_water_level_mA_over_zero;
|
||||
|
||||
LOG(DEBUG, "max_water_level_mA: %F", max_water_level_mA);
|
||||
LOG(DEBUG, "min_water_level_mA_over_zero: %F", min_water_level_mA_over_zero);
|
||||
LOG(ELOG_LEVEL_DEBUG, "max_water_level_mA: %F", max_water_level_mA);
|
||||
LOG(ELOG_LEVEL_DEBUG, "min_water_level_mA_over_zero: %F", min_water_level_mA_over_zero);
|
||||
|
||||
// Current over the 0 level of the water
|
||||
float shunt_current_over_zero = shunt_current - min_water_level_mA;
|
||||
@@ -94,10 +95,10 @@ void read_sensor_task(void* parameter)
|
||||
active_errors.current_high = shunt_current > 20.2;
|
||||
active_errors.voltage_low = bus_voltage < 23;
|
||||
active_errors.voltage_high = bus_voltage > 25;
|
||||
LOG(DEBUG, "Shunt current: %F", shunt_current);
|
||||
LOG(DEBUG, "Shunt voltage: %F", shunt_voltage);
|
||||
LOG(DEBUG, "Bus voltage: %F", bus_voltage);
|
||||
LOG(DEBUG, "cm_over_zero: %F", cm_over_zero);
|
||||
LOG(ELOG_LEVEL_DEBUG, "Shunt current: %F", shunt_current);
|
||||
LOG(ELOG_LEVEL_DEBUG, "Shunt voltage: %F", shunt_voltage);
|
||||
LOG(ELOG_LEVEL_DEBUG, "Bus voltage: %F", bus_voltage);
|
||||
LOG(ELOG_LEVEL_DEBUG, "cm_over_zero: %F", cm_over_zero);
|
||||
|
||||
shunt_data.bus_voltage = bus_voltage;
|
||||
shunt_data.shunt_voltage = shunt_voltage;
|
||||
|
||||
Reference in New Issue
Block a user