⬆️ ⬇️

Practical use of a thermistor with Arduino

image



Hello, Habrasoobschestvo. After reading a few articles on the Arduino hub, I fired up to get this toy. And recently received a parcel with a fee. Then he indulged with the LEDs and wanted something more serious. I decided to make a simple thermometer using a thermistor, a 10 kΩ resistor and an LCD display. Who cares what happened - I ask under the cat.





Start



')

A thermistor is a variable resistor that changes its resistance depending on the ambient temperature.



We will need the following details:

Arduino Uno - 1 pc

Thermistor - 1 pc

Resistor with a resistance of 10 kΩ - 1 pc

LCD display HJ1602A - 1 pc

Connecting jumpers - a few pieces



I had all this, so I immediately started designing on the breadboard.



I also soldered the legs to the screen on the day of purchase.

image



Then we attach the screen to the outputs of the Arduino. My screen has this pinout.



1 (GND) GND - Earth

2 (VDD) 5v - Power (+)

3 (VO / Contrast) - Contrast control (here I connected a variable resistor)

4 (RS) - 12 - Data Channel

5 (RW) - 11 - Data Channel

6 (E) - 10 - Data Channel

11 (DB4) - 5 - Data Channel

12 (DB5) - 4 - Data Channel

13 (DB6) - 3 - Data Channel

14 (DB7) - 2 - Data Channel

15 (BL1 / Backlight1) - 13 - Backlight Power (+)

16 (BL2 / Backlight2) - GND - Earth (-)



It turned out this picture.

image



Next we connect one leg of the thermistor to the analog input A4 and a 10 kΩ resistor to ground, and the second leg of the thermistor to 5V.

image



In general, that's all. The hardware is ready. Here is a diagram.

image



Programming





With programming, everything is clear. Sketch source code:



//       LCD    #include <LiquidCrystal.h> #include <math.h> LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); //  LCD int backLight = 13; void setup(void) { pinMode(backLight, OUTPUT); digitalWrite(backLight, HIGH); lcd.begin(16, 2); lcd.clear(); lcd.setCursor(0,0); } //          double Getterm(int RawADC) { double temp; temp = log(((10240000/RawADC) - 10000)); temp = 1 / (0.001129148 + (0.000234125 * temp) + (0.0000000876741 * temp * temp * temp)); temp = temp - 273.15; return temp; } //         void printTemp(void) { double temp = Getterm(analogRead(4)); //     lcd.clear(); lcd.setCursor(0,0); lcd.print("Temperature is:"); lcd.setCursor(0,1); lcd.print(temp); lcd.print(" C"); } void loop(void) { printTemp(); //  ,   delay(1000); } 




The result of the program.

image

Source: https://habr.com/ru/post/141691/



All Articles