Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:58 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Temp LM335 voltage fluctuations

     Page 1 of 7    
Author Message
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 07:37pm 06 Mar 2018
Copy link to clipboard 
Print this post

Dear folks! I see it's been almost four years since I last posted.

First an update on the MM powered Wood-Fired Boiler. It has been running flawlessly now for over six years. Yahoo Maximite! I'm getting older though and find spending summers collecting 12 cords of firewood more than I want to do for the rest of my life. So this past summer (June-July 2017) I built an electric boiler. It too is run by the MM and I modified the software just a bit so it could do both the electric and wood-fired boiler.

I am just finishing up a winter test of the electric boiler, and it also worked just fine being run by a MM. Now I'm setting out to build a dedicated MM for it with a control board and three temperature sensors and a 12 volt battery sensor, two relays too. I want a control panel in the house so the time periods and house thermostat temperature can be adjusted indoors, unlike the wood-fired which was controlled out at the firebox.

So here is my question. I built a MM with a component board, numeric keypad and a small 5" monitor. I have written most of the software that relates to the three temperature sensor/voltages: House, Outdoor and Boiler temp. I used 1.8 K Ohm resistors for the House and Outdoor, and a voltage divider for the Boiler water temp (so it will read up to and slightly above 100 c (this is not a pressurized system). What I'm finding is that I get fluctuating voltages from the three sensors. They vary more than I want. The outdoor sensor fluctuates between -5C and -8C all within one minute. This seems a bit much.

I created an averaging loop that collects sensor readings every 50 loops (8 seconds), and then different numbers of those loops for sensor averaging depending on how many data points I want to average for each. The outdoor sensor is set for 5 or (50 loops x 5 or 250 program loops) or about 40 seconds. Even so, I'm still getting more fluctuation in the LM355 sensor loops that I want. I'm averaging the House sensor 2 (50 loops x 2 or 100 program loops) or about 16 seconds. Similar with the Boiler temp average.

As some of you may recall, I'm no electronics guy. I have pin boards and a good collection of components, but I really don't know how to tackle this. Is there some way that using components I can even out the voltage on each of the LM335 Temp sensor circuits? Would a capacitor accomplish this? Seems like there must be a better way than attacking this problem via software. If a capacitor would work, what rating would I need, and where would it be wired on? On the two simple 1.8 K Ohm sensor circuits, these are so simple that I might be able to figure that out without a schematic.

Am I thinking in the right direction? I don't recall having such fluctuations in the wood-fired boiler sensors, which are also three, one being on a voltage divider for the higher temperature boiler water and the other two 1.8 K Ohms. I do have temperature averaging routines on it too, but I don't recall ever seeing fluctuations this large in such short periods of time.

So, is there some way that I can even out the voltages in these LM335 temp sensor circuits so they don't bounce around so much?

Any thoughts are welcome. Thank you for all the help in the past. My first project back in 2011/12 turned out really well. I think this one will too.

I still have two brand new MM SD1's, four CGStick1 MM's, a CGStick Color MM, and one other. I wonder what kinds are being sold these days? Just curious. I think I have enough for the rest of my life.

Cheerio!

Pete in Hyder Alaska
We're all here 'cause we're not all there.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:27pm 06 Mar 2018
Copy link to clipboard 
Print this post

Hi,
We thought you had finally been taken by one of those bears you have in the garden.

You are right the LM335 shouldn't vary that fast. It's internals don't respond that quickly even with a rapid change in the environment.
Check your supply voltages, both 5V and 3.3V for any fluctuations.

Consider changing to the DS18B20 temperature sensor.

Jim
VK7JH
MMedit
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 09:38pm 06 Mar 2018
Copy link to clipboard 
Print this post

Helo Tassy Jim

I have these voltage fluctuations on both a MM and a CGStick1 that I've been using to test these three LM335 sensors.

On the CGS1 the 5 v leg usually shows 5.07 volts, but sometimes goes up to 5.08.
On the CGS1 the 3.3 v leg usually shows 3.3 volts, but occasionally goes down to 3.29. My volt meter only reads to two decimal places.

I don't know if this is abnormal or not. I never checked this closely before.

I looked at the DS18B20 sensors just now. Do they wire in the same (two wires) and will they work with 1.8 K resistors? Some ebay sellers say you need some kind of Library to use these? I have no idea what they are talking about. Would you recommend getting the bare sensor, or the ones already shrouded in a waterproof end tip with a 1 meter lead wire? I like the small size when I make my own, they fit into the boiler tube easily. I'm not sure the pre-built ones would.

I have not checked voltage stability yet on the 3.3 & 5 volt pins on the MM.

Does this voltage variance on the CGStick1 seem within good operating specs or might that have been the reason for the fluctuating voltage readings?

I don't understand why the LM335's would be like this. I bought a dozen or so back in 2012 so I'd have plenty. I solder them to their wires pretty quickly. I wonder if I cooked them?

We're all here 'cause we're not all there.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 09:59pm 06 Mar 2018
Copy link to clipboard 
Print this post

Hi Peter,

The DS18B20 is very easy to use thanks to MMBASICs built-in support.

It is a three pin device - simply feed it power (between 3v3 and 5v) and have a 4K7 pull-up resistor on the third pin (this simple circuit is in the User Manual).

Then to read the temperature use the TEMPR(pin) command.

This temp sensor does not rely on a voltage measurement - instead it is digital data sent via a 1-wire protocol. For this reason you will not see any 'fluctuations' that you are seeing with the LM335s.

NO library is needed for the DS18B20.
Use whatever you can get hold of quickest/easiest. The shrouded type is technically the same as the 'naked' type!

Just out of interest - can you clarify how you are powering this setup!

WWEdited by WhiteWizzard 2018-03-08
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 10:20pm 06 Mar 2018
Copy link to clipboard 
Print this post

Thank you WhiteWizard,

For now I'm powering the MM and CGStick1 via little USB 120 volt wall power supplies. These are capable of 2.1 Amps at 5 volts (so they say).

I'm not sure what Manual you mean. My MM manuals don't show any TEMPR(pin) commands so perhaps this sensor won't work on old MMSD1 or CGStick1 varieties?

I am such a novice. An old newbie I guess you might say. I don't even know what a 4K7 pull-up resistor is. I know what a 4K resistor is, but the 7 on the end throws me, and I'm not sure but is the pull-up reference because it is used to pull the voltage up?

Sorry, I just have such limited understanding.

Thank you for trying to help me though.
We're all here 'cause we're not all there.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 10:26pm 06 Mar 2018
Copy link to clipboard 
Print this post

Hi again,

Sorry - I assumed you were using a MicroMite - but your reference to 'MM' means MaxiMite! Apologies for any confusion I may have caused you.

What version of MMBASIC do you have running on your MaxiMite? You should see this in the 'Welcome' message on Power-up/Reset.

My reference to a 4K7 resistor simply means a 4.7K resistor. Pull-Up relates to it being connected between the DS18B20's Data (output) pin, and +V

Let me know what version of MMBASIC you have and we can then see what commands may be available to you

WW

 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 10:31pm 06 Mar 2018
Copy link to clipboard 
Print this post

IF you have MMBASIC v4.5 then the TEMPR(pin) is replaced by DS18B20(pin)

Look on Page 10 of the current v4.5 Language Manual - link here . This shows the simple circuit I was referring to; along with the command syntax.

Hope this helps!
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 10:45pm 06 Mar 2018
Copy link to clipboard 
Print this post

The Maximite SD1 is running MMBASIC 3.0. I didn't reboot the CGStick1 as it is running a daily high/Low test which I'l compare with another known accurate temp sensor set (on the Wood-fired Boiler), but I got all these within six months or so in 2012 so it is probably also running MMBASIC 3.0.

Hope this helps. Thanks for the lesson in 4K7 nomenclature.
We're all here 'cause we're not all there.
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 10:51pm 06 Mar 2018
Copy link to clipboard 
Print this post

Yes, my Circuit Gizmo CGStick1 models all run MMBASIC 3.0. I looked at the PDF Manual I got with them.
We're all here 'cause we're not all there.
 
redrok

Senior Member

Joined: 15/09/2014
Location: United States
Posts: 209
Posted: 05:03am 07 Mar 2018
Copy link to clipboard 
Print this post

Hi pcaffalldavis;

The LM335 is both reliable and stable.
This is more or less an "Old School" device that outputs temperature in degrees K, or Kelvin. 10mV/°K.
373°K = 100°C = 212°F = 3.73V
330°K = 57°C = 135°F = 3.30V
271°K = 0°C = 32°F = 2.73V
I suspect you are reading this voltage using an analog voltage pin which has a voltage range of 0V to 3.3V.
The highest reading you can do is 57°C.

Unless there is additional circuitry, say a voltage divider or Op-Amp, you will not be able to read higher temperatures.

I usually add a 1uF capacitor directly cross the LM335 and another at the analog pin.

Use a twisted pair out to the sensor.
And a pullup resistor, probably 2K or so, to 5V at the micro end.
Even better, if needed, use shielded twisted pair wire and ground the shield at the micro.

The Digital temperature sensors such as the DS18B20 have built in code on the MicroMite. However, I don't know it ver 3.0 has this.

redrok
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 12:45pm 07 Mar 2018
Copy link to clipboard 
Print this post

Thank you RedRock,

Yes I'm running these sensors on analogue 3.3 volt Maximite pins. I'm using speaker wire to run to the LM335's. They are not shielded but I live far out in the woods and there are no radio or TV signals here to give you an idea how pristine our electrical wavelength environment is. I will try putting caps across the sensors and the MM pins and report back.

I used 1.8 K for the two sensors for House and Outdoor, and a voltage divider for the Boiler temp sensor. I'll try 1uF caps on all of these and see if that helps.

Thank you!

Peter
We're all here 'cause we're not all there.
 
Boppa
Guru

Joined: 08/11/2016
Location: Australia
Posts: 814
Posted: 01:34pm 07 Mar 2018
Copy link to clipboard 
Print this post

  pcaffalldavis said   I'm using speaker wire to run to the LM335's. They are not shielded but I live far out in the woods and there are no radio or TV signals here to give you an idea how pristine our electrical wavelength environment is.


  pcaffalldavis said   For now I'm powering the MM and CGStick1 via little USB 120 volt wall power supplies. These are capable of 2.1 Amps at 5 volts (so they say).


Not quite as pristine as you may believe, you could have a very 'noisy' electrical environment, just from appliances in your own home (plugpacks/wallwarts are mostly switchmode powersupplies, and cheap ones (and some expensive ones too) can be some of the worst contributors to electrical noise, and they can be found in almost all modern appliances. Add in electrical motors etc, and your local area might be quite noisy electrically
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 02:11pm 07 Mar 2018
Copy link to clipboard 
Print this post

I did not realize that. If the 1 uF caps don't take care of the voltage fluctuations I'll look into getting some more shielded twisted pair wire.

Thank you!
We're all here 'cause we're not all there.
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 03:11pm 07 Mar 2018
Copy link to clipboard 
Print this post

  pcaffalldavis said   Helo Tassy Jim

I have these voltage fluctuations on both a MM and a CGStick1 that I've been using to test these three LM335 sensors.

On the CGS1 the 5 v leg usually shows 5.07 volts, but sometimes goes up to 5.08.
On the CGS1 the 3.3 v leg usually shows 3.3 volts, but occasionally goes down to 3.29. My volt meter only reads to two decimal places.

I don't know if this is abnormal or not. I never checked this closely before.

Don't worry. That's absolutely normal!

  Quote  The outdoor sensor fluctuates between -5C and -8C all within one minute. This seems a bit much.

I'm not sure if this must be an error!
The LM335 is very sensitive and air movements (aka wind) can probably show such behavior too. To say there is something wrong you have to build a controlled test enviroment (At least put that sensor in a closed box!).

For MMBASIC 3.0 and the DS18B20 exist a Basic code example in the MMNasic-library (1WDS1820.BAS 29 March 2012 By Ian Delaney).

I hope you will find a solution soon!

Kind regards
Michael
causality ≠ correlation ≠ coincidence
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 05:07pm 07 Mar 2018
Copy link to clipboard 
Print this post

I put a 1uF cap on the breadboard where the sensor wire and the Maximite pin jumpers both connect. Still showed a variation of 4C within two minutes. This is not accurate, my other temp sensors outdoors (on another MM) show no such fluctuations beyond one degree, and that would be probably when the temp actually changes.

I wonder if I should be putting the cap right out at the end of the wire with the LM335 instead of at the breadboard?

I don't have any shielded twisted pair wire but I can order some. What size would be good for this. I would like wire lengths of up to 50' on two of the sensors. Does shielded 22 gauge sound large enough for a 50' run at about 3 volts?
We're all here 'cause we're not all there.
 
redrok

Senior Member

Joined: 15/09/2014
Location: United States
Posts: 209
Posted: 06:27pm 07 Mar 2018
Copy link to clipboard 
Print this post

Hi pcaffalldavis;

I reread your original post. And see you said you have a voltage divider for the 100°C sensor. In addition to the 1.8KΩ pullup what are the divider values?

What is this divider made with?

Note! The pullup must go to +5V.

I like using 1uF but 0.1uF would also work well, I presume.
This capacitor should be a ceramic type as they have very low leakage currents.

This capacitor provides the low impedance needed by the analog input. The impedance spec is a max of about 5KΩ. Since the measurement takes about 200nS which has an impedance of about:
Modified impedance formula for pulse widths:
1/ ( 2pi * Frequency * C )=Xc
1/ ( 2pi * ( 1 / Period ) * C )=Xc
1/ ( 2pi * ( 1 / ( Time * 3.75 ) * C ) )=Xc Note, the 3.75 is a way to convert Time into Period!
1/ ( 2pi * ( 1 / ( 200nS * 3.75 ) * 1uF ) )=Xc = 0.119Ω
1/ ( 2pi * ( 1 / ( 200nS * 3.75 ) * 100nF ) )=Xc = 1.19Ω
1/ ( 2pi * ( 1 / ( 200nS * 3.75 ) * 10nF ) )=Xc = 119Ω

The internal voltage divider, in the AtoD converter, is connected between Vcc and Gnd. Any noise on Vcc will show up in the reading. A good way to compensate for this is to divide the capacitor between Vcc and Gnd.
In your case, where one capacitor is placed across the remote sensor, the second capacitor should be placed across the 1.8KΩ pullup.
On the 100°C sensor a pair of 10KΩ voltage divider resistors can be connected to the analog input. The pair of 10KΩs look like 5KΩ to the input.

Here is a Code Snippet that can be used to read the voltage
and do "Running Averaging".
' Temp.bas
Setup:
' Gain and Offset
Vcc = 3.3
TempCalK1 = 1 / Vcc * 373.15 : TempCalK2 = 0
TempCalC1 = 1 / Vcc * 373.15 : TempCalC2 = -273.15
TempCalF1 = 1 / Vcc * 373.15 * 1.8 : TempCalF2 = -459.67
' Tracking Average calculation factors
RunAveFac = 5 ' 1 to 25 or more
RunAveFac1 = 1 - ( 1 / RunAveFac )
RunAveFac2 = 1 - RunAveFac1
Main:
' TempV = "read the sensor value in Volts"
Input "Temp Volts" ; TempV
TempK = TempV * TempCalK1 + TempCalK2
TempC = TempV * TempCalC1 + TempCalC2
TempF = TempV * TempCalF1 + TempCalF2
AveTempK = AveTempK * RunAveFac1 + TempK * RunAveFac2
AveTempC = AveTempC * RunAveFac1 + TempC * RunAveFac2
AveTempF = AveTempF * RunAveFac1 + TempF * RunAveFac2
Print Str$(Vcc ,1,3);"Vcc ";
Print Str$(TempV ,1,3);"V ";
Print Str$(AveTempK,3,2);"K ";
Print Str$(AveTempC,4,2);"C ";
Print Str$(AveTempF,4,2);"F "
GoTo Main

Have fun!!
redrok
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 06:29pm 07 Mar 2018
Copy link to clipboard 
Print this post

Please bring one sensor indoor, and see if you can see a similar change in temperature.

Volhout
PicomiteVGA PETSCII ROBOTS
 
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 07:01pm 07 Mar 2018
Copy link to clipboard 
Print this post

I have the house sensor on the computer bench pinned to the breadboard in the back room. It has only a 1 foot wire from the breadboard and lays on a marble table insert for soldering so temp there doesn't fluctuate much. No wind either. In the past three minutes I saw readings of 12, 13, 14, 15 & 16 C. I know this is not correct. My project screen displays F, but before I came back to this group I added small displays of C so we could communicate easier. I think I'll keep both F & C on the display as it is informative. Anyway, I don't think such a short sensor wire would have EMF effect that might cause that much fluctuation. I worked on trying to resolve this over a week before coming back to the group for help. Can't say I don't try!

Anyhow, I'm still stumped.

Regarding the Cap I used, It is a can cap.

The voltage divider sensor circuit is the least important. It is reading the electric boiler temp but is informational only at this time. It is reading 52 C right now, below 52 it will turn off a fan allowing the boiler temp to rebuild. I don't have this relay built yet. The high temp each day for this boiler water temp circuit is about 90C most nights when the house thermostat is turned back. The old Wood-fired boiler/MM is still handling fan control even though the water is being heated by electricity today. It probably fluctuates too, but a fluctuation of four or five degrees in the boiler is something I can't discern.

It will be the House temp sensor that will control the fan when this stand-alone unit is finished. That is why I need a fairly reliable and non-fluctuating House temp circuit. I only display period high and low temps for Outdoor temps. That is how I noticed the fluctuations so readily on a new boot. I get fluctuations in both house and outdoor temps of as much as 5 C in the first two or three minutes.
We're all here 'cause we're not all there.
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 07:17pm 07 Mar 2018
Copy link to clipboard 
Print this post

Peter

can you please compare the voltage at the MM input pin and your multimeter?

Or what's happened if you set the input voltage to 1/2 Vdd (voltage divider)?
What shows your multimeter. What shows the MM analog input?

EDIT:
  pcaffalldavis said  Regarding the Cap I used, It is a can cap.

Remove the can cap (or replace it with a ceramic cap).

BTW. did you read the LM335 datasheet? It's always a good idea!

The Maximite CPU PIC32MX795 also has a Vcap PIN like the MicroMite. Maybe the capacitor on the Maximite (or the connection) is faulty? That's just something to check.

What I wanted to say is: Just check if your analog input reads correctly. Edited by twofingers 2018-03-09
causality ≠ correlation ≠ coincidence
 
LouisG
Senior Member

Joined: 19/03/2016
Location: Australia
Posts: 129
Posted: 07:55pm 07 Mar 2018
Copy link to clipboard 
Print this post

RedRock said "Ground the shield to the micro".

Easier said than done. Where on the micro is ground? The micro is running off a plug-pack.

Put an earth stake into the ground? Connect to the earth pin on the wall outlet?

I myself have often wondered how to accomplish this.



 
     Page 1 of 7    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025