There is no sub call for the ADC reading...
Thank you so much! Problem solved! :)
But I think in the manual is a fault anyway, because it seems that GP27 is allocated to both I2C ports... I2C1 & I2C2 or is this correct? With none of this configs it will work and give always an error. So I switched to GP20 / GP21, this works fine!
Just for reference and the search function, this code works well (even if it might be far from perfect):
'Testprogram for ADS1115 module
'I2C used: SDA=GP20, SCL=GP21
Option explicit
SetPin GP20,GP21, I2C
I2C open 100,5000
Dim float adc0,getvolts,wait=100
SetTick 1*wait,ADC,4
DO
Print "Volts A0 is "; Str$(adc0,0,3)
LOOP
Sub ADC ' ADC reading
Local cfreg,cnv,cfhi,cflo
cfreg = &h01: cnv =&h00 ' rate 128 sps no comp operations
cfhi = &hC3 : cflo= &h81 ' reading single Ain0,FS= +/- 4.096 , 128 sps
I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg
I2C write &h48,0,1,cnv ' adr 48 point to conversion reg
getadc
adc0 = (getvolts+adc0)/2
End Sub
Sub getadc
Local adcv
Local integer adcrd(2) 'to receive 2 bytes
Pause wait/2
I2C read &h48,0,2,adcrd()
adcv= (adcrd(0)<<8) Or adcrd(1)
If adcv > &H7fff Then adcv = adcv - &HFFFF
getvolts = adcv *(4.096/32768.0)
End Sub
-Daniel
Edited 2022-02-14 01:00 by Amnesie