How can I program module ADS1115 with Arduino in Matlab?
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello! I am trying to program the module ADS1115 with Arduino in Matlab, I have reviewed these pages however I cannot understand how it works, has anyone managed to program? I have also tried this code and it does not give me an ADC value consistent with what the multimeter shows me.
My code is:
ar=arduino('COM4','Uno','Libraries','I2C');
dev = device(ar,'I2CAddress','0x48');
%dev = i2cdev(ar,'0x48'); % creates i2c device object
writeRegister(dev,1,51075,'uint16');
ADC=readRegister(dev,0,'uint16');
Volt=1.024*(ADC/65536);
disp(Volt)
pause(2)
댓글 수: 0
답변 (2개)
Tom Rockett
2020년 3월 5일
Hi Daniela
What is the voltage value that your code is giving you? If it is a factor of two out from the true value of 1.024V then the problem is due to using the wrong measurement mode of the ADS1115. You can try to set up your circuit to do a differential measurement, which will have the full 16-bits of resolution.
Best regards,
Tom
댓글 수: 3
Tom Rockett
2020년 3월 9일
Hi Daniela
If the value is random then that sounds like you are reading noise. I'm not sure what to suggest, other than checking all of the connections in your circuit.
Here is a photo of the circuit that I used, which is similar to what you are trying to achieve (apart from the voltage divider in my case). I hope this helps.
Tom

Tom Rockett
2020년 3월 10일
Hi Daniela
I don't know where you've got TX and RX from, I haven't used them. What model of arduino are you using? The SCL and SDA pins on the ADS1115 are connected to the SCL and SDA pins on the arduino, respectively.
You can try replacing your writeRegister line with:
writeRegister(dev,1,37762,'uint16');
As this should enable the differential measurement (using pins A0 and A3 on the ADS1115). I suggest you follow my original example and read the ADS1115 data sheet (the section on the config register) to understand what difference this will make.
Best of luck,
Tom
댓글 수: 3
Ahsan Sami
2022년 7월 6일
Tom Rockett can u please help me in understanding how u design "37762" for both pins A0 and A3 and 51075 for only pin A0
참고 항목
카테고리
Help Center 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
