Hello Everyone, I am currently working on a project where I use the 4D system touch screen, in order to make a user interface (Username - Password) with Arduino IDE ESP32. I did downloaded all the libraries I need and everything is going well, just for this code in particular, I don't know how to start coding a login Interface, does anyone please have an idea? I will pretty much appreciate it.
You started a topic in the Uncategorised category of the forum
Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics
doesn't this library come with examples?
Yes it does, but I don't know how to code a login interface.
share a link to the library
does it offer ready made textfields?
Here is a pdf explaining the example you find in the Library.
it seems you can add a Text String Object for the dynamic text and also Static Text Object for labels.
how will the user type the information in?
Using a keyboard that I will insert like a Widget in 4D systems workshop.
do you have enough space on the screen for the keyboard and the textfields?
Yes I do. I work with 9" touchscreen for 4D systems. My problem is with arduino code. How to code a login interface, putting a specific username and password. And only if you have those both identificators you can access the next page.
Which part are you stuck on ? Is it building the interface or validating the input ?
And how secure does it need to be?
very secure, only someone with the username name I put and password, can access the following screen.
As previously asked
Writing the code, I found this code online and I am trying to get inspired
#include <genieArduino.h>
#define RESETLINE 4
Genie genie;
char keyvalue[10]; // array to hold keyboard values
char newkeyvalue[10];
char asterisk[9];
int counter = 0;
int counter2 = 0;
int temp;
int temp2;
bool flag;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600); // to comminicate with LCD
genie.Begin(Serial1);
genie.AttachEventHandler(myGenieEventHandler);
pinMode(RESETLINE, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
digitalWrite(RESETLINE, 1); // Reset the Display via D4
delay(100);
digitalWrite(RESETLINE, 0); // unReset the Display via D4
delay (3500); //let the display start up after the reset (This is important)
}
void loop()
{
//Process events
genie.DoEvents();
}
void myGenieEventHandler(void)
{
genieFrame Event;
genie.DequeueEvent(&Event);
//If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
{
if(Event.reportObject.object == GENIE_OBJ_KEYBOARD)
{
if (Event.reportObject.index == 0) // If keyboard0
{
temp = genie.GetEventData(&Event);
if(temp >= 48 && temp <= 57 && counter <=9)
{
keyvalue[counter] = temp; // Receive the event data from the keyboard
genie.WriteStr(0,keyvalue); //prints to String Object
counter = counter + 1; //increment array
}
else if(temp == 8) //check if backspace
{
counter--;
keyvalue[counter] = 0;
genie.WriteStr(0,keyvalue);
}
else if(temp == 13)
{
for(int x =0; x<counter ; x++)
{
Serial.println(keyvalue[x]);
}
Serial.print("DONE");
genie.WriteObject(GENIE_OBJ_FORM,0x01,0);
}
}
}
if (Event.reportObject.index == 1)
{
temp2 = genie.GetEventData(&Event);
if(temp2 >= 48 && temp2 <= 57 && counter2 <=9)
{
newkeyvalue[counter2] = temp2;
asterisk[counter2] = temp2;
genie.WriteStr(1,asterisk);
asterisk[counter2] = '*';
counter2 = counter2 + 1;
delay(200);
genie.WriteStr(1,asterisk);
}
else if(temp2 == 8 && counter2 >0) //check if backspace
{
counter2--;
newkeyvalue[counter2] = 0;
asterisk[counter2] = ' ';
genie.WriteStr(1,asterisk);
}
else if(temp2 == 13)
{
for(int x =0; x<counter ; x++)
{
Serial.println(newkeyvalue[x]);
}
Serial.print("DONE");
for(int x=0; x<9;x++)
{
if(keyvalue[x] == newkeyvalue[x])
{
flag = 1;
Serial.println("PASSED");
}
else
{
flag = 0;
}
if(flag == 0)
{
break;
}
}
if(flag == 0)
{
genie.WriteStr(2,"INCORRECT PASSWORD");
delay(2000);
}
else if(flag == 1)
{
genie.WriteStr(2,"CORRECT PASSWORD");
for(int y=0;y<9;y++)
{
newkeyvalue[y] = 0;
asterisk[y] = 0;
}
delay(2000);
flag = 0;
counter2 = 0;
genie.WriteStr(1,asterisk);
genie.WriteObject(GENIE_OBJ_FORM,0x01,0);
}
}
}
}
}
can you answer the question with a sentence, not with code..

very secure
That means the passcode needs to be encrypted as well securely in your ESP32. The ESP32-WROOM-32SE has integrated Microchip’s ATECC608A cryptoauth chip in the module (a secure element which would generate and store ECC private key in the hardware). I assume you don't have this model.
How do you plan to handle password storage ?
I have answered your question, I said I am struggling with writing the code, The user interface is easy, just drag and drop. The password is going to be string of characters something like Arduino2024April, and only if you know the username and password you can log in.

I have answered your question, I said I am struggling with writing the code,
you just did not say which code
OK so you can design a a screen with two fields where some characters appear when the user types on the virtual keyboard (and you display stars instead of the actual characters in the pwd field to prevent shoulder surfing)
You need two String instances or cStrings (userName
, userPwd
) to memorise what the user just typed in and then your code needs to compare those with some record you have somewhere in memory.
ideally you would have some sort of hash and not store the real user name and pwd in flash as it could be possibly extracted - so you would compare the hashed version of the name and pwd with the hash you have stored in memory.
Look at SHA-256 for example for the hash
Ensure that the flash memory is not easily accessible or tamper-proof
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.