// SafeString_Example1d.ino // install the SafeString library from the Arduino Library manager or // download and install the SafeString zip file from // www.forward.com.au/pfod/ArduinoProgramming/SafeString/index.html #include "SafeString.h" createSafeString(msgStr, 10, "A0"); // increased to capacity of 10 with initial value A0 void setup() { // Open serial communications and wait a few seconds Serial.begin(9600); for (int i = 10; i > 0; i--) { Serial.print(' '); Serial.print(i); delay(500); } Serial.println(); SafeString::setOutput(Serial); // enable error messages and debug() output to be sent to Serial if (SafeString::errorDetected()) { while (1) { Serial.println(F("Error is SafeString globals!!")); delay(3000); } } } void loop() { msgStr.print(" = 0x"); msgStr.print(analogRead(A0), HEX); // output the result Serial.println(msgStr); while (1) { // stop here delay(1); // add delay(1) to prevent ESP32 reboots } }