Hello,
I would like to run the following simple code to simulate my problem:
typedef struct
{
String sensorName;
byte pin;
byte state;
}
sensorData;
// sensors on this node {sensorname,pinnr,begin_state}
sensorData sensorTable[6] =
{
{"POG04",1,0},
{"POG14",1,0},
{"ROG04",1,0},
{"ROG14",1,0},
{"LOG04",1,0},
{"TOG04",1,0}
};
void setup()
{ Serial.begin(57600);};
int debug =1;
// function to write data to Log
void writeLog(char* msg)
{
if (debug == 1) {Serial.println(msg);} //else sometimes no nextline is given
}
void loop()
{
char msgTmp(100);
for (int i = 0; i < 6 ; i++)
{
sensorTable*.sensorName ; *
_ Serial.println(sensorTable*.sensorName) ;_
_ if (sensorTable.sensorName.charAt(0) == 'T') // movement only for PIR sensors*
* {
snprintf(msgTmp,sizeof msgTmp, " sensorname= %s",sensorTable.sensorName);
writeLog(msgTmp);
}
}
delay(1000);
}
When I comment the snprintf, it works.
When I compile the code with the snprintf command not commented out,
I get the following error:_
_invalid conversion from 'char' to 'char'
sketch_sep18b:38: error: initializing argument 1 of 'int snprintf(char*, size_t, const char*, ...)'
Does anyone know how to SNPRINTF a STRING object ?
Thanks a lot,
Jeroen._