Grove-Temperature Sensor V1.2 and M5StickC

I bought the Grove-Temperature Sensor V1.2 and connected to M5StickC (https://m5stack.com/products/stick-c). I copied almost all the code from the specs page to convert the analog read to actual temperature, only adding the #include <M5StickC.h> and the M5.begin, but the temperature is way off and very oscillating. I am using pin 32 to read the data, Is it correct? Is it a sensor issue?

For example, a sample output is:

42.42
44.15
42.42
42.85
42.96
45.96
46.07
44.38
44.15
42.74
43.50
42.42
44.15
44.49
42.42
45.16
49.58
42.85

And the code is:

#include <M5StickC.h>
#include <math.h>

const int B = 4275; // B value of the thermistor
const float R0 = 100000;
const int PIN = 32;

void setup() {
M5.begin();
Serial.begin(9600);

}

void loop() {

int a = analogRead(PIN);

float R = 1023.0/a-1.0;
R = R0*R;

float temperature = 1.0/(log(R/R0)/B+1/298.15)-273.15; // convert to temperature via datasheet

Serial.println(temperature);
delay(500);
}

Thanks,
Fernando Gonzalez Sidders

Sorry, we are not familiar with M5stack. This code is strange. This sensor only use the analog interface. M5.begin(); What does it do here?