16-03-2022, 18:54
Cześć, Wie ktoś może dlaczego pokazuje mi błędne odczyty z termometrów na poziomie -127 jeżeli w setupie zainicjalizuje wyświetlacz LCD? jak odznaczę wszystkie funkcje z wyświetlacza w setupie wtedy wartości z termometrów są prawidłowe próbowałem odznaczać funkcje po kolei lecz dopiero przy odznaczonych wszystkich funkcjach termometr działa. Poniżej kod.
Kod:
#include <DallasTemperature.h>
#include <OneWire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
OneWire oneWire(2);
DallasTemperature sensors(&oneWire);
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args) write(args);
#else
#define printByte(args) print(args,BYTE);
#endif
LiquidCrystal_I2C lcd(0x27, 16, 2);
byte tmp[8] = {
0b00000,
0b00100,
0b00100,
0b00100,
0b01110,
0b01010,
0b01110,
0b00000
};
byte stC[8] = {
0b00000,
0b01000,
0b00011,
0b00100,
0b00100,
0b00100,
0b00011,
0b00000
};
void setup() {
sensors.begin();
Serial.begin(9600);
lcd.init();
lcd.backlight();
sensors.begin();
lcd.createChar(0, tmp);
lcd.createChar(1, stC);
}
void tmps() {
sensors.requestTemperatures();
float tempC1 = sensors.getTempCByIndex(0);
float tempC2 = sensors.getTempCByIndex(1);
Serial.print("In: ");
Serial.print(tempC1);
Serial.print(" st.C ");
Serial.print(" Out: ");
Serial.print(tempC2);
Serial.println(" st.C");
//lcd.setCursor(1, 0);
// lcd.printByte(0);
//lcd.print(tempC1);
//lcd.printByte(1);
}
void loop() {
tmps();
}