Skip to content

Instantly share code, notes, and snippets.

@futureshocked
Created June 29, 2020 05:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save futureshocked/f76ad0de29de7819d6d5430e22fd5b35 to your computer and use it in GitHub Desktop.
Save futureshocked/f76ad0de29de7819d6d5430e22fd5b35 to your computer and use it in GitHub Desktop.
This sketch will initialise the long counter in address 0.
// This sketch will initialise the long
// counter in address 0.
// Written by Peter Dalmaris from Tech Explorations.
// Used to find out how long an ESP32 can last on a LiPo battery.
// https://techexplorations.com
#include "EEPROM.h"
int addr = 0;
#define EEPROM_SIZE 32
void setup() {
Serial.begin(115200);
Serial.println("start...");
if (!EEPROM.begin(EEPROM_SIZE))
{
Serial.println("failed to initialise EEPROM"); delay(1000000);
}
EEPROM.writeULong(addr, 0); // Best use a seperate script to initialise the EEPROM
EEPROM.commit();
Serial.println("Cleared EEPROM at address 0");
Serial.println();
}
void loop() {
// put your main code here, to run repeatedly:
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment