When a resistance R1 is connected across the terminal of a cell, the current is I1, when the resistance is changed to R2, the current is I2. The internal resistance of the cell is:
I2R2−I1R1I1−I2
I1=Er+R1I2=Er+R2I1I2=r+R2r+R1I1r+I1R1=I2r+I2R2r(I1−I2)=I2R2−I1R1r=I2R2−I1R1I1−I2