How can I program module ADS1115 with Arduino in Matlab?

14 ビュー (過去 30 日間)
daniela tovar
daniela tovar 2020 年 2 月 24 日
コメント済み: Ahsan Sami 2022 年 7 月 6 日
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)

回答 (2 件)

Tom Rockett
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
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
daniela tovar
daniela tovar 2020 年 3 月 10 日
Hi Tom,
but what was your programming in matlab, I was connected the SCL and SDA to pins 4 and 5 of the arduino, so I see you connect it to the TX and RX. Truth?

サインインしてコメントする。


Tom Rockett
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 件のコメント
daniela tovar
daniela tovar 2020 年 3 月 10 日
Ahsan Sami
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 ExchangeArduino Hardware についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by