Connect with us

Question using EEPROM

Discussion in 'Microcontrollers, Programming and IoT' started by brian22, Aug 14, 2013.

Scroll to continue with content
  1. brian22

    brian22

    40
    0
    Jul 19, 2013
    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: Aug 14, 2013
  2. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,268
    Nov 28, 2011
    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?
     
  3. brian22

    brian22

    40
    0
    Jul 19, 2013
    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: Aug 15, 2013
  4. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,363
    2,758
    Jan 21, 2010
    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
     
  5. brian22

    brian22

    40
    0
    Jul 19, 2013
    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: Aug 15, 2013
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-