필터 지우기
필터 지우기

INA219 Current Sensor Integration with MATLAB

조회 수: 14 (최근 30일)
Jayden  Hasemann
Jayden Hasemann 2017년 9월 10일
댓글: Gongyan Du 2020년 5월 18일
Hi There,
I am trying to use a INA219 current sensor to obtain the voltage and current and thus power from a Solar Panel. This chip works with an arduino. I have coded in arduino and got the values i require however when I try to read these values on MATLAB I cannot get it to work.
The Code that I have written is Here:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clc clear all
a = arduino;
INA219 = '0x40';
INA219_ADC_CH0 = '40'; % getBusVoltage_V
INA219_ADC_CH1 = '41'; % getVoltage_mV
INA219_ADC_CH3 = '43'; % getCurrent_mA
i2c = i2cdev(a,INA219);
disp(['getBusVoltage_V ', 'getVoltage_mV', 'getCurrent_mA']);
while 1
getBusVoltage_V = read_adc(i2c,hex2dec(INA219_ADC_CH0));
pause(0.5);
getVoltage_mV = read_adc(i2c,hex2dec(INA219_ADC_CH1));
pause(0.5);
getCurrent_mA = read_adc(i2c,hex2dec(INA219_ADC_CH3));
pause(0.5);
disp([getBusVoltage_V,getVoltage_mV,getCurrent_mA]);
end
function adc = read_adc(dev,config)
write(dev,config);
read(dev, 3);
out = read(dev, 3);
adc = out;
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Where the output is:
60 0 0
31 3 0
255 255 255.
I was expecting an output of roughly:
2.46 0.03 0.07
*obtained from my arduino code.
I cannot seem to find where I've gone wrong, perhaps my limited knowledge in the area. Any help you could provide to rectify this would be great.
Regards,
Jayden
  댓글 수: 3
Raul Ballesteros
Raul Ballesteros 2019년 5월 28일
I have the same problem If find the solution Please share the vos es Thanks
Gongyan Du
Gongyan Du 2020년 5월 18일
I have the same problem

댓글을 달려면 로그인하십시오.

답변 (1개)

Gongyan Du
Gongyan Du 2020년 5월 18일
Have you solved this problem, can you share it?

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by