MATLAB Answers

how i can read a signal from asd1115 with arduino and matlab?

57 views (last 30 days)
Bambo  Lotto
Bambo Lotto on 29 May 2016
Answered: daniela tovar on 24 Feb 2020
I'm try to write a program which can read a signal from ADS1115. I use a arduino as a hub. I'm starting with this code:
%check arduino
a=arduino();
%find ic2 adc and select it (do it after installing add onto arduino)
addrs = scanI2CBus(a);
%create a ic2 device. substitute ‘0x48’ if necessary
signal = i2cdev(a, '0x48')
Now i would to configure ADS1115to perform a lecture of register0(which is the Conversion Register The feature that i need is that while matlab show some figures, matlab will read from ADS1115 a voltage value. How i can perform this?

  0 Comments

Sign in to comment.

Answers (2)

T Rockett
T Rockett on 5 Sep 2017
Edited: T Rockett on 5 Sep 2017
TLDR version:
a = arduino('COM4','Uno'); % replace with relevant com port and model
dev = i2cdev(a,'0x48'); % creates i2c device object
writeRegister(dev,1,51075,'uint16');
pause(0.02)
data = readRegister(dev,0,'uint16');
This code will measure the signal from the A0 channel of the ADS1115, up to 1.024 Volts. To use a voltage above 1.024 Volts you can write a different number to the register. As far as I know, you need to call the writeRegister command every time before you read the data with readRegister.
How to make the chip work (with more detail)
First you need to tell the ADS1115 to start gathering data. You do this by writing a value to the configuration register (the number 1 in the writeRegister command corresponds to the config register). The number that you write to the register can be worked out by looking at the ADS1115 data sheet, in the section "Config Register Field Descriptions". Basically you need to work out a 16-bit binary sequence.
The values that I used as an example:
For example in the bits 11 to 9 I used "0 1 1", this corresponds to the gain amplifier setting of FSR = +/- 1.024 V from the data sheet. By gathering these 1's and 0's into a single 16-bit sequence (starting with bit 15 from my table) we get:
1100011110000011
We can then convert this sequence into a decimal number with:
bin2dec('1100011110000011')
This gives 51075. After writing this value to the configuration register, the chip will start gathering data. This will be stored in the conversion register (which has address 0). We can read the data from this register by using the readRegister command.
n.b. sorry for necroing this thread. There is literally no documentation on the internet on how to use this chip with Matlab / Arduino, and this is the first thing that comes up on google. I spent around 10 hours getting this to work, and I want other users to not have the same painful experience :)

  0 Comments

Sign in to comment.


daniela tovar
daniela tovar on 24 Feb 2020
Hi! Has anyone tried this programming? I am trying to program my ADS1115 module with this example but when I read the ADC (0) and convert it to Volts it is not the same as I measure with the multimeter.

  0 Comments

Sign in to comment.