According to your 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.

This seems to mean that it is actually a 15-bit converter and that bit 16 represents the sign.

On the Internet I have seen somewhat confusing subroutines to measure AC voltages, for example:

Code: [Local Link Removed for Guests]

```
read_ADS:
for n = 1 to 1024
i2c.read_iobuff(0), &H48, 0, 2
sample = iobuff.read(0,0) << 8 + iobuff.read(0,1)
if sample > 32768 then sample = sample - 65536
offset = (offset + (sample-offset) / 1024)
filter = sample - offset
sqV = filter * filter
suma = suma + sqV
Amp = sqr(suma/1024) * 0.0000625 * 30 * 1.33
next n
suma = 0
return
```

Code: [Local Link Removed for Guests]

```
ADS1115_addr = &h48 : ADS1115_conv = 0 : ADS1115_conf = 1
i2c.setup 4, 5
iobuff.dim(0,2) = &B00000110, &B10100011 ' Mux = 0, Gain = 1.024V, Rate = 250 SPS, Comparator disable
i2c.write_iobuff(0), ADS1115_addr, ADS1115_conf
volt = 230
factor = 30 ' 30 Amp = 1 Volt
adjust = 704 ' empirically
tracker = 1
WHILE 1
t= millis
do while (millis - t) < 1000
if tracker = 1 then duration = millis
Vmax = 0
for n = 1 to 250
i2c.read_iobuff(0), ADS1115_addr, ADS1115_conv, 2
Vins = iobuff.read(0,0) << 8 + iobuff.read(0,1)
if Vins >= 32768 then Vins = abs(Vins - 65536)
if Vins > Vmax then Vmax = Vins
next n
Vmax = convert.map(Vmax, 0, 32767, 0, 1.024)
Vmax = Vmax * adjust
Amp = Vmax * factor
Wat = (Amp * volt) / 1000
if tracker = 1 then
duration = millis - duration
wlog duration
wlog time$, str$(Vmax, "%3.2f"); " mV", str$(Amp,"%3.2f"); " mA", str$(Wat,"%4.2f"); " W"
end if
loop
WEND
```

Am I correctly converting negative values and convert.map ()?

In general, are the concept and formulas that I use adequate?

I have obtained the value of the "adjust" variable by measuring the voltage at the terminals of the SCT013 using a digital multimeter on the millivolt scale true RMS.

And by connecting old (and currently banned) 230V (25w and 40w) incandescent bulbs, a hair dryer, a toaster, etc.

But for what is measured in the voltmeter to coincide with what is measured by the program, despite the correction factors, I am still missing something.

Can you think of something that can help me?

Thanks.