I have been trying to take basic analog readings with a temperature sensor using the Redboard Artemis and I’m having a hard time understanding how to make these calculations. I have been able to get the sensor to work with the normal redboard using the following code:
voltage = analogRead(tempPin) * 0.004882814;
degreesC = (voltage - 0.5) * 100.0;
degreesF = degreesC * (9.0 / 5.0) + 32.0;
But how would I be able to do this conversion with the Artemis? Any help would be appreciated.
Thanks for reaching out to us on this.
The Redboard uses 5v signals for I/O https://learn.sparkfun.com/tutorials/re … 1615791300, the Artemis uses 3.3v https://learn.sparkfun.com/tutorials/ho … 1615791300
If the sensor is working with the redboard, it is likely 5v…switch to a 3.3v sensor or step-down the voltage entering the Artemis.
Hope this helps, and happy sparking!
I have tried using 3.3 V from the artemis into the sensor and I have also tried using a voltage divider to input 3.3 V into the sensor but neither worked. I am still reading temperatures of around 70-80 C. Is there anything else different about the Artemis that would interfere with analog inputs?
If you measure the output of the TMP36 with a multimeter, is it the expected voltage?
If your goal was to scale the ADC output so that the max 12-bit value represents the 2.0V ADC reference voltage, then I think your scaling constant is a factor of 10 off. Let the compiler do the math for you:
analogRead(tempPin) * (2.0/4096);