Can't compile: Large integer implicitly truncated to unsigned type [-Woverflow]

Good day fellow programmers,

I am having trouble with some code that I have been building for the last few months. These programs worked properly, compiled and ran my UNO R4 WiFi consistently without issue. On Jan28, there was some sort of disruption in IDE (it looked like a string of semicolons appended to one of the lines of code that I had open), and after removing them, the file would no longer compile. Amongst the many compilation errors, I believe the most prominent and perhaps causing the others is: "EMS_Code_Jan_29_2025.ino:14:23: warning: large integer implicitly truncated to unsigned type [-Woverflow]
const byte numChars = 256; // Was 64 and before that it was 34. Upped to 128 to see if this would stop data from wrappin"

This error never happened before, so I opened an older working iteration of the code (EMS_jan10a.ino) and that too is failing to compile for the same reason.

At that point I figured something is wrong with IDE, so I removed it from my Windows 11 PC, rebooted and reinstalled IDE 2.3.4 (downloaded from Arduino.CC). Still the same problem. That compile failure is happening with all the previous (working) versions that have those Serial1 communication and Datapacket components.

I have been running this Windows PC with all my firewall and antivirus turned off because I was experimenting with MQTT and mosquitto and wanted to be sure that there was no interference, so I don't think anything is going on there.

The attached program might have some other issues now because I was fiddling around trying to get it to compile, but this error still persists. Here is the entire code. There are two unused tabs on this program that I was afraid to remove that were left behind as I was building the serial communication components. I'm not a programmer by nature, but over the last 4 months I have learned a lot from this forum and elsewhere.
Again, this programmed worked (and the compiled version is on my UNO R4 right now, happily running and sending MQTT messages to the cloud test.mosquitto.org.

EMS_Code_Jan_29_2025.ino


#include <ArduinoMqttClient.h>
#include <ArduinoBLE.h>
#include <WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>

char ssid[] = "Sumeria";       //  your network SSID (name)
char pass[] = "******";  // your network password
int status = WL_IDLE_STATUS;   // the WiFi radio's status
char inChar;
char ReceiverTest;

const byte numChars = 256;      // Was 64 and before that it was 34. Upped to 128 to see if this would stop data from wrappin
char receivedChars[numChars];  // an array to store the received data

// Define a struct matching the sender's struct

struct DataPacket {
  int16_t PressureSuction, PressureLiquid, PressureHeat, Call4Compressor, Call4CompHeat;
  float ReversingTemp, LiquidTemp, SuctionTemp, CompressorTemp, FanTemp, AmbientTemp, FanAmps, CompressorAmps;
} __attribute__((packed));

DataPacket receivedData;
boolean newData = false;

const char* SerialNumber = "10974";

//Deprecating this area. These attributes will be tied to the SerialNumber in the AWS database
//char UserFirstName;
//char UserLastName;
//String Address1 = "15848 Cobble Mill Drive";
//char Address2;
//char City;
//char State;
//char Zip;

int decimalPrecision = 2;  // sets decimal precision for RMS value loop
int FuseOKin = D8;         // Detects 5VDC on pin D8 to determine the fuse is good
int FloatSwOKin = D9;      // Detects 5VDC on pin D9 to determine the float switch is not tripped
int Call4Coolin = D10;     // Detects the call for cool as 5VDC from the thermostat call for cool
int Call4Fanin = D11;      // Detects the call for Fan in the Blower as 5VDC for thermostat call for fan
int Call4Heatin = D5;
int ForceFanOut = D12;
int ForceCoolOut = D7;  //Had to move this to D7 becasue D13 is the default Arduino Led pin
int ForceHeatOut = D4;
float PanWetin = A5;
int FuseOK;  // Dimensions variables as intergers
int FloatSwOK;
int Call4Cool;
int Call4Fan;
int Call4Heat;
int ForceFan;   //Input from MQTT to force fan on
int ForceCool;  //Input from MQTT to force cool on
int ForceHeat;
int PanWet;
float SupplyAir;  //Dimensions variables as floating point values
float ReturnAir;
int BlowerAmpsIn = A1;           //dimesion variable for Blower Motor current measurement
int VoltageAnalogInputPin = A0;  //Input pin for Air Handler 24VAC RMS calculation
float voltageSampleRead = 0;     //Dimensioning variables for RMS calculations
float voltageLastSample = 0;
float voltageSampleSum = 0;
float voltageSampleCount = 0;
float voltageMean;
float RMSVoltageMean;
float adjustRMSVoltageMean;
float FinalRMSVoltage;
float voltageOffset1 = 0.00;  // Dimensioning variables for RMS calculations
float voltageOffset2 = 0.00;  // End of RMS calculation variables dimensioned
float calcVal;                //This sets calcVal to a decimal (floating) for Blower Amps
float BlowerAmps;

//Dimensioning variables for Compressor unit, who's values will be passed here to send to MQTT Broker
int16_t PressureSuction;
int16_t PressureLiquid;
int16_t PressureHeat;  // Craig added this and said with this additional pressure, he could tell something about the reversing valve
float CompressorAmps;  // Changed 1/16 to match variable type of Compressor program
float FanAmps;
int16_t Call4Compressor;
int16_t Call4CompHeat;
float ReversingTemp;
float LiquidTemp;
float SuctionTemp;
float CompressorTemp;
float FanTemp;
float AmbientTemp;
//End Compressor Unit variables

//* Air Temperature Mesurement Dimensions */
#define ONE_WIRE_BUS 6                // Data wire is plugged into port 6 (D6) on the Arduino
OneWire oneWire(ONE_WIRE_BUS);        // Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire);  // Pass our oneWire reference to Dallas Temperature.
int numberOfDevices;                  // Number of temperature devices found
DeviceAddress tempDeviceAddress;      // We'll use this variable to store a found device address

// Bluetooth® Low Energy Battery Service
BLEService batteryService("180F");

// Bluetooth® Low Energy Battery Level Characteristic
BLEUnsignedCharCharacteristic batteryLevelChar("2A19",                // standard 16-bit characteristic UUID
                                               BLERead | BLENotify);  // remote clients will be able to get notifications if this characteristic changes

int oldBatteryLevel = 0;  // last battery level reading from analog input
long previousMillis = 0;  // last time the battery level was checked, in ms

//MQTT Intialize variables
// MQTT broker details
const char* mqtt_server = "test.mosquitto.org";
const int mqtt_port = 1883;

// For MQTT topics, All data published under S/N, and Subscribes are received unser SerialNumber/ForceCool etc. Line 27
const char* topicPublish = SerialNumber;  // Publishing to to Topic SerialNummber "33598" in my demo version
//Creating Strings to use as Subscription attributes below around lines 151
String stringForceCool = "/ForceCool";
String topicSubscribe1 = SerialNumber + stringForceCool;  // Subscribe topic
String stringForceHeat = "/ForceHeat";
String topicSubscribe2 = SerialNumber + stringForceHeat;  //Subscribe topic
String stringForceFan = "/ForceFan";
String topicSubscribe3 = SerialNumber + stringForceFan;  //Sunscribe topic

// MQTT client
WiFiClient wifiClient;
MqttClient mqttClient(wifiClient);


void connectToWiFi() {
  Serial.print("Connecting to Wi-Fi");
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("\nWi-Fi connected.");
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());
}

void connectToMQTT() {
  Serial.print("Connecting to MQTT broker...");
  while (!mqttClient.connect(mqtt_server, mqtt_port)) {
    Serial.print(".");
    delay(1000);
  }

  Serial.println("\nConnected to MQTT broker.");

  // Subscribe to topics
  mqttClient.subscribe(topicSubscribe1);
  mqttClient.subscribe(topicSubscribe2);
  mqttClient.subscribe(topicSubscribe3);
  Serial.println("Subscribed to topics.");
}

// Print received data from Compressor Unit for debugging
void printDebuggingValues() {
  Serial.print("Serial Number: ");
  Serial.println(SerialNumber);
  Serial.println("Received data: ");
  Serial.print("PressureSuction= ");
  Serial.println(PressureSuction);
  Serial.print("PressureLiquid= ");
  Serial.println(PressureLiquid);
  Serial.print("PressureHeat= ");
  Serial.println(PressureHeat);
  Serial.print("Compressor Amps= ");
  Serial.println(CompressorAmps);
  Serial.print("Compressor Fan Amps= ");
  Serial.println(FanAmps);
  Serial.print("Call for Compressor= ");
  Serial.println(Call4Compressor);
  Serial.print("Call Compressor for Heat= ");
  Serial.println(Call4CompHeat);
  Serial.print("Reversing Valve Temp=");
  Serial.println(ReversingTemp);
  Serial.print("Compressor Liquid Temp=");
  Serial.println(LiquidTemp);
  Serial.print("Compressor Suction Temp=");
  Serial.println(SuctionTemp);
  Serial.print("Compressor Temp=");
  Serial.println(CompressorTemp);
  Serial.print("Compressor Fan Temp=");
  Serial.println(FanTemp);
  Serial.print("Ambient Air Temp=");
  Serial.println(AmbientTemp);

  //Printing Blower Unit parameters for Debugging
  Serial.print(calcVal);
  Serial.println("A - Blower Amps");
  Serial.print(FinalRMSVoltage);
  Serial.println(" VAC Supply Voltage");
  Serial.print("Return Air Temp F: ");
  Serial.println(ReturnAir);
  Serial.print("Supply Air Temp F: ");
  Serial.println(SupplyAir);
  Serial.print("Fuse OK: ");
  Serial.println(FuseOK);
  Serial.print("Float Switch OK: ");
  Serial.println(FloatSwOK);
  Serial.print("Call for Cool: ");
  Serial.println(Call4Cool);
  Serial.print("Call for Fan: ");
  Serial.println(Call4Fan);
  Serial.print("Call for Heat: ");
  Serial.println(Call4Heat);
  Serial.print("Pan is Wet: ");
  Serial.println(PanWet);
  Serial.print("Force Cool: ");
  Serial.println(ForceCool);
  Serial.print("Force Heat: ");
  Serial.println(ForceHeat);
  Serial.print("Force Fan: ");
  Serial.println(ForceFan);
  Serial.println();
}

void publishVariables() {
  // Construct JSON payload
  String payload = "{";
  payload += "\"PressureSuction\":" + String(PressureSuction) + ",";
  payload += "\"PressureLiquid\":" + String(PressureLiquid) + ",";
  payload += "\"PressureHeat\":" + String(PressureHeat) + ",";
  payload += "\"CompressorAmps\":" + String(CompressorAmps) + ",";
  payload += "\"FanAmps\":" + String(FanAmps) + ",";
  payload += "\"ReversingTemp\":" + String(ReversingTemp) + ",";
  payload += "\"LiquidTemp\":" + String(LiquidTemp) + ",";
  payload += "\"SuctionTemp\":" + String(SuctionTemp) + ",";
  payload += "\"CompressorTemp\":" + String(CompressorTemp) + ",";
  payload += "\"FanTemp\":" + String(FanTemp) + ",";
  payload += "\"AmbientTemp\":" + String(AmbientTemp) + ",";
  payload += "\"FuseOK\":" + String(FuseOK) + ",";
  payload += "\"FloatSwOK\":" + String(FloatSwOK) + ",";
  payload += "\"Call4Cool\":" + String(Call4Cool) + ",";
  payload += "\"Call4Fan\":" + String(Call4Fan) + ",";
  payload += "\"Call4Heat\":" + String(Call4Heat) + ",";
  payload += "\"PanWet\":" + String(PanWet) + ",";
  payload += "\"SupplyAir\":" + String(SupplyAir) + ",";
  payload += "\"ReturnAir\":" + String(ReturnAir) + ",";
  payload += "\"FinalRMSVoltage\":" + String(FinalRMSVoltage) + ",";
  payload += "\"BlowerAmps\":" + String(BlowerAmps);
  payload += "}";

  // Publish the payload
  mqttClient.beginMessage(topicPublish);
  mqttClient.print(payload);
  mqttClient.endMessage();

  Serial.println("Published: " + payload);
}

void handleIncomingMessages() {
  while (mqttClient.available()) {
    String topic = mqttClient.messageTopic();
    String payload = mqttClient.readString();
    Serial.println("Message received on topic: ");
    Serial.print(topic);
    Serial.print(" with payload: ");
    Serial.println(payload);

    // Handle messages based on topic
    if (topic == topicSubscribe1) {
      ForceCool = payload.toInt();
      Serial.print("Updated ForceCool to: ");
      Serial.println(ForceCool);
    } else if (topic == topicSubscribe2) {
      ForceHeat = payload.toInt();
      Serial.print("Updated ForceHeat to: ");
      Serial.println(ForceHeat);
    } else if (topic == topicSubscribe3) {
      ForceFan = payload.toInt();
      Serial.print("Updated ForceFan to: ");
      Serial.println(ForceFan);
    }
  }
}
//MQTT End variables

void setup() {
  // EMS Monitoring inputs

  pinMode(FuseOKin, INPUT);
  pinMode(FloatSwOKin, INPUT);
  pinMode(Call4Coolin, INPUT);
  pinMode(Call4Fanin, INPUT);
  pinMode(Call4Heatin, INPUT);
  pinMode(BlowerAmpsIn, INPUT);  //Used for Blower Motor Amps
  pinMode(ForceFanOut, OUTPUT);
  pinMode(ForceCoolOut, OUTPUT);
  pinMode(ForceHeatOut, OUTPUT);
  pinMode(PanWetin, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);  //Blink external LED on Pin13

  //int ForceFan = 0;   //I think remove these entries when MQTT is working
  //int ForceCool = 0;  //I think remove these entries when MQTT is working
  //int ForceHeat = 0;  // I think remove these entries when MQTT is working


  digitalWrite(ForceFanOut, HIGH);  // Added this to force output low upon powerup
  digitalWrite(ForceCoolOut, HIGH);
  digitalWrite(ForceHeatOut, HIGH);



  //Initialize serial and wait for port to open:
  Serial.begin(9600);  // start serial port - Removed in  line 314
  while (!Serial)
    //;  // wait for seril port to connect. Needed for native USB port only

    Serial1.begin(9600);  // Initialize second serial communication on external pins (Serial1, UART2)
  while (!Serial1) {
    ;  // Wait for serial port to connect. Needed for native USB port only

    delay(1000);
  }
  Serial.println("Uno ready to receive data.");

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true)
      ;
  }

  String fv = WiFi.firmwareVersion();
  if (fv != "1.1.0") {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network:
    status = WiFi.begin(ssid, pass);

    // wait 6 seconds for connection:
    delay(6000);
  }

  // you're connected now, so print out the data:
  Serial.println("You're connected to the network");
  //printCurrentNet();
  //printWifiData();

  sensors.begin();                             // Start up the library
  numberOfDevices = sensors.getDeviceCount();  // Grab a count of devices on the wire

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(numberOfDevices, DEC);
  Serial.println(" devices.");

  // Loop through each device, print out address
  for (int i = 0; i < numberOfDevices; i++)
    // Search the wire for address
    if (sensors.getAddress(tempDeviceAddress, i)) {
      Serial.print("Found device ");
      Serial.print(i, DEC);
      Serial.print(" with address: ");
      printAddress(tempDeviceAddress);
      Serial.println();

    } else {
      Serial.print("Found ghost device at ");
      Serial.print(i, DEC);
      Serial.print(" but could not detect address. Check power and cabling");
    }
  //MQTT Setup

  //Serial.begin(9600);
  connectToWiFi();
  mqttClient.setId("ArduinoUnoR4");
  //connectToMQTT();

  //MQTT Setup End
}
// function to print a device address
void printAddress(DeviceAddress deviceAddress) {
  for (uint8_t i = 0; i < 8; i++) {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }

  pinMode(LED_BUILTIN, OUTPUT);  // initialize the built-in LED pin to indicate when a central is connected

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting BLE failed!");

    while (1)
      ;
  }
  /* Set a local name for the Bluetooth® Low Energy device
     This name will appear in advertising packets
     and can be used by remote devices to identify this Bluetooth® Low Energy device
     The name can be changed but maybe be truncated based on space left in advertisement packet
  */
  BLE.setLocalName("BatteryMonitor");
  BLE.setAdvertisedService(batteryService);            // add the service UUID
  batteryService.addCharacteristic(batteryLevelChar);  // add the battery level characteristic
  BLE.addService(batteryService);                      // Add the battery service
  batteryLevelChar.writeValue(oldBatteryLevel);        // set initial value for this characteristic

  /* Start advertising Bluetooth® Low Energy.  It will start continuously transmitting Bluetooth® Low Energy
     advertising packets and will be visible to remote Bluetooth® Low Energy central devices
     until it receives a new connection */

  // start advertising
  BLE.advertise();
  Serial.println("Bluetooth® device active, waiting for connections...");
}


void loop() {  // put your main code here, to run repeatedly:
  //Added MQTT up here instaead of at the end of Loop
  if (!mqttClient.connected()) {
    connectToMQTT();
  }
  mqttClient.poll();
  unsigned long currentMillis = millis();
  // Publish variables every 5 seconds
  static unsigned long lastPublishTime = 0;
  if (millis() - lastPublishTime >= 5000) {
    lastPublishTime = millis();
    publishVariables();
    printDebuggingValues();
  }

  // Handle incoming MQTT messages
  handleIncomingMessages();
  //This is the end of me pasting this all in from the bottom

  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(200);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(200);                       // wait for a second


  //delay for good measure
  delay(10);

  //int ForceFan = 0;   //I think remove these entries when MQTT is working
  //int ForceCool = 0;  //I think remove these entries when MQTT is working
  //int ForceHeat = 0;  // I think remove these entries when MQTT is working

  BlowerAmps = analogRead(BlowerAmpsIn);  //reads the data from the dimensioned pin, Pin A1 (see above)
  calcVal = (.00978) * BlowerAmps;        //5Volts / 1023 (full scale analog value of pinA1) the decimal points in teh scaling gives me decimal values such as 4.25(Volts)
  //Serial.print(calcVal);                  //will be visible in the Serial Monitor (mag glass in top right)
  //Serial.println("A - Blower Amps");
  //delay(1000);  //gives a line feed, and waits a half a second, then shows the next  read value

  //Device data in and out defenitions
  FuseOK = digitalRead(FuseOKin);
  FloatSwOK = digitalRead(FloatSwOKin);
  Call4Cool = digitalRead(Call4Coolin);
  Call4Fan = digitalRead(Call4Fanin);
  Call4Heat = digitalRead(Call4Heatin);

  if (analogRead(PanWetin) >= 400) {
    PanWet = 1;
  } else {
    PanWet = 0;
  }


  if (ForceFan == 1) digitalWrite(ForceFanOut, LOW);  //Accomodates an MQTT subscription destination for forcing activity
  if (ForceFan == 0) digitalWrite(ForceFanOut, HIGH);

  if (ForceCool == 1) digitalWrite(ForceCoolOut, LOW);  //Accomodates an MQTT subscription destination for forcing activity
  if (ForceCool == 0) digitalWrite(ForceCoolOut, HIGH);

  if (ForceHeat == 1) digitalWrite(ForceHeatOut, LOW);  //Accomodates an MQTT subscription destination for forcing activity
  if (ForceHeat == 0) digitalWrite(ForceHeatOut, HIGH);

  //* 1- AC Voltage Measurement */
  if (micros() >= voltageLastSample + 1000)
    do {
      {
        voltageSampleRead = (analogRead(VoltageAnalogInputPin) - 512) + voltageOffset1;
        voltageSampleSum = voltageSampleSum + sq(voltageSampleRead);

        voltageSampleCount = voltageSampleCount + 1;
        voltageLastSample = micros();
      }
    } while (voltageSampleCount < 1000);

  if (voltageSampleCount == 1000)  //this value is 1000, that is 1 second of sampling and averaging RMS
  {
    voltageMean = voltageSampleSum / voltageSampleCount;
    RMSVoltageMean = (sqrt(voltageMean)) * 1.5;
    //adjustRMSVoltageMean = RMSVoltageMean + voltageOffset2;
    FinalRMSVoltage = RMSVoltageMean + voltageOffset2;
    if (FinalRMSVoltage <= 2.5)  //this trims low values to zero
    { FinalRMSVoltage = 0; }     //this and above trims low values to zero


    //Serial.print(FinalRMSVoltage);  //test line to see the RMS value
    //Serial.println(" VAC Supply Voltage");
    voltageSampleSum = 0;    //resets the calulation for RMS
    voltageSampleCount = 0;  //resets the calulation for RMS
    FinalRMSVoltage = 0;
  }  //resets the calculation for RMS

  //* 1- AC Voltage Measurement End*/

  // Start of Temperature Sensor Code for OneWire Devices

  sensors.requestTemperatures();  // Send the command to get temperatures
  // Loop through each device, print out temperature data
  for (int i = 0; i < numberOfDevices; i++) {
    // Search the wire for address
    if (sensors.getAddress(tempDeviceAddress, i)) {

      //// Output the device ID  // removed this section because I don't need to see this in the monitor anymore
      //Serial.print("Temperature for device: ");
      //Serial.println(i, DEC);

      // Print the data
      if (sensors.getAddress(tempDeviceAddress, 0)) {
        float tempF = sensors.getTempF(tempDeviceAddress);
        //Serial.print("Supply Air Temp F: ");
        //Serial.println(tempF);
        SupplyAir = (tempF);
      }

      if (sensors.getAddress(tempDeviceAddress, 1)) {
        float tempF = sensors.getTempF(tempDeviceAddress);
        //Serial.print("Return Air Temp F: ");
        //Serial.println(tempF);
        ReturnAir = (tempF);
      }
      // End Temperature Sensor Code

      // Begin Serial Communication from remote Compressor, Arduino Nano
      // Check if enough bytes are available
      if (Serial1.available() >= sizeof(receivedData)) {        //   Serial1 is the 2nd Serial port on D0 and D1 of Uno
        Serial.println("Serial 1 readyto go");            //Inserted just to be sure that Serial 1 has been identified as available
      }
      static bool waitingForMarker = true;
      static size_t receivedBytes = 0;
      static char buffer[sizeof(DataPacket)];

      while (Serial1.available()) {
        char byte = Serial1.read();  // I think this clears the buffer

        if (waitingForMarker) {
          // Look for the start marker
          if (byte == 0x7E) {
            waitingForMarker = false;  // Found start marker
            receivedBytes = 0;         // Reset buffer counter
          }
        } else {
          // Collect data into buffer
          buffer[receivedBytes++] = byte;
        }
        // Check if full packet is received
        if (receivedBytes == sizeof(DataPacket)) {
          // Copy buffer into struct
          memcpy(&receivedData, buffer, sizeof(DataPacket));

          //Serial.println("Received raw bytes:");  //Removed this Debug code to match raw data received with sender raw data
          //for (size_t i = 0; i < sizeof(receivedData); i++) {
          //Serial.print(((unsigned char*)&receivedData)[i], HEX);
          //Serial.print(" ");
          //}
          waitingForMarker = true;
          receivedBytes = 0;
        }
        if (receivedBytes > sizeof(DataPacket)) {
          waitingForMarker = true;
          receivedBytes = 0;
        }
      }

      //parsing the dataPacket received on Serial1 input

      int16_t PressureLiquid = receivedData.PressureLiquid;
      int16_t PressureHeat = receivedData.PressureHeat;
      float CompressorAmps = receivedData.CompressorAmps;
      float FanAmps = receivedData.FanAmps;
      int16_t Call4Compressor = receivedData.Call4Compressor;
      int16_t Call4CompHeat = receivedData.Call4CompHeat;
      int16_t PressureSuction = receivedData.PressureSuction;

      float ReversingTemp = receivedData.ReversingTemp;
      float LiquidTemp = receivedData.LiquidTemp;
      float SuctionTemp = receivedData.SuctionTemp;
      float CompressorTemp = receivedData.CompressorTemp;
      float FanTemp = receivedData.FanTemp;
      float AmbientTemp = receivedData.AmbientTemp;
    }
    //Bluetooth code begin
    // wait for a Bluetooth® Low Energy central
    BLEDevice central = BLE.central();

    // if a central is connected to the peripheral:
    if (central) {
      Serial.print("Connected to central: ");
      // print the central's BT address:
      Serial.println(central.address());
      // turn on the LED to indicate the connection:
      digitalWrite(LED_BUILTIN, HIGH);

      // check the battery level every 200ms
      // while the central is connected:
      while (central.connected()) {
        long currentMillis = millis();
        // if 200ms have passed, check the battery level:
        if (currentMillis - previousMillis >= 200) {
          previousMillis = currentMillis;
          updateBatteryLevel();
        }
      }
      // when the central disconnects, turn off the LED:
      digitalWrite(LED_BUILTIN, LOW);
      Serial.print("Disconnected from central: ");
      Serial.println(central.address());
    }
  }
}

void updateBatteryLevel() {
  /* Read the current voltage level on the A0 analog input pin.
     This is used here to simulate the charge level of a battery.
  */
  int battery = analogRead(A0);  // this is test dcode for Bluetooth connectivity. A0 conflicts with the RMS voltage input
  int batteryLevel = map(battery, 0, 1023, 0, 100);

  if (batteryLevel != oldBatteryLevel) {       // if the battery level has changed
    Serial.print("Battery Level % is now: ");  // print it
    Serial.println(batteryLevel);
    batteryLevelChar.writeValue(batteryLevel);  // and update the battery level characteristic
    oldBatteryLevel = batteryLevel;             // save the level for next comparison
  }
}

And the embedded in use tab:
recWithStartEndMarker.ino


void recvWithStartEndMarkers() {
  static boolean recvInProgress = false;
  static byte ndx = 0;
  char startMarker = 0x7E;
  char endMarker = '!';
  char rc;

  while (Serial1.available() > 0 && newData == false) { // <<== NEW - get all bytes from buffer
    rc = Serial1.read();

    if (recvInProgress == true) {
      if (rc != endMarker) {
        receivedChars[ndx] = rc;
        ndx++;
        if (ndx >= numChars) {
          ndx = numChars - 1;
        }
      }
      else {
        receivedChars[ndx] = endMarker;//preserve endmarker 
        receivedChars[ndx+1] = '\0';// terminate the string
        recvInProgress = false;
        ndx = 0;
        newData = true;
      }
    }

    else if (rc == startMarker) {
      receivedChars[0] = startMarker;//preserve startMarker
      ndx++;
      recvInProgress = true;
    }
  } 
}

Here are the console errors from the compile effort:

C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:14:23: warning: large integer implicitly truncated to unsigned type [-Woverflow]
 const byte numChars = 256;      // Was 64 and before that it was 34. Upped to 128 to see if this would stop data from wrappin
                       ^~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino: In function 'void loop()':
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:539:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if (Serial1.available() >= sizeof(receivedData)) {        //   Serial1 is the 2nd Serial port on D0 and D1 of Uno
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:580:15: warning: unused variable 'PressureLiquid' [-Wunused-variable]
       int16_t PressureLiquid = receivedData.PressureLiquid;
               ^~~~~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:581:15: warning: unused variable 'PressureHeat' [-Wunused-variable]
       int16_t PressureHeat = receivedData.PressureHeat;
               ^~~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:582:13: warning: unused variable 'CompressorAmps' [-Wunused-variable]
       float CompressorAmps = receivedData.CompressorAmps;
             ^~~~~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:583:13: warning: unused variable 'FanAmps' [-Wunused-variable]
       float FanAmps = receivedData.FanAmps;
             ^~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:584:15: warning: unused variable 'Call4Compressor' [-Wunused-variable]
       int16_t Call4Compressor = receivedData.Call4Compressor;
               ^~~~~~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:585:15: warning: unused variable 'Call4CompHeat' [-Wunused-variable]
       int16_t Call4CompHeat = receivedData.Call4CompHeat;
               ^~~~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:586:15: warning: unused variable 'PressureSuction' [-Wunused-variable]
       int16_t PressureSuction = receivedData.PressureSuction;
               ^~~~~~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:588:13: warning: unused variable 'ReversingTemp' [-Wunused-variable]
       float ReversingTemp = receivedData.ReversingTemp;
             ^~~~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:589:13: warning: unused variable 'LiquidTemp' [-Wunused-variable]
       float LiquidTemp = receivedData.LiquidTemp;
             ^~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:590:13: warning: unused variable 'SuctionTemp' [-Wunused-variable]
       float SuctionTemp = receivedData.SuctionTemp;
             ^~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:591:13: warning: unused variable 'CompressorTemp' [-Wunused-variable]
       float CompressorTemp = receivedData.CompressorTemp;
             ^~~~~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:592:13: warning: unused variable 'FanTemp' [-Wunused-variable]
       float FanTemp = receivedData.FanTemp;
             ^~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:593:13: warning: unused variable 'AmbientTemp' [-Wunused-variable]
       float AmbientTemp = receivedData.AmbientTemp;
             ^~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\EMS_Code_Jan_29_2025.ino:423:17: warning: unused variable 'currentMillis' [-Wunused-variable]
   unsigned long currentMillis = millis();
                 ^~~~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\SerialReceiveEndMarker.ino: In function 'void recvWithEndMarker()':
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\SerialReceiveEndMarker.ino:15:21: warning: comparison is always true due to limited range of data type [-Wtype-limits]
             if (ndx >= numChars) {
                 ~~~~^~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\recvWithStartEndMarker.ino: In function 'void recvWithStartEndMarkers()':
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\recvWithStartEndMarker.ino:16:17: warning: comparison is always true due to limited range of data type [-Wtype-limits]
         if (ndx >= numChars) {
             ~~~~^~~~~~~~~~~
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\SerialReceiveEndMarker.ino: In function 'void recvWithEndMarker()':
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\SerialReceiveEndMarker.ino:13:30: warning: array subscript is above array bounds [-Warray-bounds]
             receivedChars[ndx] = rc;
             ~~~~~~~~~~~~~~~~~^
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\SerialReceiveEndMarker.ino:20:30: warning: array subscript is above array bounds [-Warray-bounds]
             receivedChars[ndx] = '\0'; // terminate the string
             ~~~~~~~~~~~~~~~~~^
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\recvWithStartEndMarker.ino: In function 'void recvWithStartEndMarkers()':
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\recvWithStartEndMarker.ino:14:26: warning: array subscript is above array bounds [-Warray-bounds]
         receivedChars[ndx] = rc;
         ~~~~~~~~~~~~~~~~~^
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\recvWithStartEndMarker.ino:21:26: warning: array subscript is above array bounds [-Warray-bounds]
         receivedChars[ndx] = endMarker;//preserve endmarker
         ~~~~~~~~~~~~~~~~~^
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\recvWithStartEndMarker.ino:22:28: warning: array subscript is above array bounds [-Warray-bounds]
         receivedChars[ndx+1] = '\0';// terminate the string
         ~~~~~~~~~~~~~~~~~~~^
C:\Users\mikeg\Documents\Arduino\EMS_Code_Jan_29_2025\recvWithStartEndMarker.ino:30:22: warning: array subscript is above array bounds [-Warray-bounds]
       receivedChars[0] = startMarker;//preserve startMarker
       ~~~~~~~~~~~~~~~^
Sketch uses 102748 bytes (39%) of program storage space. Maximum is 262144 bytes.
Global variables use 9720 bytes (29%) of dynamic memory, leaving 23048 bytes for local variables. Maximum is 32768 bytes.

I am at a loss as why this is failing, since it previously worked. Below I am also attaching an earlier version that also worked, and now is giving the same compilation error.

#include <ArduinoMqttClient.h>
#include <ArduinoBLE.h>
//#include <WiFiS3.h>
//#include <SPI.h>
#include <WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>

char ssid[] = "Sumeria";       //  your network SSID (name)
char pass[] = "*******";  // your network password
int status = WL_IDLE_STATUS;   // the WiFi radio's status
char inChar;
char ReceiverTest;

const byte numChars = 256;     // Was 64 and before that it was 34. Upped to 128 to see if this would stop data from wrappin
char receivedChars[numChars];  // an array to store the received data

// Define a struct matching the sender's struct

struct DataPacket {
  int16_t PressureSuction, PressureLiquid, PressureHeat, CompressorAmps, FanAmps, Call4Compressor, Call4CompHeat;
  float ReversingTemp, LiquidTemp, SuctionTemp, CompressorTemp, FanTemp, AmbientTemp;
} __attribute__((packed));

DataPacket receivedData;
boolean newData = false;

String SerialNumber = "74519.33598";
char UserFirstName;
//Need to expand this area
char UserLastName;

String Address1= "15848 Cobble Mill Drive";
char Address2;
char City;
char State;
char Zip;


int decimalPrecision = 2;  // sets decimal precision for RMS value loop
int FuseOKin = D8;         // Detects 5VDC on pin D8 to determine the fuse is good
int FloatSwOKin = D9;      // Detects 5VDC on pin D9 to determine the float switch is not tripped
int Call4Coolin = D10;     // Detects the call for cool as 5VDC from the thermostat call for cool
int Call4Fanin = D11;      // Detects the call for Fan in the Blower as 5VDC for thermostat call for fan
int Call4Heatin = D5;
int ForceFanOut = D12;
int ForceCoolOut = D7;  //Had to move this to D7 becasue D13 is the default Arduino Led pin
int ForceHeatOut = D4;
int PanWetin = D3;
int FuseOK;  // Dimensions variables as intergers
int FloatSwOK;
int Call4Cool;
int Call4Fan;
int Call4Heat;
int ForceFan;   //Input from MQTT to force fan on
int ForceCool;  //Input from MQTT to force cool on
int ForceHeat;
int PanWet;
float SupplyAir;  //Dimensions variables as floating point values
float ReturnAir;
int BlowerAmps = A1;             //dimesion variable for Blower Motor current measurement
int VoltageAnalogInputPin = A0;  //Input pin for Air Handler 24VAC RMS calculation
float voltageSampleRead = 0;     //Dimensioning variables for RMS calculations
float voltageLastSample = 0;
float voltageSampleSum = 0;
float voltageSampleCount = 0;
float voltageMean;
float RMSVoltageMean;
float adjustRMSVoltageMean;
float FinalRMSVoltage;
float voltageOffset1 = 0.00;  // Dimensioning variables for RMS calculations
float voltageOffset2 = 0.00;  // End of RMS calculation variables dimensioned
float calcVal;                //This sets calcVal to a decimal (floating) for Blower Amps


//Dimensioning variables for Compressor unit, who's values will be passed here to send to MQTT Broker
int16_t PressureSuction;
int16_t PressureLiquid;
int16_t PressureHeat;  // Craig added this and said with this additional pressure, he could tell something about the reversing valve
int16_t CompressorAmps;
int16_t FanAmps;
int16_t Call4Compressor;
int16_t Call4CompHeat;
float ReversingTemp;
float LiquidTemp;
float SuctionTemp;
float CompressorTemp;
float FanTemp;
float AmbientTemp;

//End Compressor Unit variables

//* Air Temperature Mesurement Dimensions */
#define ONE_WIRE_BUS 6                // Data wire is plugged into port 6 (D6) on the Arduino
OneWire oneWire(ONE_WIRE_BUS);        // Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire);  // Pass our oneWire reference to Dallas Temperature.
int numberOfDevices;                  // Number of temperature devices found
DeviceAddress tempDeviceAddress;      // We'll use this variable to store a found device address

// Bluetooth® Low Energy Battery Service
BLEService batteryService("180F");

// Bluetooth® Low Energy Battery Level Characteristic
BLEUnsignedCharCharacteristic batteryLevelChar("2A19",                // standard 16-bit characteristic UUID
                                               BLERead | BLENotify);  // remote clients will be able to get notifications if this characteristic changes

int oldBatteryLevel = 0;  // last battery level reading from analog input
long previousMillis = 0;  // last time the battery level was checked, in ms



void setup() {
  // EMS Monitoring inputs
  pinMode(FuseOKin, INPUT);
  pinMode(FloatSwOKin, INPUT);
  pinMode(Call4Coolin, INPUT);
  pinMode(Call4Fanin, INPUT);
  pinMode(Call4Heatin, INPUT);
  pinMode(BlowerAmps, INPUT);  //Used for Blower Motor Amps
  pinMode(ForceFanOut, OUTPUT);
  pinMode(ForceCoolOut, OUTPUT);
  pinMode(ForceHeatOut, OUTPUT);
  pinMode(PanWetin, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);  //Blink external LED on Pin13

  int ForceFan = 0;   //I think remove these entries when MQTT is working
  int ForceCool = 0;  //I think remove these entries when MQTT is working
  int ForceHeat = 0;  // I think remove these entries when MQTT is working


  digitalWrite(ForceFanOut, HIGH);  // Added this to force output low upon powerup
  digitalWrite(ForceCoolOut, HIGH);
  digitalWrite(ForceHeatOut, HIGH);



  //Initialize serial and wait for port to open:
  Serial.begin(9600);  // start serial port
  while (!Serial)
    ;  // wait for seril port to connect. Needed for native USB port only

  Serial1.begin(9600);  // Initialize second serial communication on external pins (Serial1, UART2)
  while (!Serial1) {
    ;  // Wait for serial port to connect. Needed for native USB port only

    delay(5000);
  }
  Serial.println("Uno ready to receive data.");


  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true)
      ;
  }

  String fv = WiFi.firmwareVersion();
  if (fv != "1.1.0") {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network:
    status = WiFi.begin(ssid, pass);

    // wait 6 seconds for connection:
    delay(6000);
  }

  // you're connected now, so print out the data:
  Serial.println("You're connected to the network");
  //printCurrentNet();
  //printWifiData();

  sensors.begin();                             // Start up the library
  numberOfDevices = sensors.getDeviceCount();  // Grab a count of devices on the wire

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(numberOfDevices, DEC);
  Serial.println(" devices.");

  // Loop through each device, print out address
  for (int i = 0; i < numberOfDevices; i++)
    // Search the wire for address
    if (sensors.getAddress(tempDeviceAddress, i)) {
      Serial.print("Found device ");
      Serial.print(i, DEC);
      Serial.print(" with address: ");
      printAddress(tempDeviceAddress);
      Serial.println();
    } else {
      Serial.print("Found ghost device at ");
      Serial.print(i, DEC);
      Serial.print(" but could not detect address. Check power and cabling");
    }
}
// function to print a device address
void printAddress(DeviceAddress deviceAddress) {
  for (uint8_t i = 0; i < 8; i++) {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }

  pinMode(LED_BUILTIN, OUTPUT);  // initialize the built-in LED pin to indicate when a central is connected

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting BLE failed!");

    while (1)
      ;
  }
  /* Set a local name for the Bluetooth® Low Energy device
     This name will appear in advertising packets
     and can be used by remote devices to identify this Bluetooth® Low Energy device
     The name can be changed but maybe be truncated based on space left in advertisement packet
  */
  BLE.setLocalName("BatteryMonitor");
  BLE.setAdvertisedService(batteryService);            // add the service UUID
  batteryService.addCharacteristic(batteryLevelChar);  // add the battery level characteristic
  BLE.addService(batteryService);                      // Add the battery service
  batteryLevelChar.writeValue(oldBatteryLevel);        // set initial value for this characteristic

  /* Start advertising Bluetooth® Low Energy.  It will start continuously transmitting Bluetooth® Low Energy
     advertising packets and will be visible to remote Bluetooth® Low Energy central devices
     until it receives a new connection */

  // start advertising
  BLE.advertise();

  Serial.println("Bluetooth® device active, waiting for connections...");
}


void loop() {  // put your main code here, to run repeatedly:

  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(200);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(200);                       // wait for a second


  //delay for good measure
  delay(10);


  int ForceFan = 0;   //I think remove these entries when MQTT is working
  int ForceCool = 0;  //I think remove these entries when MQTT is working
  int ForceHeat = 0;  // I think remove these entries when MQTT is working

  analogRead(BlowerAmps);                              //reads the data from the dimensioned pin, Pin A1 (see above)
  calcVal = (1. / 1023.) * (analogRead(BlowerAmps));  //5Volts / 1023 (full scale analog value of pinA1) the decimal points in teh scaling gives me decimal values such as 4.25(Volts)
  Serial.print(calcVal);                               //will be visible in the Serial Monitor (mag glass in top right)
  Serial.println("A - Blower Amps");
  delay(1000);  //gives a line feed, and waits a half a second, then shows the next  read value

  //Device data in and out defenitions
  FuseOK = digitalRead(FuseOKin);
  FloatSwOK = digitalRead(FloatSwOKin);
  Call4Cool = digitalRead(Call4Coolin);
  Call4Fan = digitalRead(Call4Fanin);
  Call4Heat = digitalRead(Call4Heatin);
  PanWet = digitalRead(PanWetin);

  if (ForceFan == 1) digitalWrite(ForceFanOut, LOW);  //Accomodates an MQTT subscription destination for forcing activity
  if (ForceFan == 0) digitalWrite(ForceFanOut, HIGH);

  if (ForceCool == 1) digitalWrite(ForceCoolOut, LOW);  //Accomodates an MQTT subscription destination for forcing activity
  if (ForceCool == 0) digitalWrite(ForceCoolOut, HIGH);

  if (ForceHeat == 1) digitalWrite(ForceHeatOut, LOW);  //Accomodates an MQTT subscription destination for forcing activity
  if (ForceHeat == 0) digitalWrite(ForceHeatOut, HIGH);

  //* 1- AC Voltage Measurement */
  if (micros() >= voltageLastSample + 1000)
    do {
      {
        voltageSampleRead = (analogRead(VoltageAnalogInputPin) - 512) + voltageOffset1;
        voltageSampleSum = voltageSampleSum + sq(voltageSampleRead);

        voltageSampleCount = voltageSampleCount + 1;
        voltageLastSample = micros();
      }
    } while (voltageSampleCount < 1000);

  if (voltageSampleCount == 1000)  //this value is 1000, that is 1 second of sampling and averaging RMS
  {
    voltageMean = voltageSampleSum / voltageSampleCount;
    RMSVoltageMean = (sqrt(voltageMean)) * 1.5;
    //adjustRMSVoltageMean = RMSVoltageMean + voltageOffset2;
    FinalRMSVoltage = RMSVoltageMean + voltageOffset2;
    if (FinalRMSVoltage <= 2.5)  //this trims low values to zero
    { FinalRMSVoltage = 0; }     //this and above trims low values to zero
    //lcd.setCursor(0,0);
    //lcd.print("The RMS Value: ");
    //lcd.setCursor(0,1);
    //lcd.print(FinalRMSVoltage,decimalPrecision);
    //lcd.print (" VAC ");

    Serial.print(FinalRMSVoltage);  //test line to see the RMS value
    Serial.println(" VAC Supply Voltage");
    voltageSampleSum = 0;    //resets the calulation for RMS
    voltageSampleCount = 0;  //resets the calulation for RMS
    FinalRMSVoltage = 0;
  }  //resets the calculation for RMS

  //* 1- AC Voltage Measurement End*/

  // Start of Temperature Sensor Code for OneWire Devices

  sensors.requestTemperatures();  // Send the command to get temperatures

  // Loop through each device, print out temperature data
  for (int i = 0; i < numberOfDevices; i++) {
    // Search the wire for address
    if (sensors.getAddress(tempDeviceAddress, i)) {

      //// Output the device ID  // removed this section because I don't need to see this in the monitor anymore
      //Serial.print("Temperature for device: ");
      //Serial.println(i, DEC);

      // Print the data
      if (sensors.getAddress(tempDeviceAddress, 0)) {
        float tempF = sensors.getTempF(tempDeviceAddress);
        Serial.print("Supply Air Temp F: ");
        Serial.println(tempF);
        SupplyAir = (tempF);
      }

      if (sensors.getAddress(tempDeviceAddress, 1)) {
        float tempF = sensors.getTempF(tempDeviceAddress);
        Serial.print("Return Air Temp F: ");
        Serial.println(tempF);
        ReturnAir = (tempF);
      }
      // End Temperature Sensor Code

      // Begin Serial Communication from remote Compressor, Arduino Nano
      // Check if enough bytes are available
      if (Serial1.available() >= sizeof(receivedData)) { // Serial1 is the 2nd Serial port on D0 and D1 of Uno
        Serial.println("Serial 1 readyto go");  //Inserted just to be sure that Serial 1 has been identified as available
      }
      static bool waitingForMarker = true;
      static size_t receivedBytes = 0;
      static char buffer[sizeof(DataPacket)];

      while (Serial1.available()) {
        char byte = Serial1.read(); // I think this clears the buffer

        if (waitingForMarker) {
          // Look for the start marker
          if (byte == 0x7E) {
            waitingForMarker = false;  // Found start marker
            receivedBytes = 0;         // Reset buffer counter
          }
        } else {
          // Collect data into buffer
          buffer[receivedBytes++] = byte;
        }
        // Check if full packet is received
        if (receivedBytes == sizeof(DataPacket)) {
          // Copy buffer into struct
          memcpy(&receivedData, buffer, sizeof(DataPacket));

          //Serial.println("Received raw bytes:");  //Removed this Debug code to match raw data received with sender raw data
          //for (size_t i = 0; i < sizeof(receivedData); i++) {
            //Serial.print(((unsigned char*)&receivedData)[i], HEX);
            //Serial.print(" ");
          //}
          waitingForMarker = true;
          receivedBytes = 0;
        }
        if (receivedBytes > sizeof(DataPacket)) {
        waitingForMarker = true;
        receivedBytes = 0;
        }
      }

      //parsing the dataPacket received on Serial1 input

      int16_t PressureLiquid = receivedData.PressureLiquid;
      int16_t PressureHeat = receivedData.PressureHeat;
      int16_t CompressorAmps = receivedData.CompressorAmps;
      int16_t FanAmps = receivedData.FanAmps;
      int16_t Call4Compressor = receivedData.Call4Compressor;
      int16_t Call4CompHeat = receivedData.Call4CompHeat;
      int16_t PressureSuction = receivedData.PressureSuction;

      float ReversingTemp = receivedData.ReversingTemp;
      float LiquidTemp = receivedData.LiquidTemp;
      float SuctionTemp = receivedData.SuctionTemp;
      float CompressorTemp = receivedData.CompressorTemp;
      float FanTemp = receivedData.FanTemp;
      float AmbientTemp = receivedData.AmbientTemp;

      // Print received data for debugging
      Serial.println("Received data: ");
      Serial.print("PressureSuction= ");
      Serial.println(PressureSuction);
      Serial.print("PressureLiquid= ");
      Serial.println(PressureLiquid);
      Serial.print("PressureHeat= ");
      Serial.println(PressureHeat);
      Serial.print("CompressorAmps= ");
      Serial.println(CompressorAmps);
      Serial.print("FanAmps= ");
      Serial.println(FanAmps);
      Serial.print("Call4Compressor= ");
      Serial.println(Call4Compressor);
      Serial.print("Call4CompHeat= ");
      Serial.println(Call4CompHeat);

      Serial.print("ReversingTemp=");
      Serial.println(ReversingTemp);
      Serial.print("LiquidTemp=");
      Serial.println(LiquidTemp);
      Serial.print("SuctionTemp=");
      Serial.println(SuctionTemp);
      Serial.print("CompressorTemp=");
      Serial.println(CompressorTemp);
      Serial.print("FanTemp=");
      Serial.println(FanTemp);
      Serial.print("AmbientTemp=");
      Serial.println(AmbientTemp);

      Serial.print("Fuse OK: ");
      Serial.println(FuseOK);
      Serial.print("Float Switch OK: ");
      Serial.println(FloatSwOK);
      Serial.print("Call for Cool: ");
      Serial.println(Call4Cool);
      Serial.print("Call for Fan: ");
      Serial.println(Call4Fan);
      Serial.print("Serial Number: ");
      Serial.println(SerialNumber);
      Serial.print("Address 1: ");
      Serial.println(Address1);
      Serial.print("Call for Heat: ");
      Serial.println(Call4Heat);
      Serial.print("Pan is Wet: ");
      Serial.println(PanWet);
      Serial.print("Force Fan: ");
      Serial.println(ForceFan);
      Serial.println();
    }
    
    //Bluetooth code begin 
    // wait for a Bluetooth® Low Energy central
    BLEDevice central = BLE.central();

    // if a central is connected to the peripheral:
    if (central) {
      Serial.print("Connected to central: ");
      // print the central's BT address:
      Serial.println(central.address());
      // turn on the LED to indicate the connection:
      digitalWrite(LED_BUILTIN, HIGH);

      // check the battery level every 200ms
      // while the central is connected:
      while (central.connected()) {
        long currentMillis = millis();
        // if 200ms have passed, check the battery level:
        if (currentMillis - previousMillis >= 200) {
          previousMillis = currentMillis;
          updateBatteryLevel();
        }
      }
      // when the central disconnects, turn off the LED:
      digitalWrite(LED_BUILTIN, LOW);
      Serial.print("Disconnected from central: ");
      Serial.println(central.address());
    }
  }
}

void updateBatteryLevel() {
  /* Read the current voltage level on the A0 analog input pin.
     This is used here to simulate the charge level of a battery.
  */
  int battery = analogRead(A0); // this is test dcode for Bluetooth connectivity. A0 conflicts with the RMS voltage input
  int batteryLevel = map(battery, 0, 1023, 0, 100);

  if (batteryLevel != oldBatteryLevel) {       // if the battery level has changed
    Serial.print("Battery Level % is now: ");  // print it
    Serial.println(batteryLevel);
    batteryLevelChar.writeValue(batteryLevel);  // and update the battery level characteristic
    oldBatteryLevel = batteryLevel;             // save the level for next comparison
  }
}


I know I'm not the greatest programmer in the world and there are many inefficiencies in my code, as well as some routines in the wrong places (loops) but these programs both worked and compiled properly, and now they won't.

I am now dead in the water. Please, any help is appreciated!
Kind regards,
Mike

A byte can contain the values 0..255. Change that line to

`const uint16_t numChars = 256;`

That should also change to an uint16_t.


Any chance that you're compiling for an ESP32 based board? Did you change the settings for the warning level under file → preferences?

I haven't studied everything you posted, but that jumped out. The largest byte value is 255.
[Edit: Duplicate of what was said above. It wasn't there when I started writing this.]

Building for ESP32. I tried this, because I wasn't certain what the behaviour would be:

const byte x = 256;
int y[x];
void setup(){
  Serial.begin(115200);
  Serial.println("x="+String(x));
  Serial.println("sizeof(y)="+String(sizeof(y)));
}

Trying to set a byte to 256 causes a warning:

deleteme2.ino:1:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]

I didn't get a warning for defining an array with 0 elements. I expected that to be at least a warning, if not an error. It's not something I've tried doing before.
Serial output is:

x=0
sizeof(y)=0

sterretje,
Thanks for that info. I did make your suggested change the value to 255 ( i think the whole array is only 42 bytes anyway), and I also made the change to "static byte" line.

I know I did not make a change to my preferences, which are:

However, I didn't really notice that these messages are WARNINGS and not faults. I didn't realize that the compilation actually completed because previously there were no warnings or errors when I VERIFIED. So I never uploaded the code to the UNO R4 WiFi. I was afraid of corrupting the unit that was working and broadcasting MQTT messages as I build a dashboard for this project in node-red.

I cannot explain why I am seeing these warnings now (and misinterpreting them as failures). As I mentioned, I compiled these programs before without these warnings. I am receiving a new UNO R4 WiFi tomorrow and I will connect it, compile my code, upload it and see what happens.

I am getting another kind of data mismatch WARNING in line 539: "539:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (Serial1.available() >= sizeof(receivedData)) { // Serial1 is the 2nd Serial port on D0 and D1 of Uno"

I would like some guidance on getting these data types matched to eliminate that warning as well.

Dave_Lowther asked if I selected a different version board like ESP32. I have the same board and port definition Arduino UNO R4 WiFi which I selected from the selection pulldown, so I don't think that is a problem, but the UNO R4 WiFi. It does on a side note, use an ESP32 chipset, but none of that ever changed.

Thank you for your support,
Mike

.available() returns an int. sizeof() returns a size_t, which must be unsigned, based on the warning, but I can't find the type of size_t in the Arduino docs.
You can add a cast to sizeof() to convert it to int type to get rid of the warning.

Do you mean here?:

I was saying "I'm building the code for ESP32". I did that because I happened to have an ESP32 connected to my laptop.

The compiler configuration for ESP32 based boards (not your Uno R4 WiFi) can treat (certain?) warnings as errors. I think that that is the case when you set the Compiler Warnings to All as you have. But this only applies to ESP32 based boards.

Not the Arduino docs but size_t(3type) - Linux manual page

2 Likes

Thank you both for thinking of me and responding.
I found the data type for both elements by hovering over them in the code (its not in the manual, per se).
int is integer (of course), and
sizeof() returns unsigned integer.

I fixed it by defining the unsigned integer value to an integer value and I no longer get the WARNING!

See this:
int arraySize = sizeof(receivedData);
if (Serial1.available() >= arraySize) {

instead of:

if (Serial1.available() >= sizeof(receivedData)) {

Thank you for all your help. I am now WARNING and ERROR free on my compile.
I am so grateful to you and the Forum community.
Have a great weekend!
Mike

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.