Hello!
I'm making a WiFi temperature controller using ESP8266 and some DS18B20 sensors.
Part of the code is a webserver, used for OTA configuration and OTA update of the controller.
At some point, the user will fill the form using his browser, the info wil be read and stored to eeprom. Doing that the networking information and the DS18B20 adresses don't have to be hardcoded to the arduino.
The problem is that DS18B20 adresses will be received by the arduino on the following format:
String probe1_adr = "0x28:0xC2:0x9C:0x69:0x27:0x19:0x01:0x94";
I tokenize the string using strtok:
String probe1_adr = "0x28:0xC2:0x9C:0x69:0x27:0x19:0x01:0x94";
char *probe1_adr_c [8];
int probe1_len = probe1_adr.length() + 1;
char probe1array[probe1_len];
probe1_adr.toCharArray(probe1array, probe1_len);
char *ptr1 = NULL;
byte index1 = 0;
ptr1 = strtok(probe1array, ":");
while(ptr1 != NULL){
probe1_adr_c[index]= ptr1;
index++;
ptr1 = strtok(NULL, ":");
}
The result is an array containing every hex value read on the original string, but still on the string format:
probe1_adr_c[0]= "0x28";
probe1_adr_c[1]= "0xC2";
probe1_adr_c[2]= "0x9C";
probe1_adr_c[3]= "0x69";
probe1_adr_c[4]= "0x27";
probe1_adr_c[5]= "0x19";
probe1_adr_c[6]= "0x01";
probe1_adr_c[7]= "0x94";
How do I translate those hex values to a uint8_t array, like the one below?
uint8_t probe_ferm_uint8[8] = { 0x28, 0xC2, 0x9C, 0x69, 0x27, 0x19, 0x01, 0x94 };