now i got all problems solved. here is the code. `#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // LCD-Adresse auf 0x27 für ein 16x2-Display setzen
const int pressurePin = A1; // Pin für Drucksensor
const float sensorMin = 0.5; // Minimum voltage from sensor (0.2 bar)
const float sensorMax = 4.5; // Maximum voltage from sensor (3.0 bar)
const float pressureMin = 0.2; // Minimum pressure in bar
const float pressureMax = 3.0; // Maximum pressure in bar
const int ntcPin = A3; // Pin für Temperatursensor
// Kalibrierungsfaktor zur Anpassung des Drucks
float pressureCalibrationFactor = 1.0; // Abweichung
// Offset-Faktor zur Anpassung des Drucks
float pressureOffset = 0.0; // Offset-Faktor, der zum Druck addiert wird
void setup() {
lcd.init(); // Initialisiere das LCD
lcd.backlight(); // LCD-Hintergrundbeleuchtung einschalten
}
float readPressure() {
int sensorValue = analogRead(pressurePin); // Lese analogen Wert vom Drucksensor
float voltage = sensorValue * (5.0 / 1023.0); // Spannung umrechnen
// Werte aus dem Diagramm
float c0 = 5.4 / 280.0;
float c1 = 0.85 / 280.0;
float supplyVoltage = 5.0; // Versorgungsspannung in Volt
// Berechnung des absoluten Drucks in kPa gemäß der Formel
float pressure_kPa = (280.0 / 0.85) * ((voltage / supplyVoltage) - c0);
// Umwandlung von kPa in Bar, Anwendung des Kalibrierungsfaktors und des Offset-Faktors
float pressure_bar = (pressure_kPa / 100.0) * pressureCalibrationFactor + pressureOffset;
return pressure_bar;
}
float readTemperature() {
int ntcValue = analogRead(ntcPin); // Lese analogen Wert vom NTC
float voltage = ntcValue * (5.0 / 1023.0); // Spannung umrechnen
// Berechne den Widerstand des NTC
float resistance = (10000.0 * voltage) / (5.0 - voltage); // 10kΩ Spannungsteiler
// Berechne die Temperatur aus dem Widerstand
float temperature = calculateTemperature(resistance);
return temperature;
}
float calculateTemperature(float resistance) {
// Temperatur- und Widerstandswerte aus der Kennlinie
float tempValues[] = {-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130};
float resValues[] = {45303, 34273, 26108, 19999, 15458, 12000, 9358, 7413, 5895, 4711, 3791, 3068, 2499, 2056, 1706, 1421, 1180, 987.4, 833.8, 702.7, 595.4, 508.2, 435.6, 374.1, 322.5, 279.5, 243.1, 212.6, 186.6, 165.0, 146.9, 131.9, 119.2, 108.2, 98.29};
for (int i = 0; i < 34; i++) {
if (resistance >= resValues[i + 1] && resistance <= resValues[i]) {
float slope = (tempValues[i] - tempValues[i + 1]) / (resValues[i] - resValues[i + 1]);
return tempValues[i + 1] + slope * (resistance - resValues[i + 1]);
}
}
return -999; // Fehlerwert
}
void loop() {
float pressure = readPressure();
float temperature = readTemperature();
lcd.setCursor(0, 0);
lcd.print("Druck:");
lcd.setCursor(0, 1);
lcd.print("Temp:"); // Anzeige Temp: für Temperatur
// Display pressure
lcd.setCursor(6, 0);
lcd.print(pressure, 2);
lcd.print(" bar "); // Padding to clear old data
// Display temperature
lcd.setCursor(6, 1);
if (temperature != -999) {
lcd.print(temperature, 1);
} else {
lcd.print("Err ");
}
lcd.print("C "); // Padding to clear old data
delay(200); // Aktualisierung alle 500 ms
}
so when i try to improve the fload temp values to something like this
float tempValues[] = {-40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130};
float resValues[] = {45303, 42824.7, 40489.7, 38290.9, 36221.1, 34273, 32439.5, 30713.5, 29087.7, 27554.9, 26108, 24740.5, 23448.8, 22229.9, 21080.9, 19999, 18980.9, 18022.4, 17118.7, 16265.5, 15458, 14692.1, 13965.4, 13275.8, 12621.4, 12000, 11410,
10850.9, 10322.7, 9825.1, 9358, 8920.8, 8510.9, 8125.1, 7760.2, 7413, 7080.9, 6763.2, 6459.8, 6170.4, 5895, 5633.3, 5384.7, 5148.6, 4924.2, 4711, 4508.3, 4315.5, 4132, 3957.4, 3791, 3632.3, 3481, 3336.8, 3199.2, 3068, 2942.8, 2823.6, 2709.9, 2601.8,
2499, 2401.3, 2308.5, 2220.2, 2136.1, 2056, 1979.5, 1906.5, 1836.7, 1769.9, 1706, 1644.9, 1586.5, 1530.6, 1477.2, 1421, 1371.1, 1323.8, 1278.9, 1236.3, 1180, 1144.3, 1110.1, 1077.3, 1045.8, 987.4, 958.6, 931.1, 904.9, 879.9, 833.8, 805.9, 778.8, 752.5,
727.1, 702.7, 679.3, 657, 635.6, 615.1, 595.4, 576.5, 558.4, 541, 524.3, 508.2, 492.7, 477.7, 463.2, 449.2, 435.6, 422.5, 409.8, 397.5, 385.6, 374.1, 363, 352.3, 342, 332.1, 322.5, 313.3, 304.4, 295.8, 287.5, 279.5, 271.7, 264.2, 256.9, 249.9, 243.1,
236.6, 230.3, 224.2, 218.3, 212.6, 207.1, 201.8, 196.6, 191.5, 186.6, 181.8, 177.1, 172.5, 168.1, 163.8, 159.6, 155.6, 151.7, 147.9, 144.2, 140.6, 137.1, 133.8, 130.5, 127.3, 124.2, 121.2, 118.3, 115.4, 112.7, 110, 107.5, 105, 102.6, 100.2, 97.9, 95.7,
93.5, 91.4, 89.3};` the screen just turns on without showing anything. Is my uno r3 to weak?