problem using strcat function. Help please?

Hello all,

I’m having a very weird issue using the strcat function on an ESP8266 with the Arduino IDE. Hoping you all can help me figure out what’s going on.

What I am currently trying to do is measure the temperature from a SHT31 temperature sensor, then store the values (up to 60 measurements) in two different strings. One string is separated by underscores, the other is separated by commas. Code below:

#include <Adafruit_SHT31.h>
#include <RTClib.h>
#include <Wire.h>
#include <ESP8266WiFi.h>
//#include <SPI.h>
//#include <SD.h>

Adafruit_SHT31 sht31;
RTC_PCF8523 rtc;

float SHTtemp = 0.0;

char buffer[10];
char tt2[360];
char SDstring[52] = "";

void setup() {
  // put your setup code here, to run once:
  pinMode(A0, INPUT);


  if (!sht31.begin(0x44)) {
    Serial.println("Failed to find sht31");
    while (1)

void loop() {

void sht31Temperature () {
  SHTtemp = sht31.readTemperature();
  Serial.print("float temp: ");
  char *SHTtemp_char = dtostrf(SHTtemp, 4, 2, buffer);
  strcat(tt2, SHTtemp_char);
  strcat(tt2, "_");
  Serial.print("temp char: ");

// strcat(SDstring, dtostrf(SHTtemp, 4, 2, buffer);
strcat(SDstring, buffer);
  strcat(SDstring, ",");
  Serial.print("sd string: ");

When only creating one string, the code works great. Serial output is as expected. As soon as I try to create another string with the same values (either using the dtostrf or the buffer method above) it will run successfully for a few seconds then the strings seem to get “jumbled up.” There are some commas in the string that should have only underscores and vice versa. A quick screenshot of the serial output is below. You can see where it starts to mess up. Am I making a dumb mistake or is there something weird going wrong??

Thank you!!

I spoke too soon, it was indeed a dumb mistake. Mods, you can delete this thread if you'd like.