client.connect(website, 80) seems not working

This program worked fine for me but after a week, trying to check again, the program seems to stop at

//API service using WiFi Client through PushingBox then relayed to Google
if (client.connect(WEBSITE, 80)) {

I changed nothing (as far I can remember). Does anybody has an idea why the program is not passing this instruction?

Kind regards Peter

#include <WiFiNINA.h>
#include <DHT.h>
#include <ArduinoBLE.h>

DHT Stock = DHT(1,DHT11);

float humidityData;
float celData;

const char WEBSITE[] = "api.pushingbox.com"; //pushingbox API server
const String devid = "id"; //device ID on Pushingbox for our Scenario
char ssid[] = "said";          //  your network SSID (name) 
char pass[] = "pass";   // your network password
int status = WL_IDLE_STATUS;

void setup() {
  Serial.begin(9600);
  while (!Serial);
  
  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
    }

  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    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 10 seconds for connection:
    delay(10000);
    }

  Serial.println("You're connected to the network");  
  printWifiStatus();
  
  //DHTs initialisieren  
  Stock.begin(); 

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



void loop() {
  
  delay(2000);

  // Messung Stockklima
  humidityData = Stock.readHumidity();
  celData = Stock.readTemperature();

  // Wenn fehlerhafte Sensordaten Meldung ausgeben
  if (isnan(humidityData) || isnan(celData)) {
    Serial.println("Fehler Sensor Stock!");
    return;
    }

  // Ausgabe auf seriellen Monitor
  Serial.print("Stockklima:     ");
  Serial.print("Feuchte: ");
  Serial.print(humidityData);
  Serial.print("%  Temperatur: ");
  Serial.print(celData);
  Serial.println("°C");
  Serial.println("\nSending Data to Server..."); 

  // if you get a connection, report back via serial:
  WiFiClient client;  //Instantiate WiFi object, can scope from here or Globally

  
  //API service using WiFi Client through PushingBox then relayed to Google
  if (client.connect(WEBSITE, 80)) { 

    client.print("GET /pushingbox?devid=" + devid
    + "&humidityData=" + (String) humidityData
    + "&celData=" + (String) celData);

    // HTTP 1.1 provides a persistent connection, allowing batched requests
    // or pipelined to an output buffer
    client.println(" HTTP/1.1"); 
    client.print("Host: ");
    client.println(WEBSITE);
//    client.println("User-Agent: MKR1000/1.0");
    client.println();      
    Serial.println("\nData Sent"); 
    }

  }


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

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