This message was posted on behalf of Intel Corporation
I believe the code translated to C should look like the following:
float adc_value = 0.0;
const int B=4255;
adc_a0 = mraa_aio_init(0);
if (adc_a0 == NULL)
adc_value = mraa_aio_read_float(adc_a0);
float R = 1023.0/(adc_value)-1.0;
R = 100000.0*R;
printf("It is : %f\n degrees",temperature);
Nevertheless, I don't have access to that sensor so I didn't try it. I did compile it and run it, but as expected the values were negative (~-90) because there was nothing connected. The ADC should be working but I'm not sure about the math, I just copied and pasted that part.
I hope this helps.
I think our codes are almost exactly the same.
Except that you use mraa_aio_read_float(adc_a0); and I mraa_aio_read(temp) so I compared it:
As you can see my temperature readings are also wrong even thought I have plugged temp sensor in.
My aios initialization are in separated function, nevertheless it is called before get_temp_in_celcis().
Thanks for support,
Ok, I changed VCC to 5 V. Now my algorithm (with reading to int) seems to return proper values.