5 temperature sensors for arduino projects
They describe it as having notes of dark roast coffee and semi sweet chocolate offset by the classically bright, goldings hops. So tonight, im just digging through my box of environmental sensors here and taking a look at the various different temperature sensors that ive got thatll all work with your standard, arduino or microcontroller projects, and there is a surprising variety of them and i dont even have all Of them available, this is just a smattering that ive got so we will start with this guy here, which is a thermistor, a temperature, sensitive resistor. So a lot of the arduino starter kits will come with a little module like this, which has the thermistor just sitting here, standing off on its legs and three pins theres a little resistor down there as well, but its its less important. The thermistor is just this little bead on here, theres other thermistor boards that you might find in the starter kit that look more like this one, which has the same little thermistor sitting up there and you can get its analog reading directly out of it as well. Just like before just like on this board, but this one also has a little comparator and a potentiometer on here and the smattering of resistors and whatnot. The comparator basically compares the resistance of the thermistor to whatever you set here and sets a digital higher low, depending on which side of the threshold youre on so thermistors, as the name implies, are a thermal or temperature sensitive resistor.
The resistance of the thermistor varies based on the temperature of its surrounding environment. You can get them in various different base resistances, but these ones all three of these and most of the common ones, youll get with arduino, starter kits and whatnot are 10k ohms at 25 celsius room temperature, and then their resistance will drop as the temperature increases, which Means that they are a negative temperature coefficient, thermistor or ntc ptc positive temperature coefficients also exist, but theyre a little bit less common in this hobby world. So, as you can see its pretty close to 10k ohms right at room temperature here and if i just reach in and warm it up, see the temperature. The resistance starts dropping as the temperature increases on this guy, which can be pretty handy. And i mean its just a resistor, so its really easy to talk to and deal with, so to use them with an arduino. All you have to do is connect it to an analog input and set up a voltage, divider um with this sort of resistor. Here i doesnt have to be this one. You know it could be any 10k resistor and i went through my bin of 10k resistors and selected this one because its as close as i could find to actually 10k. You know they got a percentage tolerance on them, but so that creates a voltage divider between ground um, an analog input, pin this guy and five volts so because the arduino cant measure resistance directly.
You have to measure the voltage across that voltage divider, but, as you can see its just reading the temperature, its showing you a little bit of whats going on underneath here, uh, showing that its calculated that its 10.784 ohms and for that uh 23.31 degrees. If i warm it up in my fingers, we should see it starts rising down here there you go so thats, the most common and probably most straightforward one, but theres plenty of other temperature sensors available these guys, for instance, this is a thermocouple. It looks kind of similar to the thermistor at the tip, but what it really is is simply two wires with two dissimilar metals in that little blob on the end there and those dissimilar metals will generate a tiny little voltage when you apply heat to them. These things will operate over a very wide range of temperatures. They often come with multimeters that have temperature sensing capability built into them, such as you know this kiwis, but the fluke meters do them and other brands are available. So if we connect this guy and put them into temperature monitoring, youll see that just in free air, this thing is measuring about 21 celsius. Then i warm it up notice. It jumps really fast when you start warming it up. That is another benefit of these. Additionally, they can withstand and measure accurately very high temperatures that was just the heat shrink burning off it. You see it went up over 500 degrees just from that flame very quickly and its dropping off quickly in free air, again theres, not a model thermal mass there.
So they react very quickly, theres, a bunch of different types of thermocouples theres, a wikipedia page. That explains it all, of course, and also explains better and more detailed. How the uh whats called the seaback effect of that uh. Two metal interaction with the heat is in there, so ill link that down below, but these ones and the most common ones are defined as a k, type thermocouple heres, another type you might find very commonly and again its just got that little tiny sensor. On the end of it – and there is the ranges that a k type can handle um this one with just the cloth on it is one of these, so it can handle. You know minus 58 to ‘9 fahrenheit accurately, but if you get one with a little bit more heavy duty, jacketing on it, it can go all the way up to 700 celsius or down to minus 50 celsius quite comfortably and the other types other than you know. These being a type k can be selected for other ranges of temperatures. However, if youre using a thermocouple with an arduino or most circuitry, you need an amplifier board. This one is a max 6675 chip on it, which is both an amplifier and a analog to digital converter. So then, you just talk to your arduino or whatever microcontroller using the data pins. Here this particular one is one of the ones that the wiring is set up for higher temperature and actually its designed to screw into you know a flame tube or a heater furnaces and whatnot will have uh this type in them to monitor.
If there is a pilot light and if there is a flame and stuff like that and they can operate comfortably in that environment for years, so here it is using again just a library directly from the arduino library manager, nothing too fancy and, as you can see It is showing 27 celsius or 81 fahrenheit approximately, and if i put my my lighter underneath the tip of it again, youll see that it jumps up real fast as the flame heats. The thing up, but i dont, want to hold my hand there doing that for very long, but there you go another one that works nice and easy in arduino world, so heres, another common type of temperature sensor that often comes in arduino, starter kits. This guy is called a dht11 temperature sensor. There is also a very similar looking one, although it often comes with a different colored case, which is called a dht22, and these family are a temperature and humidity sensor which outputs in a digital format, so its again got the analog digital stuff built into it. Already. Just three pins uh power ground and a data pin the actual dht 11 module itself has four pins on it, but you only need three of them to get it going and the starter kit modules will typically only have three pins on them and those guys just Go in there plug them in and we have temperature and humidity readings, so this particular script that im using is like, i said, just an example from the library.
It is showing me that it is 56 humidity in my room. I dont think its that humid, but i do have the humidifier running when im not recording videos its showing between 21 22 degrees celsius, whatever that is in fahrenheit and the heat index, which is just mathematically calculated from the humidity and temperature heres a sketch that i Happen to be using, this is uh one from adafruit, but there are several others. This particular one will work with the dht11 or the dht22 that i mentioned, which i dont have one of here right now or the dht21, and it just uses its library dht.h. To do most of the magic very little for the user to do when youre programming. With this thing and like any sketch, you can use the temperature that you get back for anything that your heart desires in your project. You can use it as a thermometer thermostat. You can turn on the fan in your greenhouse if the humidity gets too high or whatever you want its your project, and this is a super easy way to deal with it. But if you want to get fancier, there are other types of temperature sensors as well, and these ones dont tend to come into the starter kits. This one looks like a transistor, but it is really a dallas. 18B 20 one wire temperature sensor. One layer is a bus topology that allows you to both communicate and power the device on a single wire plus ground.
I guess you dont count ground whatever anyway. These are kind of neat theyre a little bit expensive, but one advantage they have is with that. One layer, bus, you can put multiple on the same bus, so you can have multiple temperature sensors scattered around your project and each one has its own hard coded and each one has its own hard coded serial number on it burned in from the factory unique theoretically. So you can address multiples of them im not going to do that experiment right now, because i couldnt find a library that worked very well with that, but i will demonstrate just the basics of it another one thats very easy to do. Wiring on you just need the signal wire, a ground wire and a power wire is optional, im doing it just for the demonstration, because its easier and then a pull up resistor on the data line, oops that goes over there come on get in there. We go and then again just a sketch from the library powered up and away. We go, as i said, theres multiple libraries and multiple demo sketches for this one. This is the one that i happen to choose to use and its once again right out of the library manager in the arduino ide. This one just does a call to the one way: library and the dallas temperature library and does some math magic and pumps it out, and here we go its showing 23.
5 degrees and, as always, ill use my standard test to warm it up ill put my fingers On it – and you can see the temperature is rising again. That can be a handy one. You can get them in a weatherproof version. I dont have one of those handy right now. I just got this one here, but another cool option – theres one other one. Ive got in here: where did you go there? You are uh. This is called a bmp180, its fairly common and fairly cheap. The sensor is just this little square guy down in the corner here and its made by bosch a fairly large company that you may have heard of in the industrial world. They make a few different environmental sensors. This bmp 180 measures temperature and barometric pressure. There are some other ones that are you see in arduino world as well, which can measure humidity and a few other things as well, but i dont have one of those right now so well just focus on this guy like so many of them. It has the analog the digital conversion in it and just voltage ground serial clock serial data. You know standard, i squared c stuff and away you go as simple as that. Four wires uh one simple sketch using uh any one of several libraries that are available on the arduino library manager and away. You go heres the script that im running and once again it is using an adafruit library.
But there are other libraries available in the arduino ide thats useful if youve got just a raw module, its only a 3.3, but this this breakout board has voltage conversions, so it can handle 5 volts. It speaks i2c and well lets just look at the result. There. We go its its showing again 25 degrees celsius. Its lets pause this for a second, its showing the barometric pressure, its guessing without me, calibrating it to what the real barometric pressure is here today, its guessing im at about 179.1 meters above sea level, but with some of the calculations it thinks my real altitude and Im not sure what the difference in those two is but yeah. So if i knew, if i had my own barometer or check the weather forecast, i could put in the actual numbers for my location today and it could figure out the altitude more carefully. But thats thats close enough for now and you could again use that to change check the difference between when you start the script and when you drop it down a well or send it up in a hot air balloon or something like that. And that would be accurate enough to get give you an altitude above ground level, but for todays purposes. I was just looking at it for its temperature measuring capabilities, so there you go just a quick look at what is that uh five different inexpensive, uh hubby grade? Although fairly accurate for the most part temperature sensors that you can use in your arduino projects, all of them are using libraries theyre in the library manager and most of them.
There are multiple options available. This guys, not even using a library just using a little bit of raw code, that i found on the internet and ill link to that below as well for the thermistor but yeah the rest of its all fairly standard stuff and most are doing. The starter kits. Are going to come with one or more of these types of temperature sensors in them? So you can do temperature based projects turn on a fan if it gets too hot open open the window turn on the heater if it gets too cold or just report. The temperature in your fridge, i used uh one of these to monitor my beer fridge for a while. When i was first setting it up, i dont know i thought it was kind of interesting and uh.