Temperature Sensor Project: Intro
Table of Contents
As I’ve mentioned in the past, I love collecting data. Temperature sensors seem so simple on the surface, but there’s a lot more to them than you might have initially thought, including a huge range of sensor types. In this series, we’re going to build a range of PCBs which will cover all the temperature sensor types and circuits to implement them. We will also build a pair of host microcontroller boards to collect data and evaluate the sensors against each other. Finally, we’ll mount all the different sensor types on one of those host boards, and expose all the sensors to different environmental conditions. This will allow us to see how the sensors compare and make recommendations on which sensor is right for your needs, application, and budget.
Temperature sensors are vital to many industries. Even on your PCB, a temperature sensor can be used to ensure accurate data from other sensors as well as protect a board from overheating.
Temperature Sensor Types
- Negative Temperature Coefficient (NTC) thermistors
- Positive Temperature Coefficient (PTC) thermistors
- Resistance Temperature Detectors (RTD)
- Analog Temperature Sensor ICs
- Digital Temperature Sensor ICs
You can find all the sensors used in this series of projects, and many more, in my open source Celestial Altium Library, to allow you to get a jump on your sensor design. You can find the evaluation boards for this series on GitHub, with all the example sensor circuits. Every part of this series is released under the MIT license, so you can freely take advantage of the schematics for your own project, or use the boards to evaluate sensors yourself.
Above is the PCB design you'll be reading about in the Altium 365 Viewer; a free way to connect with your co-workers, clients, and friends with the ability to view the design or download with the single click of a button! Upload your design in a matter of seconds and have an interactive way to take an in-depth look without any bulky software or computer power.
Generic Sensor Guidelines
Before we start on specific sensor types, let’s talk about general considerations for using temperature sensors. Suppose you’re trying to sense an external temperature. In that case, layout considerations are going to be different from when you are trying to sense the temperature of a critical component or area of a PCB. Likewise, if you measure a temperature off your PCB, then there’s another set of considerations.
Additionally, you’ll also need to take into consideration sensor self-heating and thermal mass.
Sensing External Temperature, from the PCB
If you’re trying to sense external temperature, it’s critical that you isolate the sensor from the PCB as much as possible. The most common and effective way to do this is to isolate the sensor physically. Simply having the temperature sensor at the edge of your board is insufficient if you are aiming for accurate temperature measurement or as much as your sensor can offer, as heat will conduct through the substrate into the sensor. All circuits generate heat through resistive loss, some circuit boards far more than others, therefore physical isolation is critical.
Locating the temperature sensor as far from any heat source on your circuit board as possible is a fantastic first step. Adding a milled slot around your temperature sensor completes your isolation. Make sure you leave enough PCB that the sensor will not just break off like a tabbed board in a panel, however. It should be strong enough to be handled and go through the assembly process and consider the application requirements too - shocks, vibrations, and such.
It would help if you also considered any enclosure. The enclosure should allow good airflow to the sensor, but not allow airflow from the rest of the circuit board if possible. The enclosure should also not be able to transfer heat to the sensor, and therefore not touch any section of the isolated circuit board that the sensor sits on.
When you start working with temperature sensors, you may begin to question the fabric of reality itself. When you start trying to measure temperature without significant laboratory equipment accurately, you begin to get the sense that it’s impossible to do so. What is 21°C? How do we know it’s not actually 20.9°C or 22°C, do we care?
Sensing Onboard Temperature
Suppose you want to sense the temperature of a section of PCB or a specific component from the circuit board itself. In that case, you’ll want to do the exact opposite of the advice above. That means ensuring that your sensor has as much connection to the area as possible. We will be talking about a very interesting sensor later on in the series, the Microchip EMC1833T which allows you to sense a diode remotely. It’s specifically targeted at on-die temperature sensing for ICs that support it - including custom ASICs you might have developed.
In the case of most sensors, you’ll want to get heat into the die or resistive element of the sensor with as low thermal resistance as possible. In the case of having a device with a heatsink, try to share that heatsink with your temperature sensor. Otherwise, place the sensor component as close as possible to the device or high-temperature area of the board, and ideally have an electrical connection to the copper pour that is acting as a heatsink. This electrical connection, potentially the power supply or ground net, can help take heat right into the sensor’s die.
Off Board Temperature Sensing
When you need to sense the temperature of something off your circuit board, such as a piece of machinery, your choice of sensor type can be absolutely critical to the success of your project. Most types of resistive temperature sensors are not going to be ideal choices, as cable resistance can affect your sensed temperature. There are some sensors that will stand off the board and can be positioned through an opening in your enclosure. This will help ensure the temperature is being gathered away from hot components on the board.
Generally, cabled solutions offer significant challenges in an industrial setting, as induced voltages and currents on the cable from electromagnetic interference from equipment and machinery can be detrimental to your sensing accuracy. For sensors which feature an analog output, appropriately shielded cables are necessary. Likewise, digital sensors with an I2C interface may not be feasible if the distance between the board and the sensor is too long, as I2C is not a good choice for long signal paths. Depending on the temperature range, using a sensor such as a thermocouple might be your only choice and a perfect one for industrial environments at that.
Sensor Self Heating
All components on a circuit board generate some amount of heat as they operate. In a temperature sensor, this can be disastrous for an accurate temperature reading, as the device’s own resistive losses can cause a temperature offset in the sampled temperature. If you require the utmost accuracy, then choosing a very low current device, or operating a resistive device at a very low current will give you far more precise temperature results.
I’ve worked on projects where we have added significant amounts of thermal mass to a sensor, so it can accurately represent the temperature that is important to the project. For example, in a commercial fridge or freezer, adding thermal mass to a device that is monitoring the temperature of meat products allows the correct temperature to be collected despite the door being opened and closed. Thermal mass acts somewhat like thermal capacitance.
In other situations, any amount of thermal mass might cause you issues as the sensed temperature lags behind the actual temperature. Having your sensor attached directly to a large circuit board or copper area with no isolation will not allow you to detect small or rapid changes in ambient temperature easily. The sensor and the entire board need to heat up or cool down to the new local temperature before you can get an accurate temperature reading. For a sensor that needs to take high-frequency readings that accurately reflect the environment, minimising thermal mass is an important step to take.
Sensor Tolerance and Precision
Something you need to understand before journeying too far into adding a temperature sensor to your project or basing your project around sensing temperature; is that you will never be able to measure temperature with any IC or board mountable component. All you can measure is an approximate temperature - what matters is whether that approximation of temperature is precise enough for you. For some applications, having a sensor that is accurate to 5°C is going to be sufficient. If you’re monitoring a critical temperature in a process, 0.1°C might not be good enough. Knowing the precise temperature is virtually impossible for us, its a matter of how many degrees of accuracy you need to make the project work that you need to understand. Most sensors on the market will not give you anything beyond one decimal point of precision, and many will not give you more than 1°C of precision, some struggle with even that much precision. Higher precision typically comes at a higher implementation cost, either in the sensor itself or the supporting circuitry.
Beyond accuracy, we also have tolerance. You can have a very accurate temperature sensor with a wide range of tolerance, or a very tight tolerance sensor with a wide range of accuracy. If you think of Archery, a tight tolerance but low accuracy could be grouping all the arrows very closely, or even each arrow splitting the next - but not very close to the bullseye. A very accurate but low tolerance sensor might be where all of your shots group together around the bullseye but never quite hit it in the same spot. While most sensors will tend to have very high accuracy combined with very tight tolerances or very low accuracy with very wide tolerances, you’ll find more than a few which have a bit of either one.
For some applications, a very tight tolerance might be more important than the absolute accuracy of the temperature the sensor is reporting. The offset of the accuracy can be handled in software if the sensor has been characterized in a lab to know how it reports. If you take 1000 samples, they are all virtually identical, within a very tight tolerance, even if all the readings are 2°C off.
In other applications, knowing the actual temperature might be more important. If you take 1000 sensor readings, they will all vary a bit, but generally, centre around the actual temperature. You could take these readings and average them to gain a better understanding of the actual temperature; however, each instantaneous reading is off by a little bit.
Low-cost sensors such as thermistors can have poor accuracy and poor tolerances relative to other options. These sensors can be acceptable for applications where you need a general idea of temperature, such as in thermal protection of a circuit board. To use the earlier analogy, sensors like this are more like a beginner archer shooting at a target, their shots are all over the target, and some might even miss all together… but at least you have a general idea of the target area.
Sensor Test Board
Each week we’ll be learning about a different type of temperature sensor. However, they will all have a common interface to facilitate their testing. We will have two different host boards, one which can connect to and monitor all the different sensors, and another which can quickly test a single sensor. Both options will have a USB enabled microcontroller to perform the data collection.
Each sensor will have a mezzanine connector on the top and bottom to allow them to be stacked, as well as a set of contacts on the end of the board opposite the sensor. These contacts will allow the sensor to be plugged into a card edge connector on the single sensor test host.
The stackable connections will allow a high density of sensors on the multi-sensor tester, ensuring that the ambient temperature around all the sensors is uniform. This way, we can fit a lot of sensors into a smaller area by going vertically, yet still, maintain clean air around the sensor. We’ll be testing the sensors beyond their full rated temperature range as well as looking at how quickly the sensor can respond to temperature changes so having all the sensors in clean air yet not too far apart will allow for a better comparison.
Sensor Board Template
As we’ll be making a whole series of sensor boards, I thought it would be a good idea to make a template project which has a schematic and board that already have the connectors defined. This will ensure that the boards stack well, connect well, and also save a lot of time per board.
Templates in Altium are incredibly easy to implement. In other software (not just ECAD packages) creating a template can be a real hassle, whereas Altium doesn’t have any particular file types or requirements for a template, simply place a PCB, schematic or full project into your templates directory. On the next restart, it will be available. One point, I’d note to ensure that in your template you only use libraries you have installed or are in Altium 365 so Altium can always find the footprints and symbols you use. A database library or compiled integrated library which has been added to the “Installed” tab of your File-based Library Preferences are great ways to go if you haven’t made the switch to Altium 365 yet.
Both the analog and digital sensor boards will have the same board layout, however, the electrical connections on the connectors will be different. I’m using the Hirose DF12(3.0)-14D series mezzanine connectors to stack the boards as they are one of the most commonly available and cheapest connectors. The 3mm height between boards is perfect for these sensors, allowing a compact stack but each of the sensor types should still be able to fit between the boards without getting influenced by the board above or below.
Analog Temperature Sensor Template
To create a project template, we can start out by creating a project in your usual directory just like any other project. Then add a schematic and PCB exactly as you would normally.
Continuing the theme of just building up a project as you would anyway, add the portions of the schematic that are going to be common to all the projects that use this template. You can easily store and access this project template using Altium 365. First, you'll have to place the project in your Altium 365 Workspace using the "Make Project Available Online" command from the Projects Panel.
This command will place the project into your Altium 365 Workspace. You can also add the project into formal version control, so any changes to this template project will be tracked automatically.
After you've placed this template project into Altium 365, you can create new sensor cards by cloning the current project. The easiest way to do this is to go into your Workspace via your web browser and use the "Clone" command. This will create a copy of the project, which you can then open and modify in Altium Designer. It's always a good idea to keep your template projects separate from your production projects using a naming/numbering scheme where possible. When you clone the project, you'll have the opportunity to apply a name change so you can keep track of the differences between the template and your new production project.
For this project, I’m adding both mezzanine connectors with the same layout. When I created the footprints in my library, I made sure that pin one would match up with pin 1 of the mated connector. This decision makes it really easy to create stacks, even if it might not quite match the manufacturer’s pin numbering from their manufacturing drawing.
With the 14 pin connectors, I can have both 3.3V and 5V supplies as well as ten analog channels. While I could stack ten boards, several of the analog sensor topologies we’re going to use will be able to make use of differential pairs for the output, and our host boards will have ADC inputs that can support differential pairs.
As mentioned earlier, I also want to be able to plug a single board into a board that can work with a single sensor card for quick and easy verification of the board or testing of the sensor. To do this, I want to have contacts on the end of the board so it can be plugged into a card edge connector.
As there is no need for 10 analog channels to the card edge host, I have used two zero-ohm resistors as net ties, which also allows me to desolder them if I want to isolate the analog connections to the end launch pads. The card edge connector will be a TE 5650118-3, which offers 12 pins of connectivity. Still, I want to have the ability to plug the sensor board in either orientation without frying something, so the connections on the bottom side are the same as the top - just reversed. For the template, I'm not providing any input net to the resistor, as that will depend on the specific board sensor implementation and which analog channel it uses. For a non-differential sensor connection, the negative side can just be connected to ground in the sensor schematic.
On the PCB I have added a 3mm mounting hole, so the stack is not solely supported by the mezzanine connector. I have hopefully sized the board large enough for each of the sensor topologies we’re going to use, with the board being 25mm wide and 50mm long past the edge connector.
I’ve added a silkscreen key for the channels, so I can add a fill region into each of the analog channel boxes that the sensor will use, to make sure when building up a sensor stack I don’t end up with two channels connected to the same analog port. I’ve also added some dummy text so each board will get a sensor type and topology description added in the same place, which will give me a nice matching set of sensors at the end.
As I mentioned at the start of this article, we need to ensure that the sensor is thermally isolated from the rest of the board. I’ve added a 3mm routed slot to the routing layer that will provide thermal isolation for the end of the board. This will allow me to have any amplifiers or other heat sources between the mounting hole and slot, with the temperature sensing element away from it. An important point to remember when you’re adding slots to the board is to add a keepout path that is identical to the slot path. There’s nothing to stop you accidentally routing across the slot! Luckily in the past, I’ve always managed to catch my mistakes here when doing final checks before sending a board file to a fabrication company - but it’s been a very close call at times!
When testing the response rate of the sensors, I want to have a consistent board area, so each sensor is treated equally - I’m going to try not to modify this slot size or position as we go through building sensor boards.
While this all looks nice and will ensure a consistent layout - one of the most powerful features of a template for a project like this, where we are building a whole raft of almost identical boards is the ability to have all your common routing in place.
It doesn’t take too long to route, but when you need to do it 20 or more times with each board being the same, this template will save a lot of time!
Digital Temperature Sensor Template
We can use the same process for creating a template project with a digital version of this temperature sensor card. Instead using two source voltages to power different analog temperature sensors, we'll use I2C and SPI buses on the board to interface with digital temperature sensors. The template project for this sensor card is shown below. You might also notice in the above image that I’ve also included the panellisation features in the template.
I have added unplated pads along the cutouts of the milled slot to create mouse nibble features which will create tabs that can be easily broken away when the design is manufactured. I wanted to keep the ends cleanly routed, and didn’t want a rough v-score edge all the way down the long sides of the board - so mouse nibble tabs were the best option for keeping a relatively clean board edge. By placing the drills right just over the board outline, it will reduce how much the tab extends from the board. These boards will not be going into a tight-fitting enclosure, so the poor dimensional tolerance of a broken off tab of the circuit board will not cause any issues with fit or function.
As the sensor boards have a 3mm between board mating height, we want to add a rule to ensure that no components can be placed that will crash into a component above. At most, we can have one board per stack with a component taller than 3mm, the top component.
In addition to our usual design rules, I’m also changing the default Placement/Height rule to limit the height to 2.9mm. In my Celestial Altium Library, every component has an accurate 3D model, including all the capacitors which will ensure I don’t accidentally place a capacitor or other component that is just a little bit too high.
Rather than start from scratch for the digital temperature sensor, I’m instead going to make a copy the analog project template shown above and make the changes to the schematic sheet I need, then do a little bit of rerouting on the board.
The connector pinout needs to be changed completely to support our two digital protocols: SPI and I2C. All the extra pins are dedicated to chip select lines for the SPI based sensors. This means the multi-sensor board will need to have firmware which knows which sensor will be on which chip select line.
The card edge connector is not as elegant as I’d like it to be. By having the board be reversible in the socket, there are not enough contacts to have both SPI and I2C exposed at the same time. I couldn’t find a readily available, low-cost dual throw switch that would meet the 3mm height restriction of the board design - so instead I’m using selectively populated resistors. While the template has all four resistors, I intend to remove the unused resistor entirely on the final boards.
Just like on the analog design, I have a resistor as a net tie for the chip select line, to allow the correct chip select line to be mapped to the pin on the card edge connector. The board looks very similar to the analog board since I just updated the schematic for it, so everything will be consistent when we get to the point of testing the design. This is important to make sure that digital sensors will not have any false positive or negative as far as performance compared to their analog counterparts due to the board design. We want a clean comparison between the sensors, not their mounting methods.
As with the analog design, I have a section of silkscreen to mark which chip select line(s) this particular board is utilising if it uses SPI. This will allow me to ensure that the stack only contains unique chip selects.
As with the analog board, having the connector routing already completed for each sensor board is going to save me a lot of time. This will allow me to focus on the sensors rather than all the connector routing for each board.
Saving Both Projects as Project Templates
Another option for reusing these sensor cards is to create a Project Template for each of these. This is not the same thing as a project that gets used as a template, i.e., a project that you clone and then modify as we've done here.
This other way to quickly apply the settings and files used in our existing sensor card is to use the "Save Project to Server as Template" command in the File menu. This will create a new template from your project in the "Managed Content\Templates\Project Templates" folder in your Altium 365 Workspace. Now, when you want to create a new sensor card for an analog or digital sensor, you can apply this template to your new project from inside Altium Designer.
Temperature Sensor Types
As part of this series of articles, we’ll be diving into using all the major types of sensors. We’ll build sensor cards using the templates created here for every major topology for using the type of sensor so that we can compare them all in the real world. While some topologies are certainly better than others, it will be interesting to see how much it matters when facing real-world conditions.
We’ll be evaluating:
- Negative Temperature Coefficient (NTC) Thermistors
- Positive Temperature Coefficient (PTC) Thermistors
- Resistive Temperature Detector (RTD)
- Analog Temperature Sensor ICs
- Digital Temperature Sensor ICs
At the end of the series we’ll design the two host boards, and then get a chance to put all the sensors head to head through a variety of unpleasant temperature extremes!
Build Your Own Sensor Card
You can build your sensors using these templates and use them with the host boards we’ll create at the end of the series. Check out the repository on GitHub to download the templates and use them locally.
You’ll also find all the sensor cards we develop during this series in the same GitHub repository, so you might be able to get a sneak peek at what is coming up next in the series by checking the repository!
As always, these projects are open source, released under the MIT license allowing you to use them with very little in the way of restrictions. When you're ready to build your temperature sensor card and processor board, use the PCB design tools in Altium Designer®. When you’ve finished your design, and you want to share your design with your team mates, the Altium 365™ platform makes it easy to collaborate and share your projects. We have only scratched the surface of what is possible to do with Altium Designer on Altium 365. You can check the product page for a more in-depth feature description or one of the On-Demand Webinars.