In this lesson, we'll learn below.
* AnalogRead function
* Arithmetic
* Float data type
-Table of Contents
0:00 About thermistor and analog input
0:53 What we make
1:01 Material preparation
1:19 Circuit diagram
2:10 Assemble circuit
2:22 Make program
3:41 Write to board
4:00 Conclusion
-Introduction
Hardware engineer
9 years experience as a Maker
-SNS
Web : start-electronics.com/
Twitter : / buonoatsushi
#Electronics #Arduino
-Content
A thermistor is a type of temperature sensor that has the property that its resistance value changes as the temperature changes. By using this characteristic in reverse, temperature can be measured from the change in resistance value. However, it is difficult to measure the resistance value directly, so generally, such a circuit is set up to convert it to a voltage and read it. Assuming that the detection resistor Rd is a general resistance and that Rd does not change its resistance value regardless of temperature, the voltage at point A will change according to the resistance value of Rt. From this change in voltage, the amount of change in resistance is determined. The B constant is a constant that describes the characteristics of the thermistor and indicates the slope of how much the resistance value changes in response to changes in temperature. In most cases, the B constant is found in the data sheet of the thermistor, so it is used as the value.
This is the circuit we created this time, and you can see that the temperature changes when you touch it or heat it up with a hair dryer. Now let's make this circuit.
The materials we will use this time are an Arduino Uno, a breadboard, three male and three female jumper wires, a thermistor, and a 10kΩ resistor. Note that there are two types of thermistors: NTC, whose resistance decreases as it heats up, and PTC, whose resistance increases. The NTC type is mainly used for temperature sensors, so be careful not to mistake it for the PTC type.
The analog input terminal of the Arduino has a 10-bit AD converter that can convert analog voltages in the range of 0 to 5 V into digital data in the range of 0 to 1023. The voltage per memory is called the resolution, in this case 5 V is divided by 1024, so one memory is roughly 5mV. There are a total of six analog input terminals, and in this case we are using the A0 terminal. the choice of Rd resistance requires some care: if Rd is too small or too large, the voltage at point A will barely swing, making it difficult to calculate the resistance value accurately. In reality, fine adjustment is necessary depending on the temperature range you want to measure, but for the time being, you should use a value equivalent to the resistance of the thermistor at room temperature. In the case of the thermistor used here, the resistance is 10 kΩ, so Rd is also 10 kΩ.
Next, a breadboard diagram is shown here, following the circuit diagram. Let's build the circuit according to this diagram. Yes, so we have built the circuit.
Now let's start coding. start the Arduino IDE, click File→New File, and enter the program shown in this screen. lines 5 to 8 are constants used to calculate the resistance value. In this case, we use a data type called float that can handle a decimal point, since a decimal point is generated when using division, etc. In addition, this time we use a serial monitor to monitor the change in value.
This time, we will use a function called serial monitor to see the change in value. This function allows the Arduino and the PC to exchange data via serial communication, allowing you to verify the operation while viewing the values in real time.
In the loop function, the analogRead function first reads the voltage value. Next, the current resistance value is determined. The Arduino can perform a variety of calculations, including general calculations called four arithmetic operations and slightly more complex ones such as log and root. Next, we use the formula here to find T. This is the temperature of the thermistor. This is a well-known formula for calculating thermistor temperature, so if you want some background, check out this site. Note that the units at this point are Kelvin, which represents absolute temperature. Finally, after converting to Celsius, throw the value to Serial.println and the temperature observation is complete. The wait time, i.e., how often the value is updated, can be any number of seconds, but for now we set it to 0.2 seconds.
Finally, save the file and press the "Write to microcontroller board" button on the toolbar to write the file. When the writing is completed, press the "Serial Monitor" button in the upper right corner. As you can see, the value is updated every 0.2 seconds. First, to make sure that the calculation is correct, measure the room temperature and see if it roughly matches your senses.
Негізгі бет Тәжірибелік нұсқаулар және стиль [First Arduino] 6. Thermistor | Starter course with Hands-on
Пікірлер: 8