Try this
#include "SafeString.h"
//#include <LiquidCrystal.h>// Highlight out when ready to use mian display
//LiquidCrystal lcd(2, 4, 5, 3, 7, 8);
// to print the lcd data without an lcd
#define lcd Serial
const byte numChars = 10; //Number of bits to get
float resistance = 12.36;
double floatVal = 23.01;
String stringVal = ""; //data on buff is copied to this string
unsigned long previousMillis = 0; // will store last time LED was updated
const long interval = 1000; // interval at which to blink (milliseconds)
typedef struct Data_struct {
int PRO3600_Disconnected = 10;
boolean No_data ;
char receivedChars[numChars]; // an array to store the received data
} Data_struct;
Data_struct myData;
void setup()
{
Serial.begin(9600);
for (int i = 10; i > 0; i--) {
Serial.print(' '); Serial.print(i);
delay(500);
}
Serial.println();
// lcd.begin(8, 2);
// lcd.clear();
//resistance = resistance - 40.36;
SafeString::setOutput(Serial); // for error msgs
}
void loop()
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
resistance = resistance - 1.00;
}
createSafeStringFromCharArray(sfResistance, myData.receivedChars); // wraps in a SafeString and keeps the current text if any
sfResistance = ""; // clear it OR you could use myData.receivedChars[0] ='\0';
sfResistance.print(resistance, 2);
// dtostrf(resistance, 6, 2, myData.receivedChars); // L
Serial.print("dtstore: ");
Serial.println(myData.receivedChars); // just print it SafeString leaves the char[] correctly terminated even if there are errors
// lcd.setCursor(0, 0);
lcd.print(resistance);
// lcd.setCursor(0, 1);
lcd.print(myData.receivedChars);
lcd.println();
}