ADC sampling is not correct

#1

Hi,

I am trying to sample a 60Hz signal with ESP32 that has a value in a range of 0-3.2V. I have a timer that runs every 1ms, reads the value from ADC and stores it in the array. Since the signal is 60Hz so has a 16.6ms period, my array should contain about 16 samples each period but the problem is that I get only 4-5 of them.

Here is my code:

let arr = [];
Timer.set(1, Timer.REPEAT, function () {
    arr[index] =ADC.read(34);
}, null);

And these are some value that I get:
1562
4095
2384
234
187
2297
4095
2781
527
0

I do not understand if it is a Mongoose OS limitation or something else, because in ESP32 docs it says that the sampling rate for ADC is about 6KHz.

#2

The mJS is not able to run a timer with 1ms period.
Move your code in C.