Sensor Data is full when scripts combined?

Hello, I'm facing a strange error when i combine my scripts which both work absolutely fine individually when joined my sensor data is maxed out.

Dust Sensor on its own (correct)

Raw Signal Value (0-1023): 590.00 - Voltage: 1.90 - Dust Density: 0.22
Raw Signal Value (0-1023): 360.00 - Voltage: 1.16 - Dust Density: 0.10
Raw Signal Value (0-1023): 316.00 - Voltage: 1.02 - Dust Density: 0.07
Raw Signal Value (0-1023): 418.00 - Voltage: 1.35 - Dust Density: 0.13
Raw Signal Value (0-1023): 377.00 - Voltage: 1.21 - Dust Density: 0.11
Raw Signal Value (0-1023): 364.00 - Voltage: 1.17 - Dust Density: 0.10
Raw Signal Value (0-1023): 316.00 - Voltage: 1.02 - Dust Density: 0.07
Raw Signal Value (0-1023): 273.00 - Voltage: 0.88 - Dust Density: 0.05
Raw Signal Value (0-1023): 364.00 - Voltage: 1.17 - Dust Density: 0.10
Raw Signal Value (0-1023): 394.00 - Voltage: 1.27 - Dust Density: 0.12

Networking + Dust Sensor Script result (wrong)

httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200
httpRequestData: &voMeasured=4095.00&calcVoltage=13.20&dustDensity=2.14
HTTP Response code: 200

Dust Sensor Script

int measurePin = 26;
int ledPower = 27;
 
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
 
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
 
void setup(){
  Serial.begin(115200);
  pinMode(ledPower,OUTPUT);
}
 
void loop(){
  digitalWrite(ledPower,LOW); // power on the LED
  delayMicroseconds(samplingTime);
 
  voMeasured = analogRead(measurePin); // read the dust value
 
  delayMicroseconds(deltaTime);
  digitalWrite(ledPower,HIGH); // turn the LED off
  delayMicroseconds(sleepTime);
 
  // 0 - 3.3V mapped to 0 - 1023 integer values
  // recover voltage
  calcVoltage = voMeasured * (3.3 / 1024);
 
  // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
  // Chris Nafis (c) 2012
  dustDensity = 0.17 * calcVoltage - 0.1;
 
  Serial.print("Raw Signal Value (0-1023): ");
  Serial.print(voMeasured);
 
  Serial.print(" - Voltage: ");
  Serial.print(calcVoltage);
 
  Serial.print(" - Dust Density: ");
  Serial.println(dustDensity);
 
  delay(1000);
}

Scripts Joined

#ifdef ESP32
  #include <WiFi.h>
  #include <HTTPClient.h>
#else
  #include <ESP8266WiFi.h>
  #include <ESP8266HTTPClient.h>
  #include <WiFiClient.h>
#endif

#include <Wire.h>

int measurePin = 26;
int ledPower = 27;
 
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
 
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;

// Replace with your network credentials
const char* ssid     = "Lots of Security";
const char* password = "password";

// REPLACE with your Domain name and URL path or IP address with path
const char* serverName = "http://website.com/api";

void setup() {
  Serial.begin(115200);
  pinMode(ledPower,OUTPUT);
  
  WiFi.begin(ssid, password);
  Serial.println("Connecting");
  while(WiFi.status() != WL_CONNECTED) { 
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  //Check WiFi connection status
  if(WiFi.status()== WL_CONNECTED){
    HTTPClient http;
    
    // Your Domain name with URL path or IP address with path
    http.begin(serverName);
    
    // Specify content-type header
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");
    // Prepare your HTTP POST request data
      digitalWrite(ledPower,LOW); // power on the LED
  delayMicroseconds(samplingTime);
 
  voMeasured = analogRead(measurePin); // read the dust value
 
  delayMicroseconds(deltaTime);
  digitalWrite(ledPower,HIGH); // turn the LED off
  delayMicroseconds(sleepTime);
 
  // 0 - 3.3V mapped to 0 - 1023 integer values
  // recover voltage
  calcVoltage = voMeasured * (3.3 / 1024);
 
  // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
  // Chris Nafis (c) 2012
  dustDensity = 0.17 * calcVoltage - 0.1;
    String httpRequestData = "&voMeasured=" + String(voMeasured) + "&calcVoltage=" + calcVoltage + "&dustDensity=" + dustDensity;
    Serial.print("httpRequestData: ");
    Serial.println(httpRequestData);

    // Send HTTP POST request
    int httpResponseCode = http.POST(httpRequestData);
        
    if (httpResponseCode>0) {
      Serial.print("HTTP Response code: ");
      Serial.println(httpResponseCode);
    }
    else {
      Serial.print("Error code: ");
      Serial.println(httpResponseCode);
    }
    // Free resources
    http.end();
  }
  else {
    Serial.println("WiFi Disconnected");
  }
  //Send an HTTP POST request every 1 second
  delay(1000);  
}

I've broke this down and it seems to break as soon as i add this

 WiFi.begin(ssid, password);
  Serial.println("Connecting");
  while(WiFi.status() != WL_CONNECTED) { 
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());

Any ideas would be grateful!

tried a completely different way...

Dust Sensor working

/**
 * Example for using GP2Y1010AU0F Dust Sensor library
 * Created by Mickey Chan
 */

#include <GP2Y1010AU0F.h>

int measurePin = 26;   // Connect dust sensor analog measure pin to Arduino A0 pin
int ledPin     = 27;    // Connect dust sensor LED pin to Arduino pin 2

GP2Y1010AU0F dustSensor(ledPin, measurePin); // Construct dust sensor global object
float dustDensity = 0;

void setup() {
  Serial.begin(115200);
  Serial.println(F("GP2Y1010AU0F Dust Sensor Library Example"));

  dustSensor.begin();
}

void loop() {
  dustDensity = dustSensor.read();
  
  Serial.print("Dust Density = ");
  Serial.print(dustDensity);
  Serial.println(" ug/m3");

  delay(5000);
}

Dust sensor + networking broken

#ifdef ESP32
  #include <WiFi.h>
  #include <HTTPClient.h>
#else
  #include <ESP8266WiFi.h>
  #include <ESP8266HTTPClient.h>
  #include <WiFiClient.h>
#endif    

#include <Wire.h>

// Replace with your network credentials
const char* ssid     = "Lots of Security";
const char* password = "password";
const char* serverName = "http://website.com/api";

#include <GP2Y1010AU0F.h>

int measurePin = 26;   // Connect dust sensor analog measure pin to Arduino A0 pin
int ledPin     = 27;    // Connect dust sensor LED pin to Arduino pin 2

GP2Y1010AU0F dustSensor(ledPin, measurePin); // Construct dust sensor global object
float dustDensity = 0;

void setup() {
  Serial.begin(115200);
  Serial.println(F("GP2Y1010AU0F Dust Sensor Library Example"));
  WiFi.begin(ssid, password);
  Serial.println("Connecting");
  while(WiFi.status() != WL_CONNECTED) { 
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());

  dustSensor.begin();
}

void loop() {
  if(WiFi.status()== WL_CONNECTED){
    HTTPClient http;
    
    // Your Domain name with URL path or IP address with path
    http.begin(serverName);
    
    // Specify content-type header
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");
    // Prepare your HTTP POST request data
  
  dustDensity = dustSensor.read();

  String httpRequestData = "dustDensity=";
    Serial.print("httpRequestData: ");
    Serial.println(httpRequestData);

  
    Serial.print("Dust Density = ");
    Serial.print(dustDensity);
    Serial.println(" ug/m3");

    // Send HTTP POST request
    int httpResponseCode = http.POST(httpRequestData);
        
    if (httpResponseCode>0) {
      Serial.print("HTTP Response code: ");
      Serial.println(httpResponseCode);
    }
    else {
      Serial.print("Error code: ");
      Serial.println(httpResponseCode);
    }
    // Free resources
    http.end();
  }
  else {
    Serial.println("WiFi Disconnected");
  }
  //Send an HTTP POST request every 30 seconds
  delay(1000);  
}

same result...

Dust Density = 3299.17 ug/m3
HTTP Response code: 500
httpRequestData: dustDensity=
Dust Density = 3299.17 ug/m3
HTTP Response code: 500
httpRequestData: dustDensity=
Dust Density = 3299.17 ug/m3
HTTP Response code: 500
httpRequestData: dustDensity=
Dust Density = 3299.17 ug/m3
HTTP Response code: 500
httpRequestData: dustDensity=
Dust Density = 3299.17 ug/m3
HTTP Response code: 500

The 500 response code was expected, it's the 3299.17 ug/m3 that's the problem.

It's like no matter what dust sensor script/library i use which all work fine on their own once the networking and sending it to my website comes into play it just breaks...

Do you have a pin conflict? Can you run the dust sensor on different pins?