Hi, hello there, I need some help with my project. If anyone has an idea how to solve this, it would be much help.
I'm doing this project to send data to my SC01 plus from an ESP32 using SoftwareSerial function.
Here's the coding for the SC01 plus:
#define LGFX_USE_V1 // set to use new version of library
#include <LovyanGFX.hpp> // main library
#include "esp32-hal-psram.h"
#include <WiFi.h>
#include <HTTPClient.h>
#include <SoftwareSerial.h>
//*************** -> WiFi & HTTP SETUPS <-***********************//
HTTPClient http;
const char* ssid = "TP-Link_E06C";
const char* password = "70070309";
//******************-> SETTING UP SERIAL PORT <-***********************//
SoftwareSerial mySerial(10, 11); // RX, TX
//********************-> LGFX SETTINGS <-*************************//
// Portrait
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ST7796 _panel_instance; // ST7796UI
lgfx::Bus_Parallel8 _bus_instance; // MCU8080 8B
lgfx::Light_PWM _light_instance;
lgfx::Touch_FT5x06 _touch_instance;
public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.freq_write = 40000000;
cfg.pin_wr = 47;
cfg.pin_rd = -1;
cfg.pin_rs = 0;
// LCD data interface, 8bit MCU (8080)
cfg.pin_d0 = 9;
cfg.pin_d1 = 46;
cfg.pin_d2 = 3;
cfg.pin_d3 = 8;
cfg.pin_d4 = 18;
cfg.pin_d5 = 17;
cfg.pin_d6 = 16;
cfg.pin_d7 = 15;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{
auto cfg = _panel_instance.config();
cfg.pin_cs = -1;
cfg.pin_rst = 4;
cfg.pin_busy = -1;
cfg.panel_width = TFT_WIDTH;
cfg.panel_height = TFT_HEIGHT;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.offset_rotation = 0;
cfg.dummy_read_pixel = 8;
cfg.dummy_read_bits = 1;
cfg.readable = false;
cfg.invert = true;
cfg.rgb_order = false;
cfg.dlen_16bit = false;
cfg.bus_shared = false;
_panel_instance.config(cfg);
}
{
auto cfg = _light_instance.config();
cfg.pin_bl = 45;
cfg.invert = false;
cfg.freq = 44100;
cfg.pwm_channel = 7;
_light_instance.config(cfg);
_panel_instance.setLight(&_light_instance);
}
{
auto cfg = _touch_instance.config();
cfg.x_min = 0;
cfg.x_max = 319;
cfg.y_min = 0;
cfg.y_max = 479;
cfg.pin_int = 7;
cfg.bus_shared = true;
cfg.offset_rotation = 0;
cfg.i2c_port = 1;//I2C_NUM_1;
cfg.i2c_addr = 0x38;
cfg.pin_sda = 6;
cfg.pin_scl = 5;
cfg.freq = 400000;
_touch_instance.config(cfg);
_panel_instance.setTouch(&_touch_instance);
}
setPanel(&_panel_instance);
}
};
static LGFX lcd; // declare display variable
// Variables for touch x,y
static int32_t x,y;
//***********************-> SYSTEM SETUP <-*************************//
void setup() {
Serial.begin(115200);
mySerial.begin(9600);
lcd.setRotation(1);
lcd.begin();
// Clear the display
lcd.fillScreen(TFT_BLACK);
lcd.setCursor(0, 0);
lcd.setTextSize(2);
lcd.setTextColor(TFT_WHITE);
// Connect ESP to Wifi
lcd.println("Connecting to WiFi....");
WiFi.begin(ssid, password);
int retries = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi....");
lcd.print(".");
}
if (WiFi.status() == WL_CONNECTED) {
lcd.println("Connected to WiFi");
Serial.println("Connected to WiFi");
} else {
lcd.println("Failed to connect to WiFi");
Serial.println("Failed to connect to WiFi");
}
}
//***********************-> SYSTEM PROCESS*************************//
void CardScanned() {
lcd.fillScreen(TFT_BLACK);
lcd.setCursor(100, 100);
lcd.setTextSize(5);
lcd.setTextColor(TFT_WHITE);
lcd.print("Scan your");
lcd.setCursor(15, 150);
lcd.setTextSize(5);
lcd.setTextColor(TFT_WHITE);
lcd.print("ID Card here ->");
String receivedData = "";
if (mySerial.available()) {
String receivedData = mySerial.readStringUntil('\n');
lcd.fillScreen(TFT_BLACK);
lcd.setCursor(20, 130);
lcd.print("Data Receivied: " + receivedData);
}
delay(1000);
If anyone has been through this or has something similar, please do guide. Thanks