How convert eight hex characters to uint32_t using strtol() function? I want to control 4 pins using hexa code like this ff00ff00 (255, 0, 255, 0).

strtol() function works fine with three pins like 00ff00, but when i add two extra caracters to &amp;payload[1] variable like this ff00ff00.
((rgba >> 24) &amp; 0xFF) is equal to 127 when it should be 255.
How to make this work?

each analog pin should be set from 0 to 255

    analogWrite(LED_WHITE,  ((rgba &gt;&gt; 24) &amp; 0xFF));
    analogWrite(LED_RED,    ((rgba &gt;&gt; 16) &amp; 0xFF));
    analogWrite(LED_GREEN,  ((rgba &gt;&gt; 8) &amp; 0xFF));
    analogWrite(LED_BLUE,   ((rgba &gt;&gt; 0) &amp; 0xFF));


    uint32_t rgba = (uint32_t) strtol((const char *) &amp;payload[1], NULL, 16);
The function strtol() is not able to convert numbers that are larger than LONG_MAX and smaller than LONG_MIN as it uses signed numbers.

You should use the function strtoul() instead (for unsigned long integers). 

Cheers!