Hi, I have DS18B20 ID's saved in EEPROM.
I write data to EEPROM from PC using my simple protocol - I send BYTE enter BYTE enter,... from pc to arduino.
Each byte is value from 0 to 255.
So if my DS18B20 has ID "28, 5D, 95, A2, 2, 0, 1, F9" i save to EEPROM "40, 93, 149, 162, 2, 0, 1, 249" - it is the same but in dec.
I have following code:
struct Abc {
byte DS18B20ID[9];
float tmp;
byte relay;
};
Abc s[3];
byte getAbcArrayID(byte* ) {
int sensorCount=sizeof(s) / sizeof(Abc);
for (int n=0; n<sensorCount ;n++) {
for (int i=0; i<8 ;i++) {
if (s[n].DS18B20ID[i] == soughtID[i]) {
return n;
}
}
}
}
void loop () {
byte count = sensors.getDeviceCount();
DeviceAddress da;
sensors.requestTemperatures();
if (!count == 0) {
for (byte i=0; i<count; i++) {
byte id[8];
for (byte e=0; e<8; e++) {
sensors.getAddress(da, i);
id[e] = da[e];
}
byte XXX = getAbcArrayID(id);
}
}
It doesn't work, because I compare "28, 5D, 95, A2, 2, 0, 1, F9" with "40, 93, 149, 162, 2, 0, 1, 249" - 5D!=95.
How can I convert dec2hex or hex2dec?
Or is there any other way how can I solve this problem?
Is possible to modify "void print_char_hex(volatile avr32_usart_t *usart, unsigned char n)"?