#include "DHT.h"
#include "PMS.h"
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266HTTPClient.h>
#include <SoftwareSerial.h>
#define DHTPIN D1
#define DHTTYPE DHT11
SoftwareSerial pmsSerial(D4, D3);
const char *ssid = "";
const char *password = "";
const char *serverName = "http://192.168.0.35:5000/upload-data";
// String apiKeyValue = "tPmAT5Ab3j7F9";
String sensorName = "PMTL_Sensor1";
String sensorLocation = "55108";
String httpRequestData;
DHT dht(DHTPIN, DHTTYPE);
WiFiClient wifi;
PMS pms(pmsSerial);
PMS::DATA data;
void setup()
{
Serial.begin(9600);
pmsSerial.begin(9600);
dht.begin();
WiFi.enableInsecureWEP(true);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
Serial.println("Waiting");
delay(500);
}
Serial.println("Connected!!");
}
void loop() {
Serial.println("Output!!");
float h = dht.readHumidity();
float t = dht.readTemperature();
if (WiFi.status() == WL_CONNECTED) {
Serial.println("Output123!!");
if (pms.read(data)) {
HTTPClient http;
http.begin(wifi, serverName);
http.addHeader("Content-Type", "application/json");
String payload = "{";
payload += "\"SensorID\":\"" + sensorName + "\",";
payload += "\"location\":\"" + sensorLocation + "\",";
payload += "\"temp\":" + String(t) + ",";
payload += "\"humidity\":" + String(h) + ",";
payload += "\"pm10\":" + String(data.PM_AE_UG_1_0) + ",";
payload += "\"pm25\":" + String(data.PM_AE_UG_2_5) + ",";
payload += "\"pm100\":" + String(data.PM_AE_UG_10_0) + ",";
payload += "\"particles03\":" + String(data.P_03);
payload += "}";
int httpResponseCode = http.POST(payload);
Serial.println("HTTP Response code: " + String(httpResponseCode));
http.end();
}
}
}
The serial monitor is showing waiting on this code, what would be the issue here? the code compiles and uploads but the serial monitor shows waiting as the result