Analog val reading not what its 'meant' to be

I’m slowly going crazy. I’m having a problem where my excel formulas are telling me the analog val (aval) is much higher than what is the output on the Spark core.

https://dd6116b9937b2f787881566cbf21a27b381cc0a5.googledrive.com/host/0B3NyXvs_xmuIfnQ2MlE0aWhVU0NlVENxTEFzeDhxOWNvN09nT25SVHBZYUw3MHppRFNSY00/heater.html#p1t=1&p1r=45000&p2t=1&p2r=22000

You can scroll out the graph with your mouse and move it around by clicking on it. Centre it so you can see the whole thing. The graph enables you to set a fixed resistor and choose the thermistor type. I have the ET-732 piece of crap. According to the maths on the graph, and my maths in my excel (https://drive.google.com/open?id=0B3NyXvs_xmuIa1ZleHhtOUNMaUE&authuser=0), 66Fahrenheit (roughly 19C room temp) should present to the controller as an analogue value of ~3957. That’s nicely within the upper bound of 4095, so the 45k resistor seems to be a good choice.

The trouble is, I’m not seeing anything close to an analog value of 3900 odd, its mostly sitting around the 3100 analog range. Either the coefficients are well out (I took them from Heatermeter and tried numerous versions) or the analog value is for some reason not what it should be.

My circuit is currently simple, a voltage divider resistor (tried 1k, 10k, 20k, 45k, 68k) and a 0.1cu ceramic cap. Using a spark core, ET-732 temperature probe, breadboard. Power via USB or 5v wall wart has been tried.

Suggestions on formula, circuit etc are most welcome

Hi @mterrill

What is the 25 C resistance of the temperature sensor? I have seen some sources online that say it is 1 M ohm at 25 C which will not work with the Core ADC input.

Unlike the Arduino analog inputs the Atmel parts, the inputs to the ST32F105 ARM are not buffered by an op-amp so they have fairly low input impedance (it depends on sampling mode, but 40k ohm is good number). This means that high resistance sensors like a 100k or 1M ohm need a small external circuit to buffer them before the analog input on the processor.

If you use a 10k ohm at 25 C sensor, things will work fine without the op-amp too.

1 Like

Hi @bko,

I do suspect that is the case. My calc is at 25C it’d be 990k with a 45k fixed resistor. My ‘room temp’ of 19C is 1.8M Ohm.

I can’t for the life of me find a Maverick ET-7/-72/-73 set of replacement probes in the country, cheapest option is a full temperature kit @ $90. So I may look into the op-amp. Is this a well trodden path?

My sheet with the formulas using the heatermeter coeffs:

Screenshot:

An op-amp is an easy thing to add–you want a voltage follower where you connect the (-) input of the op-amp to the output, which sets it to unity voltage gain. You then connect your resistor divider to the (+) input and take the output of the op-amp back to the analog input pin on the Core. Easy.

You need a 3.3V capable op-amp and LM358 are very cheap and plentiful, but if you can’t get that any single-supply 3V capable op-amp will work.

Thanks! I’ll see if I can get one at my local store for use tonight.

PS I found the op amp discussion you guys had - the 50k max is highly relevant here. Low ADC Readings

I presume something like this would be ok. LM358 Low Power Dual Op-Amp Linear IC | Jaycar Electronics

1 Like

Hi @mterrill

That will work great! Please note that the picture on that the website is not the chip you are buying but a generic picture. The part comes in an 8-pin DIP package.

Apologies for being a tad slow. I’ve purchased a LM358, and changed the breadboard layout so:

  • 3v3* to 2x 20k resistors (measured to be 39.9k)
  • End of fixed resistor is in the same row as the LM358 Input (+) and the positive wire from the thermistor
  • Thermistor negative wire to ground
  • LM358 input (-) to LM358 output
    -LM358 output to Particle A7 row, 103 (0.1u?) cap to ground

On the particle, I see the same reading pretty much as when nothing is plugged in.

When I connect the LM358 ground to ground, I get anolog val of 1383. Validated there is ~1.1v between ground and A7. This seems like progress, but my old formula suggests its ~126Celsius, and I know I’m not burning.

Should ground be connected? Should v+ be connected to the 3v3* ? When I connect ground and 3v3* I can see the op amp is putting out 2.1v instead of 1.1v.

It’s clear as mud unfortunately :smile:

Hi @mterrill

I think you are missing the power connections to the LM358.

If you the 8-pin DIP package, then connect 3.3V or better yet 3.3V* the filtered supply to pin 8 called V+. Then connect GND to pin 4 GND on the op-amp. There are two op-amps in that package so you should pick pins 1,2,3 OR pins 5,6,7 but don’t mix them.

They are indeed connected.

  • v+ to 3v3*
  • lm358 Gnd (pin 4) to ground

There is 3.2 being fed into pin 3 (input +). The breadboard bridge between input (-) and output reads 2.06v to GND, which is what the particle is seeing.

It sounds like you have a power supply problem of some sort. If the op-amp is hooked up right, the input voltage and output voltage should identical within a very small margin.

Maybe you should try temporarily disconnecting the temp sensor and just tie the (+) input high (+3.3) and then low (GND) and check the op-amp output voltage.

Heh. Can’t find a good reason why it wouldn’t be showing ~3.1v on both sides.

Have pulled out the chip, validated against the sheet the pin 1 marker indent, changed over the breadboard pins.

3.3v* straight to Input+ yields 3.32v

On the output, it keeps showing 2.06v

with nothing on input+, the output still reads 2.06v.

Putting GND directly on input+, the output reads 0.

Putting the resistor and therm back onto the input+, even if I change out the resistor to something much higher (100k) or lower (1k), the output of the op-amp stays rock steady on 2.06. Only by attaching GND to input+ does it change.

[edit for extra info]

By the way, similar to that previous thread you were involved in a few months ago, I see some weird behaviour where the serial out momentarily shows the value it should be showing, ie analog ~3947 which according to my excel formula is 23C, close enough to the instant thermometer I have sitting here saying its 21C

I looked at your wiring in the photo (that really helps!) and I don’t see anything except that you don’t need the capacitor on A7 any more. I am assuming that the white GND wire and orange wire from the bottom of the series resistors goes off to the temp sensor.

The problem where the correct value only came out occasionally was fixed a long long time ago on the core and was a firmware issue.

Do you have a solid power supply like from a 500mA-1000mA USB adapter or a laptop or similar?

Ran up a separate board with:

  • 5v 700mv mobile phone wall wart
  • 0.01uf ceramic and 1uf electrolytic caps in parallel between gnd and vcc

Measured 5.2v from vcc to gnd. from the pin 1&2 unity bridge it measured 3.93v.

Can’t seem to get the little op amp to actually do 1:1. Tried multiple (same model) with same effect.

Interestingly, if I measure a v+ (pin 8) powered and GND’d lm358, the voltage between V+ and output is 1.27v. Coincidentally, this is the difference between the input voltage and output voltage that was previously measured.

If there is no input, it appears to ‘float’ (best analogy I have in electrical terms) to output its ‘full’ 3.93v. If I put a 10k R between input+ and GND then it outputs 0v when nothing else is connected to output+.

Can pin 2 of the LM358 be left floating?

its rather pleasing when after literally 2 weeks of numerous hours a night you finally get it to work.

  • I tried the wall wart into the v+ and 3v3* on the thermistor divider. Got a much higher voltage close to what I expected, but 100ms spaced aval readings were ±50. The average was still 15% below what my formula was expecting.

  • Hooked up the 5.2v wall wart through a DC-DC regulator. It’s meant for 12 to 5, but figured that would clean the signal and get rid of the extra .2v. Hooked it up again to the v+ and bingo the particle was seeing avals just over 4000. Changed the divider resistor back to 40k (had been trying 20k) and the formula spat out 19.46 celsius. Instant thermometer on table says 18.9C so thats a solid win.

I’m a little dubious about hooking 5v up to the opamp v+, as I’m guessing it could push all of that to the innocent A7 pin. Will keep experimenting, but thanks for the posts last night and tips to go op amp. This thermistor (maverick ET-732) is truly a piece of crap but I suppose, after spending triple on parts than buying a commercial pit temp controller, its the learning journey not the destination.

1 Like

I’m guessing not. i understand unity gain mode (ie voltage follower) is triggered by tying pin2 (input-) to pin1 (output)

1 Like