Convert Raw value into voltage in an ADC

Hi,

An ADC (ADS1015 with n=12 bit resolution) is connected to 5V DC power supply. So its V_ref=5V.
However, if I set gain=16, then full-scale-range = +/-0.256V i.e peak to peak voltage= V_pp=2*0.256=0.512V (as given in data sheet Pg 10, Table 3: Reference https://cdn-shop.adafruit.com/datasheets/ads1015.pdf )

In such a scenario, which formula out of the two mentioned below should be used to convert raw data from ADC into equivalent voltage:

(1) V_in = (Raw data from ADC) * (V_ref/2^n) = (Raw data from ADC) * (5/4096)

(2) V_in = (Raw data from ADC) * (V_pp/2^n) = (Raw data from ADC) * (0.512/4096)

Also, in the above two formula, where do we substitute "gain=16" factor?

If somebody could please explain this I would be very much appreciative.

When you say equivalent voltage are you looking at the RMS equivalent of an alternating signal ?
I’m unsure what your formulas mean , but the gain factor is incorporated in the formulas as the the .512 or 5 representing the full scale value of the A/D. Your A/d will provide instantaneous values of the input waveform , you need to be sampling at a high enough rate to be able to have captured a good representation of the input waveform so you can calculate the “ rms” value from the individual samples .( finding pk to pk if it’s a sine wave)

If the signal is a undistorted sine wave then you can relate the peak voltage to the rms voltage .