OK, I had some time to play around with this a bit. I wrote a cli php script to query the api once per second and take readings and average them out and gather some data. On the core side, I’m using the exact temperature reading example that’s in the documentation that updates the variable every loop() and exposes the variable through a GET request. I’m also using a 5V 1A micro usb wall wart (that I’ve been using to power my Raspberry PI just fine) for these tests just to make sure it’s not a power issue from my laptop.
My PHP script in case anyone wants it:
#!/usr/bin/env php
<?php
$useCore = "jester";
$coreVoltage = 3.28;
$accessToken = "XXX";
$cores['jester'] = "XXX";
$url = "https://api.spark.io/v1/devices/" . $cores[$useCore] . "/temperature?access_token=" . $accessToken;
$readings = array();
$voltages = array();
while (1) {
$result = json_decode(file_get_contents($url), true);
$reading = $result['TEMPORARY_allTypes']['number'];
$readings[] = $reading;
$voltage = number_format( ($reading * $coreVoltage) / 4095, 3 );
$voltages[] = $voltage;
echo "\n-----------------\n";
echo "Reading Count: " . count($readings) . "\n\n";
echo "Current Reading: " . $reading . "\n";
echo "Current Voltage: " . $voltage . "V\n\n";
echo "Avg Reading: " . (int)( array_sum($readings) / count($readings) ) . "\n";
echo "Reading Range: " . min($readings) . "-" . max($readings) . " (" . (max($readings) - min($readings)) . ")\n\n";
echo "Avg Voltage: " . number_format( array_sum($voltages) / count($voltages), 3 ) . "V\n";
echo "Voltage Range: " . min($voltages) . "V - " . max($voltages) . "V (" . (max($voltages) - min($voltages)) . "V)\n";
sleep(1);
}
Using a 10k/10k resistor divider (not a 10k pot in this case), my multimeter gets a stable reading of 1.643V which is perfect. My 3V3* is 3.28V. Here is the output of my script after 6 minutes:
Reading Count: 360
Current Reading: 2062
Current Voltage: 1.652V
Avg Reading: 2060
Reading Range: 1964-2221 (257)
Avg Voltage: 1.651V
Voltage Range: 1.573V - 1.779V (0.206V)
So the average voltage that the core is reading vs my multimeter is only a .008V difference, which seems totally acceptable to me (It would only result in a 1.44F degree difference). However the voltage range difference from the core is .206V which would result in a 37.08F degree difference. So it seems like in this case, the core is having a hard time with consistency. If you use the average though you can get really close to the correct voltage reading.
Now lets try the same thing with the TMP36 again…
Hooked up the tmp36 (without the .1uf cap), let it normalize for a few minutes and my multimeter is reading .736V (23.6C/74.48F) (Towards the end of the test, the multimeter was showing .727V) Here’s the output after 6 minutes:
Reading Count: 360
Current Reading: 997
Current Voltage: 0.799V
Avg Reading: 1030
Reading Range: 867-1258 (391)
Avg Voltage: 0.826V
Voltage Range: 0.694V - 1.008V (0.314V)
So here, the average voltage reading from the core is off from my multimeter by .09V which really doesn’t seem like much, but it equates to a difference of 9C/24.2F (someone check my math here). The voltage range difference is even larger. It’s a 56.52F degree difference. So in the case of the TMP36, not only is the average off, but the consistency issue is much greater.
Now let’s try the TMP36 WITH the .1uf cap and see if it helps with consistency (multimeter reading is .725V)…
Reading Count: 360
Current Reading: 1044
Current Voltage: 0.836V
Avg Reading: 1024
Reading Range: 859-1230 (371)
Avg Voltage: 0.821V
Voltage Range: 0.688V - 0.985V (0.297V)
So in this case, the voltage difference between the core reading and my multimeter is greater with the .1uf cap. It does seem to have helped the core reading range difference a bit although it’s still a large range.
Is there any other data I can provide that might help?