2024-10-1200
This commit is contained in:
parent
660267f0ad
commit
62fbc84e5a
|
@ -21,6 +21,7 @@ lib_deps =
|
||||||
paulstoffregen/XPT2046_Touchscreen @ 0.0.0-alpha+sha.26b691b2c8
|
paulstoffregen/XPT2046_Touchscreen @ 0.0.0-alpha+sha.26b691b2c8
|
||||||
adafruit/Adafruit Unified Sensor @ 1.1.14
|
adafruit/Adafruit Unified Sensor @ 1.1.14
|
||||||
#adafruit/Adafruit HTU21DF Library @ 1.0.5
|
#adafruit/Adafruit HTU21DF Library @ 1.0.5
|
||||||
|
milesburton/DallasTemperature @ 3.11.0
|
||||||
|
|
||||||
build_flags = ${env.build_flags}
|
build_flags = ${env.build_flags}
|
||||||
-DKorrekturTemperatur=0.0
|
-DKorrekturTemperatur=0.0
|
||||||
|
|
41
src/main.cpp
41
src/main.cpp
|
@ -41,6 +41,18 @@ int d = 0;
|
||||||
void analogMeter();
|
void analogMeter();
|
||||||
void plotNeedle(int value, byte ms_delay);
|
void plotNeedle(int value, byte ms_delay);
|
||||||
|
|
||||||
|
#include <OneWire.h>
|
||||||
|
#include <DallasTemperature.h>
|
||||||
|
|
||||||
|
// Data wire is plugged into port 2 on the Arduino
|
||||||
|
#define ONE_WIRE_BUS 22
|
||||||
|
|
||||||
|
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
|
||||||
|
OneWire oneWire(ONE_WIRE_BUS);
|
||||||
|
|
||||||
|
// Pass our oneWire reference to Dallas Temperature.
|
||||||
|
DallasTemperature sensors(&oneWire);
|
||||||
|
|
||||||
void setup(void) {
|
void setup(void) {
|
||||||
tft.init();
|
tft.init();
|
||||||
tft.setRotation(1);
|
tft.setRotation(1);
|
||||||
|
@ -50,25 +62,48 @@ void setup(void) {
|
||||||
//I2C_2.begin(SDA_2, SCL_2, I2C_FREQ);
|
//I2C_2.begin(SDA_2, SCL_2, I2C_FREQ);
|
||||||
//delay(9000);
|
//delay(9000);
|
||||||
|
|
||||||
|
sensors.requestTemperatures(); // Send the command to get temperatures
|
||||||
|
Serial.println("DONE");
|
||||||
|
|
||||||
|
Serial.print("Temperature for the device 1 (index 0) is: ");
|
||||||
|
Serial.println(sensors.getTempCByIndex(0));
|
||||||
|
|
||||||
|
//delay(10000);
|
||||||
|
|
||||||
analogMeter(); // Draw analogue meter
|
analogMeter(); // Draw analogue meter
|
||||||
|
|
||||||
updateTime = millis(); // Next update time
|
updateTime = millis(); // Next update time
|
||||||
pinMode(ledGreen, OUTPUT);
|
pinMode(ledGreen, OUTPUT);
|
||||||
analogWrite(ledGreen, 102);
|
analogWrite(ledGreen, 102);
|
||||||
//init_HTU21();
|
//init_HTU21();
|
||||||
delay(5000);
|
//delay(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
float Temperatur;
|
||||||
if (updateTime <= millis()) {
|
if (updateTime <= millis()) {
|
||||||
updateTime = millis() + 35; // Update meter every 35 milliseconds
|
updateTime = millis() + 5000; // Update meter every 35 milliseconds
|
||||||
|
|
||||||
// Create a Sine wave for testing
|
// Create a Sine wave for testing
|
||||||
d += 4; if (d >= 360) d = 0;
|
d += 4; if (d >= 360) d = 0;
|
||||||
value[0] = 50 + 50 * sin((d + 0) * 0.0174532925);
|
value[0] = 50 + 50 * sin((d + 0) * 0.0174532925);
|
||||||
|
sensors.requestTemperatures(); // Send the command to get temperatures
|
||||||
|
Temperatur = sensors.getTempCByIndex(0);
|
||||||
plotNeedle(value[0], 0); // It takes between 2 and 12ms to replot the needle with zero delay
|
plotNeedle(value[0], 0); // It takes between 2 and 12ms to replot the needle with zero delay
|
||||||
|
tft.fillRect(0, 179, 310, 60, TFT_GREEN);
|
||||||
|
tft.setTextColor(TFT_BLACK,TFT_GREEN);
|
||||||
|
if (!Temperatur <= 127.000){
|
||||||
|
tft.drawString("Temperatur: ", 1, 180, 4);
|
||||||
|
tft.drawFloat(Temperatur, 1.2,160, 180,4);
|
||||||
|
tft.drawString("o", 212, 180, 1);
|
||||||
|
tft.drawString("C", 220, 180, 4);
|
||||||
|
tft.drawString("Raumfeuchtigkeit:", 1, 210, 4);
|
||||||
|
char buf[8]; dtostrf(value[0], 3, 0, buf);
|
||||||
|
tft.drawString(buf, 230, 210, 4);
|
||||||
|
tft.drawString("%", 270, 210, 4);
|
||||||
|
}
|
||||||
|
Serial.print(Temperatur,4); Serial.println(" °C");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user