Hallo zusammen,
ganz vorweg ich bin in dem Thema noch ziemlich neu.
Ich habe zwei Probleme und hoffe ihr könnt mir dabei helfen.
Und zwar möchte ich mit einem Arduino Mega 2560 3 Temperatursensoren (TMP36) und 1 Akkuzelle abfragen. Diese Werte möchte ich auf dem Elegoo 2.8TFT LCD (ILI9341) wiedergeben.
Temp. Abfrage:
Ich habe 3 Temp. Sensoren
- Regler Temp.
- Motor Temp.
- Akku Temp.
Die Werte möchte ich auch dem Display angezeigt bekommen und sobald eine der Temperaturen über einen bestimmten wert kommen sollte ein Signal (Piezo) ertönen oder eine LED leuchten oder der Display mich irgendwie drauf hinweisen.
Reichweiten abfrage:
Hier würde ich gerne eine Zelle von meinem Akku abfragen der Wert liegt zwischen 3,8 und 4,2Volt
zb. :
4,2Volt = 100km
4,1Volt = 75km
4,0Volt = 50km
3,9Volt = 25km
3,8Volt = 0Km
und bei ~25km ein Warnsignal (LED oder Display) ausgeben.
Was ich habe bis jetzt :
Das Programm dazu:
// IMPORTANT: Elegoo_TFTLCD LIBRARY MUST BE SPECIFICALLY
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
// SEE RELEVANT COMMENTS IN Elegoo_TFTLCD.h FOR SETUP.
#include <Elegoo_GFX.h> // Core graphics library
#include <Elegoo_TFTLCD.h> // Hardware-specific library
// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// Elegoo_TFTLCD tft;
void setup(void) {
Serial.begin(9600);
Serial.println(F("TFT LCD test"));
#ifdef USE_Elegoo_SHIELD_PINOUT
Serial.println(F("Using Elegoo 2.8\" TFT Arduino Shield Pinout"));
#else
Serial.println(F("Using Elegoo 2.8\" TFT Breakout Board Pinout"));
#endif
Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
tft.reset();
uint16_t identifier = tft.readID();
identifier=0x9341;
if(identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
} else if(identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
} else if(identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
} else if(identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
} else if(identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
} else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Elegoo 2.8\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_Elegoo_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Elegoo_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial."));
return;
}
tft.begin(identifier);
Serial.println(F("Benchmark Time (microseconds)"));
Serial.print(F("Text "));
Serial.println(testText());
delay(3000);
Serial.println(F("Done!"));
}
void loop(void) {
for(uint8_t rotation=3; rotation=3; rotation++) {
tft.setRotation(rotation);
testText();
delay(20000);
}
}
unsigned long testFillScreen() {
unsigned long start = micros();
tft.fillScreen(BLACK);
tft.fillScreen(RED);
tft.fillScreen(GREEN);
tft.fillScreen(BLUE);
tft.fillScreen(BLACK);
return micros() - start;
}
unsigned long testText() {
tft.fillScreen(BLACK);
unsigned long start = micros();
tft.setCursor(0, 0);
tft.setTextColor(WHITE);
tft.setTextSize(3);
tft.println("Regler Temp.");
tft.println("");
tft.println("Motor Temp.");
tft.println("");
tft.println("Batt. Temp.");
tft.println("");
tft.println("Reichweite");
tft.println("");
tft.setCursor(270, 145);
tft.setTextColor(WHITE);
tft.println("KM");
tft.println("");
return micros() - start;
}
Ich habe leider keine Programmschnipsel gefunden die mir dabei weiter helfen könnten die Temperaturabfrage und die abfrage der Zelle im Display anzuzeigen.
Vlt hat ja von euch einer da etwas rumfliegen was mir weiter helfen könnte.
Danke im vorraus.