Open Marco3231st opened 1 year ago
Arduino Mega 2560 REV3 [A000067] https://www.amazon.ca/-/fr/gp/product/B0046AMGW0/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1
if I use the KY-013 ANALOG TEMPERATURE SENSOR, I could use this code, it would give me the temp in celsius from -55 to 125
int ThermistorPin = A0; int Vo; float R1 = 10000; // value of R1 on board float logR2, R2, T; float c1 = 0.001129148, c2 = 0.000234125, c3 = 0.0000000876741; //steinhart-hart coeficients for thermistor void setup() { Serial.begin(9600); } void loop() { Vo = analogRead(ThermistorPin); R2 = R1 (1023.0 / (float)Vo - 1.0); //calculate resistance on thermistor logR2 = log(R2); T = (1.0 / (c1 + c2logR2 + c3logR2logR2logR2)); // temperature in Kelvin T = T - 273.15; //convert Kelvin to Celcius // T = (T 9.0)/ 5.0 + 32.0; //convert Celcius to Farenheit Serial.print("Temperature: "); Serial.print(T); Serial.println(" C"); delay(500); }
The expression for calculating R2 is wrong (at least with my module). It should be like this:
R2 = R1*Vo/(1023-Vo); https://arduinomodules.info/ky-013-analog-temperature-sensor-module/
https://www.circuitbasics.com/arduino-thermistor-temperature-sensor-tutorial/
int ThermistorPin = 0; int Vo; float R1 = 10000; float logR2, R2, T; float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
void setup() { Serial.begin(9600); }
void loop() {
Vo = analogRead(ThermistorPin); R2 = R1 (1023.0 / (float)Vo - 1.0); logR2 = log(R2); T = (1.0 / (c1 + c2logR2 + c3logR2logR2logR2)); T = T - 273.15; T = (T 9.0)/ 5.0 + 32.0;
Serial.print("Temperature: "); Serial.print(T); Serial.println(" F");
delay(500); } To display the temperature in degrees Celsius, just comment out line 18 by inserting two forward slashes (“//”) at the beginning of the line.
To output the temperature readings to a 16X2 LCD, follow our tutorial, How to Set Up an LCD Display on an Arduino, then upload this code to the board:
int ThermistorPin = 0; int Vo; float R1 = 10000; float logR2, R2, T; float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() { Serial.begin(9600); }
void loop() {
Vo = analogRead(ThermistorPin); R2 = R1 (1023.0 / (float)Vo - 1.0); logR2 = log(R2); T = (1.0 / (c1 + c2logR2 + c3logR2logR2logR2)); T = T - 273.15; T = (T 9.0)/ 5.0 + 32.0;
lcd.print("Temp = ");
lcd.print(T);
lcd.print(" F");
delay(500);
lcd.clear();
}
le SSR est peu être pas nécessaire si je décide de donner 120W pendant 3h... à voir combien de deg ça donne
This issue is met to select the right hardware for the project