That is the same configuration I've been using the Adafruit INA219 library in Arduino. However, the esp-idf-lib library reports wrong measures on this simple circuit (also simulated in Falstad):
The multimeter shows almost the same value around 36mA, but the library says about 76mA.
I think the calibration factor is somehow, in the Arduino library says 0x2000 and here, as is computed dinamically, says 0x1000. I tried to hardcode this value with no positive results. Shunt resistor is set to 100miliohms.
Which SDK are you using?
esp-idf
Which version of SDK are you using?
master
Which build target have you used?
[ ] esp32
[X] esp32s2
[ ] esp32s3
[ ] esp32c2
[ ] esp8266
[ ] other
Component causing the issue
ina219
Anything in the logs that might be useful for us?
I (102) main_task: Started on CPU0
I (102) main_task: Calling app_main()
I (102) INA219_example: Initializing INA219
D (102) i2cdev: Reconfiguring I2C driver on port 0
D (102) i2cdev: I2C driver successfully reconfigured on port 0
D (112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
D (112) ina219: Initialize, config: 0x03ff
I (112) INA219_example: Configuring INA219
D (112) ina219: Config: 0x019f
D (112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
I (112) INA219_example: Calibrating INA219
D (112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
D (112) ina219: Calibration: 0.1000 Ohm, 0x1000
D (112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
I (102) main_task: Returned from app_main()
I (112) INA219_example: Starting the loop
D (112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
112,92.00
D (1112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
1112,-100.00
D (2112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
2112,76.00
D (3112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
3112,76.00
D (4112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
4112,76.00
D (5112) i2cdev: Timeout: ticks = 0 (0 usec) on port 0
5112,76.00
Additional information or context
No response
Confirmation
[X] This report is not a question nor a request for drivers.
The issue
I'm running the example provided by de library with an ESP32 and INA219 sensor, configured for 400mA, 16V and 40mV gain as:
That is the same configuration I've been using the Adafruit INA219 library in Arduino. However, the esp-idf-lib library reports wrong measures on this simple circuit (also simulated in Falstad):
The multimeter shows almost the same value around 36mA, but the library says about 76mA.
I think the calibration factor is somehow, in the Arduino library says
0x2000
and here, as is computed dinamically, says0x1000
. I tried to hardcode this value with no positive results. Shunt resistor is set to 100miliohms.Which SDK are you using?
esp-idf
Which version of SDK are you using?
master
Which build target have you used?
Component causing the issue
ina219
Anything in the logs that might be useful for us?
Additional information or context
No response
Confirmation