From d534077f344717ef63936e049b575ee38839bc7e Mon Sep 17 00:00:00 2001 From: Mikhail Grushinskiy Date: Wed, 6 Nov 2024 13:39:17 -0500 Subject: [PATCH] Update bbn_m5atomS3_lite_DS18B20.ino --- .../bbn_m5atomS3_lite_DS18B20.ino | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino b/bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino index 19ccaee..6d4b3dd 100644 --- a/bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino +++ b/bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino @@ -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); } @@ -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() { @@ -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 }