Dear everyone,
I have a running project that to remotely monitor an equipment's currency and temperature.
Sometimes, I need to change the programs, I need to go to the machine take out the arduino and reflash it. I think if there is a way that can convert a string to be executed like a function. What I need to do is let arduino download this string on the internet and put this string to a function, then it like reprograms itself.
Anyway, is this possible?
Which board are you using ?
Using an ESP8266 board you can do updates Over The Air (OTA) with no physical connection to the board by using a wireless network
If I understand the question correctly, the short answer is "no". There is no way to convert a string to a function.
The question is what "change the programs" means. If it's just a few parameters that need adjustment, you can store those in eerpom.
If you have a set of pre-defined functions (and basically never want to add something new) that you want to execute, you can use something in the line of below.
void loop()
{
char command[32];
someFunctionToReceiveData(command);
if(strcmp(command,"add") == 0)
{
add();
}
else if (strcmp(command,"subtract") == 0)
{
subtract();
}
}
You probably need to store the receivedData in eeprom and retrieve from there to make it persistent.
void loop()
{
char command[32];
someFunctionToReceiveData(command);
// if new comman d received
if(strcmp(command,"")!=0)
{
// store in eeprom
}
// else execute last received command
else
{
// read 'function' from eeprom and store in command
...
...
}
if(strcmp(command,"add") == 0)
{
add();
}
else if (strcmp(command,"subtract") == 0)
{
subtract();
}
}