{"id":101,"date":"2023-09-21T13:53:40","date_gmt":"2023-09-21T16:53:40","guid":{"rendered":"https:\/\/thiagoldaniel.com.br\/?p=101"},"modified":"2023-10-24T15:32:14","modified_gmt":"2023-10-24T18:32:14","slug":"eliminar-conteudo-eeprom-esp8266","status":"publish","type":"post","link":"https:\/\/thiagoldaniel.com.br\/index.php\/2023\/09\/21\/eliminar-conteudo-eeprom-esp8266\/","title":{"rendered":"Eliminar Conte\u00fado EEPROM &#8211; ESP8266"},"content":{"rendered":"\n<p>Pessoal, <\/p>\n\n\n\n<p>Muito boa tarde, a dica de hoje vai sobre a utiliza\u00e7\u00e3o de uma rotina para eliminar o conte\u00fado da EEPROM em um controlador IOT ESP8266.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/********************************************************************************************\n\n                       EEPROM-Cleaner v1.2.0\n\n                       Copyright (c) 2023 - Thiago Santana\n\n ********************************************************************************************\/\n\n#include &lt;EEPROM.h&gt;\n#include &lt;ESP8266WiFi.h&gt;\n\n\/\/ sizeBytes being the number of bytes you want to use.\n\/\/ It's defined with \"#define sizeBytes\"\n\/\/ Size can be anywhere between 4 and 4096 bytes (Default for ESP8266_deauther = 4096)\n#define sizeBytes 4096\n\n\/\/ change it for lower or higher endByte (Default for ESP8266_deauther = 4096)\n\/\/ normaly it's the same as sizeBytes\n#define endByte 4096\n\n\/\/ change it for lower or higher startByte (Default = 0)\n#define startByte 0\n\nunsigned long ok = 0;\nunsigned long nok = 0;\nunsigned long tok = 0;\n\n\nvoid setup()\n{\n  Serial.begin(115200);\n  EEPROM.begin(sizeBytes);\n\n  delay(100);\n\n  Serial.println(\"**********************************************************************************************************\");\n  Serial.println(\"\");\n  Serial.print(\"    Write a char(255) \/ hex(FF) from byte \");\n  Serial.print(startByte);\n  Serial.print(\" to \");\n  Serial.print(endByte - 1);\n  Serial.print(\" into the EEPROM with a defined size of \");\n  Serial.print(\"\");\n  Serial.print(sizeBytes);\n  Serial.println(\" Bytes\");\n  Serial.println(\"\");\n  Serial.println(\"**********************************************************************************************************\");\n  Serial.println(\"\");\n\n  Serial.println(\"             testing EEPROM for written bytes\");\n  Serial.println(\"\");\n\n  for (int i = startByte; i &lt; endByte; ++i)\n  {\n    if (EEPROM.read(i) == 255) {\n      ++ok;\n    } else {\n      ++nok;\n    }\n  }\n\n  Serial.printf(\"               empty bytes: %6d\\r\\n\", ok);\n  Serial.printf(\"           not empty bytes: %6d\\r\\n\", nok);\n  Serial.println(\"\");\n  Serial.println(\"**********************************************************************************************************\");\n  Serial.println(\"\");\n\n  Serial.println(\"**********************************************************************************************************\");\n  Serial.println(\"\");\n  Serial.println(\"             Start clearing EEPROM... - Please wait!!!\");\n  Serial.println(\"\");\n  Serial.println(\"**********************************************************************************************************\");\n\n  delay(1000);\n\n  \/\/ write a char(255) \/ hex(FF) from startByte until endByte into the EEPROM\n  for (int i = startByte; i &lt; endByte; ++i) {\n    EEPROM.write(i, -1);\n  }\n\n  EEPROM.commit();\n\n  delay(1000);\n\n  Serial.println(\"\");\n  Serial.println(\"             testing EEPROM for clearing\");\n  Serial.println(\"\");\n\n  String test;\n  for (int i = startByte; i &lt; endByte; ++i)\n  {\n    if (EEPROM.read(i) == 255) {\n      ++tok;\n    }\n  }\n  Serial.println(\"**********************************************************************************************************\");\n  Serial.println(\"\");\n  if (tok = endByte - startByte) {\n    Serial.println(\"             EEPROM killed correctly\");\n  } else\n    Serial.println(\"             EEPROM not killed - ERROR !!!\");\n\n  Serial.println(\"\");\n  Serial.println(\"**********************************************************************************************************\");\n  Serial.println(\"\");\n  Serial.println(\"             Ready - You can remove your ESP8266 \/ LoLin\");\n  Serial.println(\"\");\n  Serial.println(\"**********************************************************************************************************\");\n}\n\nvoid loop()\n{\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Pessoal, Muito boa tarde, a dica de hoje vai sobre a utiliza\u00e7\u00e3o de uma rotina para eliminar o conte\u00fado da EEPROM em um controlador IOT ESP8266.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-101","post","type-post","status-publish","format-standard","hentry","category-iot"],"_links":{"self":[{"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/posts\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":2,"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/posts\/101\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/posts\/101\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thiagoldaniel.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}