ESP8266 Thing programmed with Arduino IDE not sending Dweet

New here with a programming question. I’ve searched the web and this forum for Arduino/dweet.io examples. I have not found a solution yet and that brings me here hoping for help.

I have the following code taken from other devices I have collecting sensor data. I have it working, with different sensor packages, on an Uno, a Mega, and 2 Photons. I moved it over to a ESP8266 Thing where it collects sensor data from a MPL3115A2 and a water detector. It then sends it to ThingSpeak every 5 minutes. I added the code for sending a dweet, which was borrowed for other working deployments. The code will compile and upload without problems. It will run and update ThingSpeak every 5 minutes as scheduled. It does not feed the data to dweet.io. Qriginal code was based on GET and I also tried using POST without success. I do not have any serial output as I will have to modify the board to enable that function. I’m not sure if I’m missing any INCLUDES such as http. Any help will be appreciated.

#include <ESP8266WiFi.h>
#include <Wire.h>
#include "SparkFunMPL3115A2.h"
#include "ThingSpeak.h"

// WiFi and Channel parameters
const char WIFI_SSID[] = "########";
const char WIFI_PSK[] = "########";
unsigned long CHANNEL_ID = ######;
const char * WRITE_API_KEY = "########";
#define thing_name  "pvzSumpThing"
char SERVER[] = "www.dweet.io";

// Pin definitions
#define waterSensorPin  A0
#define LED_PIN         5

unsigned long previousMillis = 0;
const long interval = 299930;      // read interval(milliseconds)adjusted for drift; 300000ms=5 min
const String sketchVer = "ESP8266 ThingSpeak EM v3.2 (2018-08-07)";

WiFiClient client;

MPL3115A2 myPressure;
float pressure = 0;
float temperature = 0;
float baroin = 0;
float sumpRaw = 0;
String pres;
String temp;
String baro;
String sump;

void setup() {

  pinMode(waterSensorPin, INPUT);    // Analog pin setup for read
  pinMode(LED_PIN, OUTPUT);         // LED pin as output.

  Wire.begin();        // Join i2c bus
  myPressure.begin(); // Get sensor online
  // MPL3115A2 Settings
  myPressure.setModeBarometer(); // Measure pressure in Pascals from 20 to 110 kPa
  myPressure.setOversampleRate(7); // Set Oversample to the recommended 128
  myPressure.enableEventFlags(); // Enable all three pressure and temp event flags

  connectWiFi();

  ThingSpeak.begin(client);
}

void loop() {

  sensorCalc();

  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = currentMillis;
    digitalWrite(LED_PIN, HIGH);
    delay(250);
    digitalWrite(LED_PIN, LOW);
    digitalWrite(LED_PIN, HIGH);
    thingspeak();
    sendDweet();
    digitalWrite(LED_PIN, LOW);
  }

  digitalWrite(LED_PIN, HIGH);
  delay(100);
  digitalWrite(LED_PIN, LOW);
  delay(900);

}
//---------------------------------------------------------------
void connectWiFi() {

  byte led_status = 0;

  WiFi.mode(WIFI_STA);

  WiFi.begin(WIFI_SSID, WIFI_PSK);

  while ( WiFi.status() != WL_CONNECTED ) {
    digitalWrite(LED_PIN, led_status);
    led_status ^= 0x01;
    delay(100);
  }

  digitalWrite(LED_PIN, HIGH);
}
//---------------------------------------------------------------
void sensorCalc() {

  pressure = myPressure.readPressure();
  temperature = myPressure.readTempF();

  sumpRaw = analogRead(waterSensorPin);   // Read the water sensor channel, ADC
  if (sumpRaw <= 100) {
    sump = "Sump Empty";
  }
  else if (sumpRaw > 100) {
    sump = "Sump Water Detected";
  }

  const int station_elevation_m = 247; //Accurate for 14 Alcott
  pressure /= 100; //pressure is now in millibars

  float part1 = pressure - 0.3; //Part 1 of formula

  const float part2 = 8.42288 / 100000.0;
  float part3 = pow((pressure - 0.3), 0.190284);
  float part4 = (float)station_elevation_m / part3;
  float part5 = (1.0 + (part2 * part4));
  float part6 = pow(part5, (1.0 / 0.190284));
  float altimeter_setting_pressure_mb = part1 * part6; //Output is now in adjusted millibars
  baroin = altimeter_setting_pressure_mb * 0.02953;
}
//---------------------------------------------------------------
void thingspeak() {

  pres = String(round(pressure * 100.00) / 100.00);
  temp = String(round(temperature * 100) / 100.00);
  baro = String(round(baroin * 100) / 100.00);

  ThingSpeak.setField(1, temp);
  ThingSpeak.setField(2, pres);
  ThingSpeak.setField(3, sumpRaw);
  ThingSpeak.setField(4, baro);
  ThingSpeak.writeFields(CHANNEL_ID, WRITE_API_KEY);
}
//---------------------------------------------------------------
void sendDweet() {

  client.stop();

  if (client.connect(SERVER, 80))
  {
    client.print(F("GET /dweet/for/"));
    client.print(thing_name);
    client.print(F("?Pressure="));
    client.print(pres);
    client.print(F("&Temperature="));
    client.print(temp);
    client.print(F("&Barometer="));
    client.print(baro);
    client.print(F("&Sump="));
    client.print(sumpRaw);
    client.print(F("&Status="));
    client.print(sump);
    client.println(F("HTTP/1.1"));
    client.println(F("Host: dweet.io"));
    client.println(F("Connection: close"));
    client.println(F(""));
  } else {
    delay(3000);
  }
}

The code will compile and upload without problems.
...
I'm not sure if I'm missing any INCLUDES such as http.

You can be quite sure that if the code compiles, you are not missing any #includes

AWOL:
You can be quite sure that if the code compiles, you are not missing any #includes

Thanks for reminding me of that. I'll shift my focus away from the libraries.

A couple decent tutorials:

https://openhomeautomation.net/cloud-temperature-logger-esp8266/

mpeddi:
A couple decent tutorials:

https://openhomeautomation.net/cloud-temperature-logger-esp8266/
https://www.hackster.io/TechGuru/esp8266-geolocation-dweet-io-freeboard-io-google-api-334969

mpeddi, thanks. I took a look. It made me realize that I might be attempting to post variables (temp, pres, baro) within sendDweet() that were created within the thingspeak() function. I instead called directly on the variables created in sensorCalc() with no effect.

void thingspeak(){
  
  pres = String(round(pressure*100.00)/100.00);
  temp = String(round(temperature*100)/100.00);
  baro = String(round(baroin*100)/100.00);

void sensorCalc() {

  pressure = myPressure.readPressure();
  temperature = myPressure.readTempF();
  
  sumpRaw = analogRead(waterSensorPin);   // Read the water sensor channel, ADC
    if (sumpRaw<=100){ 
      sump = "Sump Empty"; 
    }
    else if (sumpRaw>100){ 
      sump = "Sump Water Detected"; 
    }

The code will run constantly without hesitation, updating ThingSpeak while skipping the dweet. The issue may lie in the connection to the server not occurring for some reason.

Thanks again.