loading

Most of you have heard the expression ‘Hot Air Rises’. Well, it’s true.

So in your typical house, it’s going to be hotter near the ceiling than near the floor. How much hotter?

Well, being a Lazy Old Geek, I wanted to know how much. Well, that’s easy, I just point my IR thermometer (See picture) up in the corner and down at the floor. Okay, it reads 82 F at the ceiling and 75 F on the floor. All done.

But wait a minute. This is during a sunny warm day. What about when the A/C is on? What about when the heater is on during the winter? This calls for an Arduino!

Step 1: Parts List

1 Arduino RBBB $10

Arduino USB$5
https://www.instructables.com/id/Arduino-USB/

6 KTY81-250 Temperature sensors $0.45@Mouser.com
6 1.2K resistors $0.01@ Taydaelectronics.com
25ft Ethernet cable $3.48 ebay.com
10ft ½” PVC $2.70 Home Depot

Well, I had an Arduino RBBB lying around. See picture.

And I recently bought a bunch of KTY81-250 temperature sensors. See picture. I bought these because they were cheap and two leads only. I also had a 25 foot Ethernet cable lying around.

Total cost is around $23.

Step 2: Sensor Design

So here’s my physical/mechanical plan. I decided to use some KTY81-250 temperature sensors to measure temperatures from the ceiling to the floor. My ceiling is about nine feet tall. The basic Arduino is limited to six analog inputs so I decided on six sensors. So I spaced the sensors about 1.8 feet apart.

Ethernet cable has eight wires in it. The KTY81-250s are two wire sensors but one can be ground so I used six wires for the sensors and two for ground. So I hacked it up as follows:

Here’s the color code scheme, I selected:

Sensor

RJ45

Common

5

Brn/Wht

Brown

4

Grn

Brown

3

Grn/Wht

Brown

2

Blu/Wht

Blue

1

Org

Blue

0

Org/Wht

Blue

For the sensor on the top, I just stripped back the wires and solder the first KTY81 to the Brn/Wht and Brown wires. It doesn’t matter which lead goes to which. I used hot glue to insulate and support the leads.

The pictures show how I spliced in the other KTY81 sensors.

First I marked the cable approximately every 1.8 feet for the sensor locations with a Sharpie. Using a utility knife I carefully cut about an inch on each side of the mark. Carefully cut along the insulation and remove it.

In my cable there is some nylon braiding for strength. (See picture) I just cut it away. There is also some blue colored aluminum foil for noise reduction. This is not a concern in this application so just peel it away.

Now you should see the wires plus another bare wire that is for strength and grounding. (See picture) The wires are in twisted pairs. Find the two colors for this sensor and try to separate them to give you some access. Now, carefully remove the insulation on these two wires. Try to keep the cuts a little separated from each other so they can’t short together.

Solder on the KTY81 sensor as shown.

I used hot glue to insulate and support the sensors and to add strength to the cable.

Repeat the process for the other sensors.

Step 3: Electrical Design

The KT81-250 Temperature Sensor is basically a resistor whose resistance changes with temperature. At room temperature the resistance is about 2000 ohms. The Arduino can’t read resistance but can read voltage so I built a voltage divider with 5 volts going to a 1.2K resistor then to the KTY81 sensor to ground. The connection between the resistor and sensor is attached to the appropriate Analog input of the Arduino. There are six of these circuits as shown in the schematic.
The schematic also shows an 8.2K resistor going from 3.3V to Aref. I had a good reason for using an 8.2K resistor but don’t remember. It works fine. The Arduino software has to use analogReference(EXTERNAL) to use this.

THEORY: The 1.2K resistors were selected to yield the best resolution for the Arduino. The resolution is about 0.6 degrees F. This means the Arduino can only detect a change of 0.6 degrees. The Arduino has a 10 bit resolution so there are only 1023 different steps. The resistor was also selected so that the temperatures between 50 to 100 degrees F will be less than 3.3V and readable by this Arduino.

Six resistors are connected to the Analog inputs. The other ends are tied to 5 VDC. The Ethernet cable is wired to the Analog inputs and grounds. (See pictures)

Step 4: Problems

I will get back to the calibration step later.

Problem: Well my first attempt was a disaster. The temperatures were all over the place and not very stable.

Solution1: One of the problems was that I was powering the Arduino with 5V from the USB port of my computer through a 4 port hub. Well, this voltage measured about 4.65V and varied a lot. So I added a 5Volt regulator and capacitors and a 6 Volt power supply. See schematic.
Some of you sharp-eyed readers will notice that the power supply (See picture) is rated at 6 VDC output and that the 7805 regulator is specified for a minimum of 7 VDC. Well, most of these power supplies actually put out more voltage than rates. With this one hooked up, the output was 7.5VDC and the regulator output was a consistent 5.1VDC output.

Solution2: The software I first wrote sampled the temperature 10 times, averaged it then output it. It repeated this every minute. Well, I decided to implement a rolling average. The way this works is that it samples the voltage constantly and averages the last 25 samples and outputs it.
Programmers: I created a 25 element array for each sensor and a pointer to the array.
float TempArray[NUM_SAMPLES][MAX_TEMPS];
byte ArrPtr=0;

Then I read in the counts for each sensor and stored it in the array bin pointed to by the ArrPtr.
Then I incremented the ArrPtr++ and repeated the process. If the ArrPtr = 25 then it is set to 0.

Each array is summed and averaged by dividing by 25, then this averaged count value is converted to a temperature.

This is like a low pass filter. The sensor is averaged over about 50 seconds. The temperature shouldn’t change significantly in that period of time.

Step 5: Calibration

I’ve worked with temperature sensors before. I know they are hard to calibrate especially in air. It is very hard to get them to within a degree F of each other.

As with most temperature sensors, the KTY81s are not very accurate and need to be calibrated. For example, the resistance at room temperature can vary from 1900 to 2100 ohms.

If you want to build this, then you will need to calibrate your sensors. This involves Algebra, maybe a game killer for some readers. But I will try to take you through a simple two point linear fit.

Procedure Theory: First you need to get the sensor (or in this case sensors) at a fixed and known temperature. The known temperature is measured by some known instrument. I used my IR thermometer. The Arduino will read the associated sensor and send out a number from 0 and 1023. The temperature and count is recorded. Then for a different temperature the whole process is repeated.

Procedure Applied: I wrapped the hacked Ethernet cable in a coil and stuck them in a box, then closed it. (See pictures) I put it in a fairly stable environment on my floor and let it set for a while. Then I got a readout from the Arduino, just the raw counts from the Analog sensors and I measured the temperature in the box with my IR Thermometer.(See picture)

Next I set the box outside at a hotter temperature and repeated the process.

So now you should have two different temperatures and two different counts for each sensor.

Algebra: So these sensors are fairly linear. That means the resistance changes pretty evenly with temperature. So I used a linear fit.

TempF = Multiplier * count + Offset

TempF is the temperature in Fahrenheit.
Count is the Arduino count.
Multiplier is a constant for each sensor.
Offset is a different constant for each sensor.

Once you figure out what the Multiplier and Offset is for each sensor then when the Arduino reads the count from the sensor, the software will multiply this by the Multiplier and add the Offset to give the temperature in Fahrenheit.

To find the Multiplier and Offset for a sensor, you know the TempF and counts for two different points so you have two different equations. Example:

At 83.5 degrees, the fifth sensor had 999.3 counts.
At 75.5 degrees, the fifth sensor had 979.5 counts.

The two equations are:
83.5 = M * 999.3 + O
75.5 = M * 979.5 + O

M=Multiplier and O=Offset

Using Algebra you can subtract the second equation from the first

83.5-75.5 = M * 999.3 - M * 979.5 + O - O

Simplify:

8 = M * 999.3 - M * 979.5
8 = 19.8 * M
M = 0.4040

So now you know what M is. To find O, just plug the M into one of the starting equations:

83.5 = M * 999.3 + O
83.5 = 0.4040 * 999.3 + O
83.5 = 403.7576 + O
83.5 - 403.7576 = O
O = -320.258

To check your calculations you can plug the M and O into the other equation.

Alert Readers: Some may wonder how I got a count of 999.3 when the Arduino only outputs 0 to 1023. That is correct but I am using an average value over 25 samples.
The Offset is a negative number. This is okay as the computer knows that adding a negative number is the same as subtracting it.

Repeat the above procedure for the other five sensors and plug the values into the software. By the way I used Excel to do the calculations.

The Arduino software is attached.

Software Notes:

Once the software is loaded to the Arduino, the serial terminal is used to display the results. Each line contains the temperatures from the top sensor to the bottom separated by commas.
The software will have to run through 25 samples before it starts averaging correctly. This will take about a minute.

Code Notes:
float TempArray[NUM_SAMPLES][MAX_TEMPS];
This is a double array, 25 samples x 6 sensors

Under “void setup(void){“ you will see the Multipliers and Offsets for each sensor.

Under “float getTemperatureF(unsigned int TempNum){“
there are two return statements.

The one commented out “//return (SumTotal/NUM_SAMPLES);”
is uncommented to get the average raw counts for calibration

The other "return Multiplier[TempNum]*(SumTotal/NUM_SAMPLES)+Offset[TempNum];"
returns the calibrated temperature.

Step 6: In Use and Conclusions

To use the Temperature wand, I bought ten feet of ½” PVC and a couple of couplers. I have a little car, so I had to cut the ten foot piece in half to get it into my car.
Unwrap the coiled sensors.
Cut PVC pieces to desired height and connect with couplers.
Attach the top sensor to the top of the PVC. I used tie wraps.
Plug in and run software.

Results: The picture is a sample of a hot room. (I added some fudge factors into the software) It does shows the fairly wide gradient in temperatures.

Conclusions: Well, I am not too happy with the results. When I have some free time, I think I will try a modified calibration procedure to see if I can get better results.
But it does show the temperature gradients in a room. I think it would be a good project for someone with ceiling fans and/or attic fans. You could probably get a good idea on how effective they are. I might try some experiments with fans myself.
Just a tip, you can use the DS18B20 temperature sensor and you can have multiple temperature sensors over the same data line because each sensor has its own unique id... I am planning on putting temperature sensors throughout my house similar to what you are doing...
nifty set up. I may try something like that on a different scale
Thanks. It should be easy to scale it up or down.<br><br>LOG

About This Instructable

10,513views

27favorites

License:

Bio: Lazy Old Geek
More by msuzuki777:Senior Moments Weather Station 5 IP Time Clock Part 2 
Add instructable to: