Skip to content

Commit

Permalink
Update bbn_m5atomS3_lite_DS18B20.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrouch authored Nov 6, 2024
1 parent 90139bd commit d534077
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void setup() {
if (!sensors.getAddress(deviceAddress, i)) {
gen_nmea0183_msg("$BBTXT,01,01,02,TEMPERATURE unable to find sensor address for device=%s", String(i).c_str());
} else {
char str[9];
char str[17];
addressToStr(deviceAddress, str);
gen_nmea0183_msg("$BBTXT,01,01,02,TEMPERATURE found sensor address=%s", str);
}
Expand All @@ -34,11 +34,12 @@ void byte_to_hex_ascii(unsigned char byte, char* hex_str) {

void addressToStr(DeviceAddress deviceAddress, char str[9]) {
for (uint8_t i = 0; i < 8; i++) {
char a;
char a[3];
byte_to_hex_ascii(deviceAddress[i], &a);
str[i] = a;
str[2 * i] = a[0];
str[2 * i + 1] = a[1];
}
str[8] = (char)0;
str[17] = (char)0;
}

void loop() {
Expand All @@ -48,7 +49,7 @@ void loop() {
for (int i = 0; i < count; i++) {
DeviceAddress deviceAddress;
if (sensors.getAddress(deviceAddress, i)) {
char str[9];
char str[17];
addressToStr(deviceAddress, str);
gen_nmea0183_msg("$BBXDR,C,%s", (String(sensors.getTempCByIndex(i)) + ",C,TEMP_" + String(str)).c_str()); // C
}
Expand Down

0 comments on commit d534077

Please sign in to comment.