First of all, I’m not really a expert on electronics, so bear with me
I bought a Spark Core Maker kit (will all kind of stuff in it) and I started with the “Measuring the temperature”-sample on http://docs.spark.io/#/examples
I have connected everything the same way as on the photo and flashed my core with the example program.
When I retrieve the values from the input pin I get values around 1300. When I convert this to a voltage I get 1.04v. Convert this into a temperature I get 55 degrees Celsius. I’m very sure, it’s not that hot in here So, what’s going on?
Can somebody tell me what I’m doing wrong? I followed the example to the letter.
Yeah we can’t upload pics directly to the forum either. http://imgur.com seems to work the best for me.
Your wiring looks correct. You might try to replace the jumpers with new ones, sometimes those jumpers can have cold solder joint where the wire connects to the pin.
If you had a voltmeter I would want to know if your A0 pin measures 1.04V with respect to GND. But I’m guessing you don’t.
Does the kit have two 1k ohm resistors? (brown black red gold). If so, remove the Temp sensor, and put one resistor between A0 and GND, and the other between A0 and 3.3*. This will setup a fairly approximate ~1.65V on A0, which we can then compare to the readings from the analogRead().
I hope you’re able to get it working; looking at the example I am not sure how the provided code will convert to celsius from -40C to 125C. Here’s the formula given:
voltage = (sensor_readout * 3.3)/4095 temperature = (voltage - 0.5) * 100
Looking at the datasheet it looks like the max. sensor reading with this formula would correspond to a temperature of ~280C. The sensor datasheet gives a response of 10mV/celsius. With the given formula 10mV corresponds to a sensor readout change of 124, but if the sensor is rated to work linearly from -40C to 125C then those 165 degrees of change correspond to sensor readout from 0 to 20640.
This is one of those cases where I really wish I knew what I was missing, and again I hope you’re able to figure it out soon.
I'm not sure how you got those numbers but hopefully this helps clear some things up...
The TMP36 outputs 0.75V at 25°C, with an output scale factor of 10mV/°C.
Therefore it will output 0.10V at -40°C and 1.75V at 125°C.
With a 12-bit A/D this will give an approximate reading of:
0.10V / 3.3V x 4095 = 124 decimal at -40°C
1.75V / 3.3V x 4095 = 2172 decimal at 125°C
Some problems may be arising from not having a decoupling capacitor across the supply pins of the temperature sensor. Read this note from the datasheet:
Note the 0.1 μF bypass capacitor on the input. This capacitor should be a ceramic type, have very short leads (surface-mount is preferable), and be located as close as possible in physical proximity to the temperature sensor supply pin. Because these temperature sensors operate on very little supply current and may be exposed to very hostile electrical environments, it is important to minimize the effects of radio frequency interference (RFI) on these devices. The effect of RFI on these temperature sensors specifically and on analog ICs in general is manifested as abnormal dc shifts in the output voltage due to the rectification of the high frequency ambient noise by the IC. When the devices are operated in the presence of high frequency radiated or conducted noise, a large value tantalum capacitor (±2.2 μF) placed across the 0.1 μF ceramic capacitor may offer additional noise immunity.
We are basically sticking the temp sensor right next to the Wifi chip antenna, without a decoupling capacitor...
Anyone having problems with readings should try to put a 0.1uF (or larger) ceramic cap directly between pins 1 and 3 of the TMP36.
Thanks for all the responses, but nothing in this topic seemed to work. I finally got it to work by connecting 0.01 μF ceramic cap from the ground to the A0 pin.
Maybe this will help somebody else that has the same problem.
Is there another possible cause for such an error?
I consistently get values which are 4-5 degrees higher than expected, for example a reading of 945, which corresponds to 26° C, but another thermometer in the room says about 21.x° C. I even put the Spark board in my fridge where the values were also 4-5 degrees higher than the fridge thermometer.
I tried to put “caps everywhere”, 0.01 μF between A0 and ground, 0.1uF between pins 1 and 3 of the TMP36, and both, without any impact on the values.
A 10k / 10k resistor divider in place of the TMP36 leads to values around 2055, which is basically as expected.
@Heri, sounds like you are good at troubleshooting If you are getting a consistent 4-5 degree higher than expected offset across your entire usable temp range for the TMP36, I would suggest subtracting 50 to 62 in decimal from your ADC readings to normalize the offset. It’s not uncommon to have to calibrate the offset of a temperature sensor. This is a good problem to have, because it’s easily solved with a known good reference temperature
@BDub, I thought based on the TMP36 datasheet there is no external calibration required, and my measured deviation was beyond the accuracy listed in the datasheet. Am I understanding something wrong there?
@defsdoor, the voltage factor should be 3.3 instead of 3.0.
Can someone please put up a photo of what putting the ceramic cap from GND to AO looks like? Got my training wheels on and some of this is hard to visualise. So a photo or fritzing diagram of the final config would be great! Thanks in advance.
This is the config I have. 0.01uF cap on pin 1, 3 of the TMP 36. Getting all sorts of queer readings so wondering if I have a faulty TMP 36 as it jumps by 1000 units per 5 secs etc etc.