How to store data from serial to PROGMEM?

Hi all,
Im wondering how im able to store data that comes in over serial to progmem.
Reason being i woud like to use the data after my arduino has had power removed and re-applied to it.

Right now the data that comes in over serial is stored to:
char inData2[12]; // Allocate some space for the string

I am able to print this over serial or to an oled screen via:
Serial.println(inData2); or oled.println(inData2);

But how would i then store "inData2" to progmem? and then call it back for use "Serial.println(NEW-PROGMEM-INDATA)"

Many Thanks!

You can't write to progmem, use EEPROM instead.

Im wondering how im able to store data that comes in over serial to progmem.

You can't. PROGMEM is read only.

Reason being i woud like to use the data after my arduino has had power removed and re-applied to it.

That's what EEPROM is for.

You can do it, but you'd have to rewrite the bootloader.
Because you asked the question, I guess you're not ready for that.

Ahh brilliant.

Emm got any pointers to help me get started?

If i were to print my current "inData2" it prints in form "00000AF298GT"

So how doI port that to EEPROM memory and then recall it for later use?

Many Thanks

So how doI port that to EEPROM memory and then recall it for later use?

What have you tried? What have you at least researched?

Emm well... So far i have found out that you have to do it byte by byte.

So im guessing that the "00000AF298GT" needs to be broken down into 12 bytes?

So im guessing that the "00000AF298GT" needs to be broken down into 12 bytes?

It's already "broken down" into 12 chars which are the same size as bytes.

oh ok, mmm well im stuck there atm. Time for more research.

I have aslo found this:

http://www.arduino.cc/playground/Code/EEPROMWriteAnything

But cant work out how to use this for my purposes.. Any ideas?

Thanks

I have aslo found this:

http://www.arduino.cc/playground/Code/EEPROMWriteAnything

But cant work out how to use this for my purposes.. Any ideas?

Go through the examples line by line to understand what each line does, and try the examples out. Make some modifications and see what happens. If you are still stuck after that, post a specific question.

I'd have to say, if you're writing strings, then EEPROMWriteAnything isn't a lot of use, but you'd normally be writing fixed length items into EEPROM, to make them more easily accessible.

The OP's example shows a 12 byte character array, which is fine with EEPROMWriteAnything

char inData2[12]; // Allocate some space for the string

The code that ive put up is probably completely wrong.

But am i going the right way about it?

#include <EEPROM.h>
#include "EEPROMAnything.h"

struct config_t
{
    char inData2[12]; // Allocate some space for the string
    long alarm;
    int mode;
} configuration;

void setup()
{
  Serial.begin(9600);
    EEPROM_readAnything(0, configuration);
    // ...
}
void loop()
{
    // let the user adjust their alarm settings
    // let the user adjust their mode settings
    // ...
Serial.println(inData2);
    // if they push the "Save" button, save their configuration
    if (digitalRead(13) == HIGH)
        EEPROM_writeAnything(0, configuration);
}

But am i going the right way about it?

Did it work? It's faster, sometimes, to ask the Arduino these kinds of questions.

PaulS:

But am i going the right way about it?

Did it work? It's faster, sometimes, to ask the Arduino these kinds of questions.

And waaay more instructive.

Ok so I was at work and didnt have access to y arduino at the time..

And nope it didnt work.

The arduino IDE showed this error:

sketch_may12a:22: error: 'inData2' was not declared in this scope

So I guess I'm not understanding how this code works.

I thought that this section of code:

struct config_t
{
    char inData2[12]; // Allocate some space for the string
} configuration;

Replaced me having to set up:

    char inData2[12]; // Allocate some space for the string

Prior to my running code.

Does anybody know of the glaring mistake im making?

Does anybody know of the glaring mistake im making?

You're not posting your code.

You need to read up on structures and how to address the individual members. Structures in C - Cprogramming.com