Skip to content
Snippets Groups Projects
Commit 4dee0d1e authored by Jonathan Klimt's avatar Jonathan Klimt
Browse files

Solarfarm uses INA231 now

parent 50412b5b
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@
#include "driver/spi_master.h"
#include "driver/timer.h"
#include "ina233.h"
#include "ina231.h"
#include "legos_common.h"
#include "owb.h"
#include "owb_rmt.h"
......
......@@ -9,7 +9,7 @@
static const char* TAG = "SolarFarm"; // Logging tag
static i2c_port_t i2c_num = I2C_NUM_1; // I2C port
static uint8_t ina_grid = INA233_ADDRESS_44; // I2C address INA233
static uint8_t ina_grid = 0x44; // I2C address INA231
spi_device_handle_t AD8400_IMAX; // SPI handle to Digital Pot
static uint8_t setpoint_imax_old; // Current setpoint
......@@ -186,7 +186,7 @@ void set_digital_pot(spi_device_handle_t handle, uint8_t value)
}
/**
* @brief Read INA233 Telemetry
* @brief Read INA231 Telemetry
*
* @param[in] addr Addres of the device on the I2C bus
*
......@@ -194,9 +194,9 @@ void set_digital_pot(spi_device_handle_t handle, uint8_t value)
*/
void read_telemetry(uint8_t addr)
{
entity.power_out.voltage = ina233_getBusVoltage_V(addr);
entity.power_out.current = ina233_getCurrent_mA(addr);
entity.power_out.power = ina233_getPower_mW(addr);
entity.power_out.voltage = ina231_getBusVoltage_V(addr);
entity.power_out.current = ina231_getCurrent_mA(addr);
entity.power_out.power = ina231_getPower_mW(addr);
ESP_LOGD(TAG, "Telemetry\tbus: %f V,shunt: %f mA, pwr: %f mW",
entity.power_out.voltage, entity.power_out.current,
entity.power_out.power);
......@@ -473,7 +473,7 @@ esp_err_t init_spi()
}
/**
* @brief Init the INA233 power monitor
* @brief Init the INA231 power monitor
*
* @return
* - ESP_OK Success
......@@ -491,8 +491,8 @@ esp_err_t init_telemetry()
float INA_R_SHUNT = 0.075;
float INA_I_MAX = 1.2;
ESP_ERROR_CHECK(ina233_init(i2c_num, ina_grid));
ESP_ERROR_CHECK(ina233_setCalibration(ina_grid, INA_R_SHUNT, INA_I_MAX));
ESP_ERROR_CHECK(ina231_init(i2c_num, ina_grid));
ESP_ERROR_CHECK(ina231_setCalibration(ina_grid, INA_R_SHUNT, INA_I_MAX));
return ESP_OK;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment