Temperature - Temperature sensor TMP36
What next phenomenon will we measure with our Arduino? Temperature. To do this, we will use a rather complex CI (integrated circuit) hidden in a package identical to our P2N2222AG transistors. It has three pins, connection to ground, signal and + 5 volts, and is easy to operate.
It sends a signal of 10 millivolts per degree Celsius to the port (in order to be able to measure temperatures below frost, a shift of 500 mV occurs, thus 25 ° C = 750 mV, 0 ° C = 500 mV).
To convert a digital value to degrees, we will use some of the mathematical capabilities of Arduino. We will send the value to the console. Let.
COMPONENTS
- Temperature sensor TMP36.
- Connecting wire.
CIRCUIT DIAGRAM
CIRCUIT INSTALLATION
Photo of installation with temperature sensor, translator
(Note
that the flat face of the sensor is on the Arduino side)
CODE
You can find this code in CIRC-10-code-temperaturesensor.js
var five = require("johnny-five");
five.Board().on("ready", function(){
var tempSensor = new five.Sensor("A0");
tempSensor.on("read", function(err, value){
var cel = (100 * (value / 1000) - 50).toFixed(2);
console.log("temp is " + cel);
});
});
EMERGENCY REPAIR
Nothing seems to be happening
This mounting does not indicate that it is working. To see the results, look at what is displayed on the console.
The temperature does not change.
Try pinching the sensor with your fingers to warm it, or pressing ice against it to cool it.
(NdT: You may get burned if the mounting is not done correctly. Rather, blow on it to cool down a degree).
CODE EXTENSION
Show stress:
You just have to change one line. Our sensor shows 10mv per degree Celsius, also to get the voltage, we show the sensor value. Edit Line:
console.log("Temperature: " + cel);
to display the value instead of cel.
Show in degrees Fahrenheit:
Again, this is a simple change requiring only calculations. To convert degrees C to F, the formula is used:
F = C * 1.8 + 32
Add a line:
var fahrenheit = (cel * 1.8) + 32;