Memorize commands on the EEPROM

I’m a beginner to arduino programming. I’m trying to develop home automation project using node mcu board based with blynk. I’m trying to memorize commands on the EEPROM.This is my code. please help to modify it

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth = "*********";

char ssid = "*<em><strong><strong>";
char pass[] = "</strong></strong></em>";
WidgetTerminal terminal(V0);

void setup()
{
// Debug console
Serial.begin(9600);

pinMode(D1, OUTPUT);
digitalWrite(D1, LOW);

Blynk.begin(auth, ssid, pass);

}

BLYNK_WRITE(V1)
{
if (param.asInt() == 1) {
digitalWrite(D1, HIGH);


terminal.println();
terminal.println();
terminal.println();
terminal.println(" LIGHT ON");
terminal.println();
terminal.println();
terminal.println();
terminal.flush();


}
else {
digitalWrite(D1, LOW);

terminal.println();
terminal.println();
terminal.println();
terminal.println(" LIGHT OFF");
terminal.println();
terminal.println();
terminal.println();
terminal.flush();


}

}

void loop()
{
Blynk.run();
}

@Prabhath1 please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

I want to add EEPOM to this code… so i want help to edit the code

You haven’t posted the code correctly, because you didn’t follow the instructions you were given when you crated the topic. I’ve asked you to fix that, and your code will be deleted if it isn’t fixed.

Pete.

I have edited my post

I’d suggest that you try again, and this time have one set of triple backticks at the beginning of your code, and another at the end, rather than what you’ve currently done.

Pete.

i did it

Okay, EEPROM is old technology and will damage the memory of your device if used incorrectly.
It was replaced by SPIFFS, which in turn has been replaced by LittleFS.

However, it depends what you are trying to achieve. In most situations the data you want to save can be written to a Blynk virtual pin and retrieved at startup using a Blynk.syncVirtual command.
The only scenario where that isn’t appropriate is if you want your device to function using manual inputs even if the connection to the Blynk server is down. However, your code won’t work in that scenario anyway, as you’ve used Blynk.begin which is a blocking command so the code execution won’t progress beyond that line of code if a connection to Blynk is unavailable.

Pete.

1 Like

thank you

I redid it for you :stuck_out_tongue: 3 backticks at beginning and 3 more at end… not 3-6 in groups placed throughout the code.

1 Like