Eprom erase Jumper



  • I´m not a programmer, only user - my wish would be to have an eprom-erase-jumper, so i don´t need to erase it when moving the sensor from one gateway to another one, even to another installation.
    I was even thinking, as there are many unused ports on the arduino, about jumpers to select the update time ?


  • Contest Winner

    HI @kr0815 , what you can do is add a piece of code which checks for a jumper presence on start-up if so just erase your EEPROM.

    An input pin will become LOW when the jumper connects this pin to GND and will become HIGH when the jumper is removed (stable high by activating the interval pull up resistor)

    This jumper check code can be something like this:

        pinMode(CLEAR_EEPROM_JUMPER, INPUT);           // set pin to input
        digitalWrite(CLEAR_EEPROM_JUMPER, HIGH);       // turn on internal pull up resistors
        delay(50);                                     // Wait to stabilize the input pin
        // If jumper is placed and thus the input pin is LOW a clean EEPROM is required
        if (digitalRead(CLEAR_EEPROM_JUMPER) == LOW) {
            Serial.begin(BAUD_RATE);
            Serial.println(F("Clearing EEPROM. Please wait..."));
            for (int i=0;i<512;i++) {
                EEPROM.write(i, 0xff);
            }
            Serial.println(F("Clearing done. Continue with normal init..."));
        }
    

    A very simple plug in would look something like this:

    #include <MySensor.h>
    #include <SPI.h>
    #include <EEPROM.h>  
    
    // Clear EEPROM jumper: when placed this pin should be connected to GND 
    #define CLEAR_EEPROM_JUMPER  6
    
    MySensor gw;
    
    void setup()  
    { 
        pinMode(CLEAR_EEPROM_JUMPER, INPUT);           // set pin to input
        digitalWrite(CLEAR_EEPROM_JUMPER, HIGH);       // turn on internal pull up resistors
        delay(50);                                     // Wait to stabalize the input pin
        // If jumper is placed and thus the input pin is LOW a clean EEPROM is required
        if (digitalRead(CLEAR_EEPROM_JUMPER) == LOW) {
            Serial.begin(BAUD_RATE);
            Serial.println(F("Clearing EEPROM. Please wait..."));
            for (int i=0;i<512;i++) {
                EEPROM.write(i, 0xff);
            }
            Serial.println(F("Clearing done. Continue with normal init..."));
        }
        
        // place normal init here
        gw.begin();
    }
    
    void loop()      
    { 
        // Normal sensor stuff here
        gw.process();
    } 
    

    Just add this check to all your plugin code



  • Thank BartE, exactly what i needed, works perfect
    I already upgraded all my sensors, makes it much easyer because i have a different gateway on my solder bench then in the house

    It would maybe make sense to include that feature to the examples ?

    Best regards

    Klaus


 

265
Online

8.6k
Users

9.4k
Topics

99.1k
Posts