Ads1115 returns value 65535 always

  1. My goal is: have analog pins to read ph values
  2. My actions are: use ads1115 example (https://github.com/mongoose-os-apps/example-arduino-adafruit-ads1x15-js)
  3. The result I see is: all the analog pins returns 65535
  4. My expectation & question is: how to get the correct read of ads1115?

mos call I2C.Scan and see whether it shows an expected device.

According to the datasheet:
The ADS111x provide 16 bits of data in binary two’s complement format. A positive full-scale (+FS) input
produces an output code of 7FFFh and a negative full-scale (–FS) input produces an output code of 8000h. The output clips at these codes for signals that exceed full-scale.
Examples:
input >=FS*(pow(2,15)-1)/pow(2,15), output 0x7FFF
input +FS/pow(2,15), output 0x0001
input 0, output 0
input -FS/pow(2,15), output 0xFFFF
input <=FS, output 0x8000

Single-ended signal measurements, where VAINN = 0 V and VAINP = 0 V to +FS, only use
the positive code range from 0000h to 7FFFh. However, because of device offset, the
ADS111x can still output negative codes in case VAINP is close to 0 V.

Your case is 65535=0xFFFF which is a small negative value.

Do you have a ADS1115 or ADS1015?
If you have a ADS115, you should modify the line

let ads = Adafruit_ADS1015.create(ADS1X15_I2C_addresss);

into

let ads = Adafruit_ADS1015.create_ads1115(ADS1X15_I2C_addresss);

The arduino-adafruit-ads1x15 library returns an unsigned value of the reading instead a signed one.
To deal with the negative values you could use something like this

function twosComplement(value){
  if(value >= 0x8000){
    value = -((~value & 0xFFFF) + 1);
  }
  return value;
}

My readings:

[May  5 14:15:37.319] ADC0:  5862  ADC1:  5863  ADC2:  5862  ADC3:  3112 
[May  5 14:15:38.317] ADC0:  5862  ADC1:  5863  ADC2:  5862  ADC3:  3115 
[May  5 14:15:39.316] ADC0:  5862  ADC1:  5862  ADC2:  5862  ADC3:  3113 

with channles 0,1 and 2 connected toghether to resistive divisor which provides 1.095V and channel 3 uncoonected.

1 Like

… and it might be better to use the “pure” Mongoose-OS lib which is easy to use and works fine: https://github.com/mongoose-os-libs/ads1x1x-i2c