Hi, I'm doing some work with one today and read through the data sheet yesterday. Not an easy read. I haven't tried this yet but my take is.
EDIT: this does work.
The ADS1115 has up to 4 analog inputs but only measures one a time. To set which one is being used use bits 14:12 (MUX) in the config register. Then set the pointer to and read the current value from the conversion register.
From Power on.
Code: Select allWrite:
B 0100 1000, IC address (address pin to Gnd).
B 0000 0001 set pointer to config register.
B 1100 0001 config bits 15:8 – set to read AIN0
B 1000 0011 config bits 7:0
End:
EDIT: A delay is needed here. I'm currently using 15ms but less will work you will need to test.
Write:
B 0100 1000, IC address (address pin to Gnd).
B 0000 0000 set pointer to conversion register.
End:
Read:
B 0100 1000, IC address (address pin to Gnd).
ADS sends back 2 bytes (MSB first) containing the value of the conversion register.
To read again
Read:
B 0100 1000, IC address (address pin to Gnd).
ADS sends back 2 bytes (MSB first) containing the value of the conversion register.
To read a different analog input do the same again but set bits 14:12 as follows:
Code: Select all100 = AIN0
101 = AIN1
110 = AIN2
111 = AIN3
So to read all 4 analog inputs you would have to do the above 4 times changing bits 14:12 each time through the loop' I'll know better later when I've had time to test this.
EDIT: changed conversion register as was incorrect.
EDIT: added a delay between write to config reg and pointer set.