main/task_ina219.c

changeset 30
7448b8dd4288
parent 28
5872b972e553
child 34
40231d010111
equal deleted inserted replaced
29:551a53b31373 30:7448b8dd4288
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, &current) because it takes 112 * We don't call ina219_get_current(&ina219_b_dev, &current) 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));

mercurial