Maker Pro
Maker Pro

Question using EEPROM

brian22

Jul 19, 2013
40
Joined
Jul 19, 2013
Messages
40
How to save the password in eeprom? when the device is turn off the pass was still in the chip.
and what syntax to use for changing the password?

tnx


Code:
char p1[] = {"11111"};

void Password(){

  char p2[5];
  int y = sizeof(p1);
  int flag=0;

  for (int x=0;x<=y;x++)
  {
    p2[x]= p1[x];
  }


  if(gsm.readSMS(smsbuffer, 5, p2, 5) == 0)
  flag=1;
  {
    if(strstr(smsbuffer,"11111") != NULL){
    Serial.println(strcmp(smsbuffer,"Matched"));
    }
    else if(strstr(smsbuffer," ") != NULL){
    flag=2;


  }
    }
  if(flag==2){    
    Serial.println(strcmp(smsbuffer,"Matched"));
    delF();
    }
    else if(flag==1){    
    Serial.println(strcmp(smsbuffer,"Don't Matched"));
    delF();

}
}

void delF()
{
 Serial.println("Executing delete");
     for (int j=0;j<=4;++j){     
     Serial.println(sms.DeleteSMS(j));
     }
}
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
It's impossible to answer that question because you've provided NO information.

If you describe your whole project thoroughly, we may be able to help.

To start with, what microcontroller are you using?

Have you looked at the data sheet for the microcontroller to find out how to access the EEPROM?

What development environment are you using?

Does it provide functions for reading and writing the device's EEPROM?

Have you Googled the relevant keywords to see how other people have done it?
 

brian22

Jul 19, 2013
40
Joined
Jul 19, 2013
Messages
40
i'm using arduino.

can you help me with codings? i'm working now with arduino library password.h
the concept is when the pass is correct it will jump to the main program and it also have change or reset pass

just don't mind the eeprom. tnx
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
There is a simple interface that allow you to read and write bytes to the eeprom.

How you store it is up to yourself.

You might, for example, allow up to 20 bytes and fill any unused bytes with 0's
 

brian22

Jul 19, 2013
40
Joined
Jul 19, 2013
Messages
40
i remove already the eeprom in my project. just a pass authentication and change pass

i hope you can help me with the codes..


Code:
#include <Password.h>


boolean started=false;
Password password = Password( "1234" );

byte currentLength = 0;


void setup(){
  Serial.begin(9600);
  Serial.println("Enter Password");
  

}

void loop()
{
  
if(started){

char smsbuffer = Serial.read();
         
String n=smsbuffer;  

if(gsm.readSMS(smsbuffer, 5, n ,5) == 0){
{  
switch (smsbuffer){
  case 'Reset': //reset password
  password.reset();
  currentLength = 0;
   Serial.println("\tPassword is reset!");
   
   break;
      case '1234': //evaluate password
        if (password.evaluate()){
          Serial.println("\tAuthorized!");
          mainp();
        }else{
          Serial.println("\tUnauthorized");
        }
   break;
default: //append any keypress that is not a '!' nor a '1234' 
        password.append(smsbuffer);
        currentLength++;
        
        //Print some feedback.
        Serial.print("Enter password: ");
        for (byte i=0; i<currentLength; i++){
          Serial.print('*');
        }
        Serial.println();
     }
  }
}
}



void mainp()

{
}
 
Last edited:
Top