102 * rest for a while. The INA219 runs in continuous mode so we get the |
102 * rest for a while. The INA219 runs in continuous mode so we get the |
103 * results during the vTaskDelay(). |
103 * results during the vTaskDelay(). |
104 */ |
104 */ |
105 ESP_ERROR_CHECK(ina219_configure(&ina219_b_dev, INA219_BUS_RANGE_32V, INA219_GAIN_0_125, |
105 ESP_ERROR_CHECK(ina219_configure(&ina219_b_dev, INA219_BUS_RANGE_32V, INA219_GAIN_0_125, |
106 INA219_RES_12BIT_1S, INA219_RES_12BIT_1S, INA219_MODE_CONT_SHUNT_BUS)); |
106 INA219_RES_12BIT_1S, INA219_RES_12BIT_1S, INA219_MODE_CONT_SHUNT_BUS)); |
107 vTaskDelay(10 / portTICK_PERIOD_MS); |
107 vTaskDelay(20 / portTICK_PERIOD_MS); |
108 ESP_ERROR_CHECK(ina219_get_bus_voltage(&ina219_b_dev, &bus_voltage)); |
108 ESP_ERROR_CHECK(ina219_get_bus_voltage(&ina219_b_dev, &bus_voltage)); |
109 vTaskDelay(10 / portTICK_PERIOD_MS); |
109 vTaskDelay(10 / portTICK_PERIOD_MS); |
110 ESP_ERROR_CHECK(ina219_get_shunt_voltage(&ina219_b_dev, &shunt_voltage)); |
110 ESP_ERROR_CHECK(ina219_get_shunt_voltage(&ina219_b_dev, &shunt_voltage)); |
111 /* |
111 /* |
112 * We don't call ina219_get_current(&ina219_b_dev, ¤t) because it takes |
112 * We don't call ina219_get_current(&ina219_b_dev, ¤t) because it takes |
137 } |
137 } |
138 |
138 |
139 if (! ina219_state->Solar.fake) { |
139 if (! ina219_state->Solar.fake) { |
140 ESP_ERROR_CHECK(ina219_configure(&ina219_s_dev, INA219_BUS_RANGE_32V, INA219_GAIN_0_125, |
140 ESP_ERROR_CHECK(ina219_configure(&ina219_s_dev, INA219_BUS_RANGE_32V, INA219_GAIN_0_125, |
141 INA219_RES_12BIT_1S, INA219_RES_12BIT_1S, INA219_MODE_CONT_SHUNT_BUS)); |
141 INA219_RES_12BIT_1S, INA219_RES_12BIT_1S, INA219_MODE_CONT_SHUNT_BUS)); |
142 vTaskDelay(10 / portTICK_PERIOD_MS); |
142 vTaskDelay(20 / portTICK_PERIOD_MS); |
143 ESP_ERROR_CHECK(ina219_get_bus_voltage(&ina219_s_dev, &bus_voltage)); |
143 ESP_ERROR_CHECK(ina219_get_bus_voltage(&ina219_s_dev, &bus_voltage)); |
144 vTaskDelay(10 / portTICK_PERIOD_MS); |
144 vTaskDelay(10 / portTICK_PERIOD_MS); |
145 ESP_ERROR_CHECK(ina219_get_shunt_voltage(&ina219_s_dev, &shunt_voltage)); |
145 ESP_ERROR_CHECK(ina219_get_shunt_voltage(&ina219_s_dev, &shunt_voltage)); |
146 ESP_ERROR_CHECK(ina219_configure(&ina219_s_dev, INA219_BUS_RANGE_32V, INA219_GAIN_0_125, |
146 ESP_ERROR_CHECK(ina219_configure(&ina219_s_dev, INA219_BUS_RANGE_32V, INA219_GAIN_0_125, |
147 INA219_RES_12BIT_1S, INA219_RES_12BIT_1S, INA219_MODE_POWER_DOWN)); |
147 INA219_RES_12BIT_1S, INA219_RES_12BIT_1S, INA219_MODE_POWER_DOWN)); |