Tried Hacking 1 Therm Sensor Code into 5 Therm, no luck

Today I tried modifying Tombrew’s (instructables) Tempbug code to work with 5 thermistors, rather than just one. I basically copied and pasted 5 times the bulk of the sensor reading, calculation and output code and just changed the read pin every time. Tombrew’s original code had a thermistor read on pin 8, with pins 9 and 3v3 used for calibration.

I assumed that if I added another thermistor, I could read the next available pin (say 7) and use pins 9 and 3v3 in the same way they were used to read the first thermistor on pin 8. My attached code works fine to read a single themistor, even though I have it attached to my homemade wiring harnesses on pins 9 and 3v3 (see attached diagram). But if I add 2 thermistors at one time (as diagram shows), the output temperatures for each seem to be low by about 1/2 value, but identical.

Anyway, I’m trying to make an Imp which reads 5 thermistors. If anyone has thoughts on the best way to do this, I’m all ears. Thanks.

The Sustainability Workshop
Ithaca, NY

Hi there,

Looks like you’ve just wired it up backwards. The sense pin for each divider needs to go in the middle - between the thermistor and the resistor. Take a look at the schematic on the instructable again.

To get started with your circuit, just wire it up as simply as possible. I’ve attached a photo of a simple schematic. You can wire the bottom of the divider directly to ground if you’re not worried about battery life; the pin8-as-enable-pin technique was used in the instructable to save battery.

I’ve also moved the code from the instructable to a class. You can configure the class for thermistor-on-top or thermistor-on-bottom of the divider. You can instantiate the class many times to use many thermistors. This should make your code a lot simpler. The code is here:

Hope this helps!

Ah! I see I’m actually being ambiguous about “backwards”, too. What you want to do is use one enable pin and many sense pins. If you use one sense pin and many enable pins, the equivalent resistance of the top of the divider changes, because current flows through the top halves of all the dividers regardless of which one is turned on (because they’re all tied together in the middle with the sense pin). Again, pictures attached!

This, hopefully, is more helpful.

Wow! Thanks. This is awesome. I really appreciate your help. I’ll let you know how it turns out next time I have a chance to work on this. If you ever find yourself in Ithaca, NY you have a few free beers coming your way!

Thanks again!

Hey Tbuttner,

Just an update, and another thank you. Your extra explanation about wiring the thermistors and watching my sense/enable pin assignments was the key. Thanks for emphasizing it.

It is very rewarding to have an Imp on Xively posting 20 second temp readings for 5 individual thermistors. I could not have done it without you. You rock.

The Sustainability Workshop
Ithaca, NY 14850

Thank you so much! I’m so glad it’s working the way you want. Good luck with your project!

I’m from Syracuse originally and my family is still there, so I may need to swing by and take you up on that beer offer :wink:

Southern Tier IPA! BTW, Tom, I got my wings in '99 at the Corning/Painted airport. Spent lots of time flying over the Finger Lakes region…and skiing at Greek Peak.

how did you get it show up with multiple graphs on Xively. im a noob here and im looking to do this i just have no clue on the coding cause i have very little coding experience

You have to set up multiple channels in Xively, and then send that channel information from the agent. I like to put the information in a table when I send it to the agent, like this:

local probetemps = {"probe1temp" : probe1temp , "probe1reftemp" : probe1reftemp, "probe2temp" : probe2temp, "probe2reftemp" : probe2reftemp}; agent.send("Xively", probetemps)

Then at the agent you made multiple channels and send them like this:
device.on("Xively", function(v) { channel1 <- Xively.Channel("Grill_Temperature"); channel1.Set(v.probe1temp, ""); channel2 <- Xively.Channel("Food_Probe_Temperature"); channel2.Set(v.probe2temp, ""); channel3 <- Xively.Channel("Grill_Temp_Reference"); channel3.Set(v.probe1reftemp, ""); channel4 <- Xively.Channel("Food_Probe_Temp_Reference") channel4.Set(v.probe2reftemp, ""); feed <- Xively.Feed("111111555555", [channel1, channel2, channel3, channel4]); client.Put(feed); });

Note that I am using the latest version of the Xively class that takes a “Tag” parameter as well with each channel. Mine are empty strings, but the parameter is required.

Got it. Thank you! I now have 6 thermistors updating every minute. Now to hook this up to my shop built solar HW system. I see there is a small fluctuation between display temperatures. +/- 1 degree. I used the parts on the instructable. Everything is still on my breadboard. Is this acceptable?

That is entirely up to you. I wrote a tutorial for Adafruit that uses thermocouples to monitor very high and low temps. You may want to look at using them, as you can get various probes, including stainless steel insertion probes. Companies like Omega, and Thermoworks have lots of different thermocouples. The downside is that they are more expensive and more difficult to read. I am currently working on a tutorial for a handheld dual probe thermocouple temperature monitor.

What do you mean by fluctuation? The thermistors have different readings? You’ll find that there is a margin of error in all sensors…some worse than others.