cohron
November 11, 2022, 11:03am
1
I recently started a project with an ILI9341 TFT LCD and an Esp32.
My problem is that the pressure readings of the display are all over the place.
I already searched online and found a post about me having to mesure the resistance between xPlus and xMinus.
After doing so (347 Ohms) 1/4 of the screen gives me valid readings and im not sure where the problem is.
I am just using the Esp32 and display so there aren't any other component interfering.
Do you have any idea on what the reason for that behavior could be?
Specs:
Controller: AzDelivery Esp32 NodeMCU CP2102
Display: ILI9341 TFT LCD Arduino Shield
IDE: Visual Studio - PlatformIO
Connections
#define LCD_RD 2
#define LCD_WR 4
#define LCD_RS 15
#define LCD_CS 33
#define LCD_RST 32
#define LCD_D0 12
#define LCD_D1 13
#define LCD_D2 26
#define LCD_D3 25
#define LCD_D4 17
#define LCD_D5 16
#define LCD_D6 27
#define LCD_D7 14
My Readings in the area that seems to work:
Z lands between like 30 and 260
My readings in the area that doesn't work:
Z lands between like -300 and -16400
Hi, @cohron
Welcome to the forum.
See also FAQ - Arduino Forum for general rules on forum behaviour and etiquette.
Hello,
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is fru…
Can you please post your full code?
Can you please post a circuit diagram?
Thanks.. Tom..
cohron
November 12, 2022, 11:14am
3
Here is my full code that im using
#include <Arduino.h>
#include <MCUFRIEND_kbv.h>
#include <TouchScreen.h>
#include <EEPROM.h>
#include <iostream>
#define LCD_RD 2
#define LCD_WR 4
#define LCD_RS 15
#define LCD_CS 33
#define LCD_RST 32
#define LCD_D0 12
#define LCD_D1 13
#define LCD_D2 26
#define LCD_D3 25
#define LCD_D4 17
#define LCD_D5 16
#define LCD_D6 27
#define LCD_D7 14
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
int XP=LCD_D6, XM=LCD_RS, YP=LCD_WR, YM=LCD_D7;
const int LEFT=-2500,RIGHT=600,TOP=687,BOT=-2200;
int mappedX, mappedY;
bool enableDebugLogging = true;
TouchScreen touchScreen = TouchScreen(XP, YP, XM, YM, 347);
TSPoint touchScreenPoint;
MCUFRIEND_kbv tft;
int cursorStart = 0;
String message = "Hallo wie gehts";
void initializeTFTScreen() {
tft.reset();
tft.begin(tft.readID());
tft.setRotation(1);
}
void mapTouchScreenPoints() {
touchScreenPoint = touchScreen.getPoint();
mappedX = map(touchScreenPoint.x, LEFT, RIGHT, 0, tft.width());
mappedY = map(touchScreenPoint.y, TOP, BOT, 0, tft.height());
}
void printStringOnDisplay(const String &string, int x, int y) {
int16_t x1, y1;
uint16_t w, h;
tft.fillScreen(BLACK);
tft.getTextBounds(string, x, y, &x1, &y1, &w, &h);
cursorStart = x-w/2;
tft.setCursor(cursorStart, y - h / 2);
tft.print(string);
}
void calibrateTouchScreen() {
mapTouchScreenPoints();
Serial.println("-----------------------");
Serial.println("X: " + String(touchScreenPoint.x));
Serial.println("Y: " + String(touchScreenPoint.y));
Serial.println("Z: " + String(touchScreenPoint.z));
Serial.println("mapped X: " + String(mappedX));
Serial.println("mapped Y: " + String(mappedY));
}
void debugLog(String logEntry) {
if (enableDebugLogging) {
Serial.println(logEntry);
}
}
void debugLog(int logEntry) {
debugLog(String(logEntry));
}
void testThing() {
tft.setTextColor(WHITE,BLACK);
int cursorY = tft.getCursorY();
tft.setCursor(cursorStart,cursorY);
tft.print(message);
cursorStart--;
delay(25);
}
void setup() {
initializeTFTScreen();
Serial.begin(115200);
/*
tft.setTextWrap(false);
tft.setTextSize(3);
printStringOnDisplay(message,tft.width()/2,tft.height()/2);
*/
}
void loop() {
// debugLog(cursorStart);
calibrateTouchScreen();
}
Could you tell me why you need a ciruit diagram of this project?
You can see my connections in my initial post.
cohron
November 12, 2022, 11:19am
4
I hope this is enough of a schematic
Wawa
November 12, 2022, 8:29pm
5
Dumb question:
Where are your power/ground wires.
Isn't this a shield made for a 5volt Arduino, which the 3.3volt-logic ESP32 is not.
Leo..
cohron
November 13, 2022, 3:35pm
6
the connections are as they should be
Wawa
November 13, 2022, 8:06pm
7
So you're saying that the Fritzy drawing is not representing what it really is.
Yeah, we get that a lot here.
Leo..
system
Closed
May 12, 2023, 8:06pm
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.