The ESP is a 3.3v device. If your Uno is a 5v device, its A/D converter can measure and report voltages from 0 to 4.9878v (5v minus 1 LSB). If the same signal is presented to the ESP, any value above 3.29919 volts (3.3v - 1 LSB) will read as 4095, i.e., out of range.
(If this isn't your issue, adding wiring diagrams of each system to your question will help ...
The ADC is a "Successive Approximation" type ADC. It works by:
Taking a snapshot of the incoming voltage in a small capacitor
Generating a reference voltage
Comparing the voltage in the capacitor to that reference voltage
Refining the reference voltage
Go back to 3 until you have the accuracy you desire.
There's lots of "time" involved there:
First, let me give a couple of suggestions on the programming style.
There is no point in defining your own variables for accessing the
hardware registers: the avr-libc does that for you, you just have to
#include <avr/io.h>. Actually, you don't have to #include anything:
the Arduino IDE automatically #includes Arduino.h, which in turn