Dereferencing char into a struct
In your situation, your best bet is probably to use the standard C function strcpy:

payload_t payload;
char* source = "abcdef";
strcpy(payload.sensorid, source);


Note that source string does not have to be declared as char source[20] and can be declared as the rather standard C string char*.

Also, since you are limiting the size of the string to be passed in payload, you may prefer to use strncpy which will ensure no more than 20 characters get copied:

payload_t payload;
char* source = "abcdef";
strncpy(payload.sensorid, source, 20);
// Explicitly add a string termination to the end of string
payload.sensorid[19] = 0;


In the snippet above, please notice the last line, it is necessary in the situation where source string length is 20 or more non-null characters, as in this case, strncpy will copy all 20 characters but will not add the terminating 0 at the end of the string.