How to read a text file from an internal address using HTTP

Hello,

I am trying to read an text from an device on my internal network using HTTP commands.
But I am not very successfull.
If I try the example then it works well connecting to an external site.

The internal address is: 192.168.50.62/e and that shoeld give me an text string like:
[{“tm”:1737639811,“net”: 5377.441,“pwr”: 1340,“ts0”:1737639800,“cs0”: 22629.227,“ps0”: 185,“p1”: 10382.647,“p2”: 9905.192,“n1”: 4594.387,“n2”: 10316.011,“gas”: 8899.993,“gts”:2501231440,“wtr”: 0.000,“wts”:0}]
This is my internal power monitor.

But whatever I do I do not get an connection en get status code 404.
The wifi connection is OK because it is reading the actual NTP data.

Is there an example code what I shoud use?

In my old system with an ESP8266 I used:

WiFiClient client;
HTTPClient http; //Object of class HTTPClient
http.begin(client,“http://192.168.50.62/e”);
int httpCode = http.GET();
Serial.println(httpCode);

But the new system is using other commands.
Please help.

Hi @wspronk,

https://www.amebaiot.com/en/amebad-arduino-web-client-http/

Can you try to call the setBlockingMode() API for the WifiClient?

For instance, client.setBlockingMode();

Thank you.

Hello Kelvin,

I tried your idea but get the responce:

Compilation error: ‘class WiFiClient’ has no member named ‘setBlockingMode’

Also your mail regarding HTTP examples did not help because this is for the AMB82-mini and I work with the BW16(RTL8720DN).

Therefore any help would still be very usefull.

Thanks…

Hi @wspronk ,

May I know which version of SDK are you using? Kindly update to the latest version to avoid compilation error for setBlockingMode() method.
This HTTP example is an example from AmebaD SDK and I have tried it on BW16 to connect to an internal site.
https://www.amebaiot.com/en/amebad-arduino-web-client-http/

Hope it helps.

Thanks.

Hello KelvinKL,

I checked the verion of SDK that I use and that is :

Realtec Ameba Boards(32 bits ARM Cortex-M33 @200MHz) Version 3.1.7 and that seems to be the newest version.

I tried this example and it connects to the external site but I do not get the connection to my internal site working.

I used:
const char kHostname = “192.168.50.62”;
const char kPath = “/e”;
And I used:
const char kHostname = “192.168.50.62/e”;
const char kPath = “/”;

But I do get:
[INFO]server_drv.cpp: start_client
[INFO] Create socket successfully
[INFO] Connect to Server successfully!
startedRequest ok
Got status code: 404
Content length is: 0

I hope this info helps you to see where I do go wrong…
Thanks for your help…
Willy Spronk.

Hi @wspronk ,

Thanks for the info provided. You may want to update to the latest pre release version of 3.1.8-build20241128, kindly paste this link https://github.com/Ameba-AIoT/ameba-arduino-d/raw/dev/Arduino_package/package_realtek_amebad_early_index.json in your Arduino IDE preferences. Please try the Simple HTTP example again with the latest pre release version SDK. Remember to change the kHostname to your IP address and kindly add c.setBlockingMode() after creating WiFiClient c object.

Thank you.

Hi Kelvin,

I succesfully updated the software version to 3.1.8 and now c.setBlockingMode() is recocnised.

But the resonce is still 404.

This is the responce that I get:

Interface 0 IP address : 192.168.50.50Connected to wifi
SSID: ASUS_5G-1
IP Address: 192.168.50.50
signal strength (RSSI):-75 dBm

[INFO] Create socket successfully

[INFO] Connect to Server successfully!

startedRequest ok
Got status code: 404
err updated0
Content length is: 0

Body returned follows:

404 Niet Gevonden

Therefore still no succes.
Regards,

Willy Spronk.

Hi @wspronk ,

Looks like the connection was successful. Do you mind to verify the http server response by connecting to it using a web browser?

I was able to connect to an internal web server using BW16

Thank you.

Hi Kelvin,
When I use a web browser i do send the command:

http://192.168.50.62/e

The return message is then:

[{“tm”:1738056705,“net”: 5505.248,“pwr”:-519,“ts0”:1738056705,“cs0”: 22640.953,“ps0”: 870,“p1”: 10477.993,“p2”: 9939.732,“n1”: 4595.062,“n2”: 10317.415,“gas”: 8907.674,“gts”:2501281030,“wtr”: 0.000,“wts”:0}]

This I use every day to get the actual data from my power usage.

In my old system with an ESP8266 this was working but I had always internet connection problems and therefore I was planning to upgrade with the BW16 to get a better internet connection with 5G.

Is it possible that the extension /e is the problem?
That is not a path but a command to get the right information.
There are more extensions possible like /d or /a.

But what you send me is very simular then what I do expect.
Maybe you could send me the commands that you use to get this responce?

Thanks,
Willy Spronk.

Hi @wspronk ,

Apologize for the delay. I tried to replicate your setup here using BW16 as HTTP client and AMB82 mini as HTTP server. I managed to get the response from the server using endpoint “/e”. The connections were all done within internal network. Please find the Arduino example code below for reference,

Client side (BW16)

#include <HttpClient.h>
#include <WiFi.h>
#include <WiFiClient.h>

// This example downloads the URL "http://www.amebaiot.com"
char ssid[] = "AP084_5G";       // your network SSID (name)
char pass[] = "123456789";           // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;                   // your network key Index number (needed only for WEP)

// Name of the server we want to connect to
const char kHostname[] = "192.168.84.28";

const char kPath[] = "/e";
// Number of milliseconds to wait without receiving any data before we give up
const int kNetworkTimeout = 30 * 1000;
// Number of milliseconds to wait if no data is available before trying again
const int kNetworkDelay = 1000;
int status = WL_IDLE_STATUS;

void setup() {
    Serial.begin(115200);
    while (status != WL_CONNECTED) {
        Serial.print("Attempting to connect to SSID: ");
        Serial.println(ssid);
        status = WiFi.begin(ssid, pass);
        // wait 10 seconds for connection:
        delay(10000);
    }
    Serial.println("Connected to wifi");
    printWifiStatus();
}

void loop() {
    int err = 0;

    WiFiClient c;
    c.setBlockingMode();
    HttpClient http(c);

    err = http.get(kHostname, kPath);
    if (err == 0) {
        Serial.println("startedRequest ok");

        err = http.responseStatusCode();
        if (err >= 0) {
            Serial.print("Got status code: ");
            Serial.println(err);

            // Usually you'd check that the response code is 200 or a
            // similar "success" code (200-299) before carrying on,
            // but we'll print out whatever response we get
            err = http.skipResponseHeaders();
            Serial.print("err updated");
            Serial.println(err);

            if (err >= 0) {
                int bodyLen = http.contentLength();
                Serial.print("Content length is: ");
                Serial.println(bodyLen);
                Serial.println();
                Serial.println("Body returned follows:");

                // Now we've got to the body, so we can print it out
                unsigned long timeoutStart = millis();
                char c;
                // Whilst we haven't timed out & haven't reached the end of the body
                while ((http.connected() || http.available()) && ((millis() - timeoutStart) < kNetworkTimeout)) {
                    if (http.available()) {
                        c = http.read();
                        // Print out this character
                        Serial.print(c);
                        bodyLen--;
                        // We read something, reset the timeout counter
                        timeoutStart = millis();
                    } else {
                        // We haven't got any data, so let's pause to allow some to arrive
                        delay(kNetworkDelay);
                    }
                }
            } else {
                Serial.print("Failed to skip response headers: ");
                Serial.println(err);
            }
        } else {
            Serial.print("Getting response failed: ");
            Serial.println(err);
        }
    } else {
        Serial.print("Connect failed: ");
        Serial.println(err);
    }
    http.stop();

    // And just stop, now that we've tried a download
    while (1);
}

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

    // print your WiFi 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");
}

Server side (AMB82-mini):

#include <WiFi.h>

char ssid[] = "AP084_5G";    // your network SSID (name)
char pass[] = "123456789";        // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;                // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;     // Indicator of Wifi status

WiFiServer server(80);

void setup()
{
    Serial.begin(115200);        // initialize serial communication

    // attempt to connect to Wifi network:
    while (status != WL_CONNECTED) {
        Serial.print("Attempting to connect to Network named: ");
        Serial.println(ssid);    // print the network name (SSID);

        // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
        status = WiFi.begin(ssid, pass);
        // wait 10 seconds for connection:
        delay(10000);
    }
    server.begin();       // start the web server on port 80
    printWifiStatus();    // you're connected now, so print out the status
}


void loop()
{
    WiFiClient client = server.available();    // listen for incoming clients

    if (client) {                          // if you get a client,
        Serial.println("new client");      // print a message out the serial port
        String currentLine = "";           // make a String to hold incoming data from the client
        while (client.connected()) {       // loop while the client's connected
            if (client.available()) {      // if there's bytes to read from the client,
                char c = client.read();    // read a byte, then
                Serial.write(c);           // print it out the serial monitor
                if (c != '\r') {           
                    currentLine += c; 
                }
                if (currentLine.endsWith("GET /index")) {
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-type:text/html");
                    client.println();

                    // the content of the HTTP response follows the header:
                    client.print("Click <a href=\"/e\">here</a> to get sensor reading EEE<br>");
                    client.print("Click <a href=\"/a\">here</a> to get sensor reading AAA<br>");

                    // The HTTP response ends with another blank line:
                    client.println();
                    currentLine = "";                  
                }
                // Check to see if the client request was "GET /e" or "GET /a":
                if (currentLine.endsWith("GET /e")) {
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-type:text/html");
                    client.println();
                    client.print("[{\"tm\":1738056705,\"net\": 5505.248,\"pwr\":-519,\"ts0\":1738056705,\"cs0\": 22640.953,\"ps0\": 870,\"p1\": 10477.993,\"p2\": 9939.732,\"n1\": 4595.062,\"n2\": 10317.415,\"gas\": 8907.674,\"gts\":2501281030,\"wtr\": 0.000,\"wts\":0}]");
                    client.println();
                    currentLine = "";
                }
                if (currentLine.endsWith("GET /a")) {
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-type:text/html");
                    client.println();
                    client.print("[{\"tm\":1111111111,\"net\": 22222222,\"pwr\":333333333,\"ts0\":4444444444,\"cs0\": 555555555555}]");
                    client.println();
                    currentLine = "";
                }
            }
        }
        // close the connection:
        client.stop();
        Serial.println("client disconnected");
    }
}

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

    // print your WiFi 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");
    // print where to go in a browser:
    Serial.print("To see this page in action, open a browser to http://");
    Serial.println(ip);
}

Thank you.

Hello Kevin,

Many thanks for your support…
But still no succes with your code.
I used your code 1 to 1 and only changed the IP adres and the Wifi settings.

The only thing I notished is that I do get some warnings during uploading.

This is what I get:

C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In constructor ‘WiFiClient::WiFiClient(uint8_t, tPortMode)’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:51:15: warning: comparison is always true due to limited range of data type [-Wtype-limits]
if ((sock >= 0) && (sock != 0xFF)) {
~~~^~
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In constructor ‘WiFiClient::WiFiClient(uint8_t, tPortMode, tBlockingMode)’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:61:15: warning: comparison is always true due to limited range of data type [-Wtype-limits]
if ((sock >= 0) && (sock != 0xFF)) {
~~~^~
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In member function ‘virtual uint8_t WiFiClient::connected()’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:76:16: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if ((_sock < 0) || (_sock == 0xFF)) {
~~~~^
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In member function ‘virtual int WiFiClient::available()’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:91:33: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (!_is_connected || _sock < 0) {
~~~~^
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In member function ‘virtual void WiFiClient::stop()’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:167:15: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (_sock < 0) {
~~~~^
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In member function ‘virtual size_t WiFiClient::write(const uint8_t*, size_t)’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:193:15: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (_sock < 0) {
~~~~^
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In member function ‘virtual WiFiClient::operator bool()’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:212:18: warning: comparison is always true due to limited range of data type [-Wtype-limits]
return _sock >= 0;
~~~~^~
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In member function ‘virtual int WiFiClient::connect(const char*, uint16_t)’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:232:19: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (_sock < 0) {
~~~~^
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In member function ‘virtual int WiFiClient::connect(IPAddress, uint16_t)’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:249:15: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (_sock < 0) {
~~~~^
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp: In member function ‘virtual int WiFiClient::connectv6(IPv6Address, uint16_t)’:
C:\Users\wspro\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.8-build20241128\libraries\WiFi\src\WiFiClient.cpp:264:15: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (_sock < 0) {
~~~~^
Sketch uses 721660 bytes (34%) of program storage space. Maximum is 2097152 bytes.

Please enter the upload mode manually(wait 5s)
05
04
03
02
01
Uploading…
Upload Image done.
All images are sent successfully!

And after running the code it still gives error 404.

If this does not ring a bel then I do not know how to proceed and maybe I have to go back to my ESP8266 and need to upgrade my Wifi system.

Again many thanks…

Willy Spronk.

Hi @wspronk ,

I don’t think the warnings would matter, as I have them on my side too.

Do you mind trying another http.get() API instead? Please find the example code below, I have replaced the kHostname[] with an IP address constructor and and http.get(kHostname, kPath) with http.get(ipAddr, NULL, “/e”, NULL);.

Client side:

#include <HttpClient.h>
#include <WiFi.h>
#include <WiFiClient.h>

// This example downloads the URL "http://www.amebaiot.com"
char ssid[] = "AP084_5G";       // your network SSID (name)
char pass[] = "123456789";           // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;                   // your network key Index number (needed only for WEP)

// Name of the server we want to connect to
// const char kHostname[ ] = "192.168.84.28";
IPAddress ipAddr = IPAddress(192,168,84,28);

const char kPath[] = "/e";
// Number of milliseconds to wait without receiving any data before we give up
const int kNetworkTimeout = 30 * 1000;
// Number of milliseconds to wait if no data is available before trying again
const int kNetworkDelay = 1000;
int status = WL_IDLE_STATUS;

void setup() {
    Serial.begin(115200);
    while (status != WL_CONNECTED) {
        Serial.print("Attempting to connect to SSID: ");
        Serial.println(ssid);
        status = WiFi.begin(ssid, pass);
        // wait 10 seconds for connection:
        delay(10000);
    }
    Serial.println("Connected to wifi");
    printWifiStatus();
}

void loop() {
    int err = 0;

    WiFiClient c;
    c.setBlockingMode();
    HttpClient http(c);

    // err = http.get(kHostname, kPath);
    err = http.get(ipAddr, NULL, "/e", NULL);
    if (err == 0) {
        Serial.println("startedRequest ok");

        err = http.responseStatusCode();
        if (err >= 0) {
            Serial.print("Got status code: ");
            Serial.println(err);

            // Usually you'd check that the response code is 200 or a
            // similar "success" code (200-299) before carrying on,
            // but we'll print out whatever response we get
            err = http.skipResponseHeaders();
            Serial.print("err updated");
            Serial.println(err);

            if (err >= 0) {
                int bodyLen = http.contentLength();
                Serial.print("Content length is: ");
                Serial.println(bodyLen);
                Serial.println();
                Serial.println("Body returned follows:");

                // Now we've got to the body, so we can print it out
                unsigned long timeoutStart = millis();
                char c;
                // Whilst we haven't timed out & haven't reached the end of the body
                while ((http.connected() || http.available()) && ((millis() - timeoutStart) < kNetworkTimeout)) {
                    if (http.available()) {
                        c = http.read();
                        // Print out this character
                        Serial.print(c);
                        bodyLen--;
                        // We read something, reset the timeout counter
                        timeoutStart = millis();
                    } else {
                        // We haven't got any data, so let's pause to allow some to arrive
                        delay(kNetworkDelay);
                    }
                }
            } else {
                Serial.print("Failed to skip response headers: ");
                Serial.println(err);
            }
        } else {
            Serial.print("Getting response failed: ");
            Serial.println(err);
        }
    } else {
        Serial.print("Connect failed: ");
        Serial.println(err);
    }
    http.stop();

    // And just stop, now that we've tried a download
    while (1);
}

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

    // print your WiFi 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");
}

You may refer to ameba-arduino-d/Arduino_package/hardware/libraries/Http/src/HttpClient.h at dev · Ameba-AIoT/ameba-arduino-d · GitHub for more details about HTTP Client APIs.

Thank you.

Hello Kevin,

I did try your suggestion and no succes…

Therefore I did try more suggetions that you did send me in the link and added the httpPort = 8080 but I do not know if this port is correct. But the responce did change.

Below find three tests with the responce added.

I hope to not overload you with my data but maybe this is usefull.

Many thanks,

Willy spronk.

Test with your code:

IPAddress ipAddr = IPAddress(192,168,50,62);

WiFiClient c;
c.setBlockingMode();
HttpClient http(c);

String httpServer = "192.168.50.62";
String http_request = "e";
uint16_t httpPort = 8080;


err = http.get(ipAddr, NULL, "/e", NULL);

if (err == 0) {
    Serial.println("startedRequest ok");

Responce:

Attempting to connect to SSID: ASUS_5G-1
interface 0 is initialized

interface 1 is initialized

Initializing WIFI …

WIFI initialized

RTL8721D[Driver]: set ssid [ASUS_5G-1]

RTL8721D[Driver]: rtw_set_wpa_ie[1160]: AuthKeyMgmt = 0x2

RTL8721D[Driver]: rtw_restruct_sec_ie[4279]: no pmksa cached

RTL8721D[Driver]: start auth to 08:bf:b8:25:fa:74

RTL8721D[Driver]: auth alg = 2

RTL8721D[Driver]:

OnAuthClient:algthm = 0, seq = 2, status = 0, sae_msg_len = 11

RTL8721D[Driver]: auth success, start assoc

RTL8721D[Driver]: association success(res=25)

RTL8721D[Driver]: ClientSendEAPOL[1650]: no use cache pmksa

RTL8721D[Driver]: set pairwise key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4)

RTL8721D[Driver]: set group key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4) keyid:2

Interface 0 IP address : 192.168.50.50Connected to wifi
SSID: ASUS_5G-1
IP Address: 192.168.50.50
signal strength (RSSI):-60 dBm

[INFO] Create socket successfully

[INFO] Connect to Server successfully!

startedRequest ok
Got status code: 404
err updated0
Content length is: 0

Body returned follows:

404 Niet Gevonden

Test 2:

WiFiClient c;
c.setBlockingMode();
HttpClient http(c);

String httpServer = "192.168.50.62";
String http_request = "e";
uint16_t httpPort = 8080;


err = http.get(httpServer.c_str(), httpPort, (http_request).c_str());
if (err == 0) {
    Serial.println("startedRequest ok");

Responce:

RTL8721D[Driver]: set ssid [ASUS_5G-1]

RTL8721D[Driver]: rtw_set_wpa_ie[1160]: AuthKeyMgmt = 0x2

RTL8721D[Driver]: rtw_restruct_sec_ie[4279]: no pmksa cached

RTL8721D[Driver]: start auth to 08:bf:b8:25:fa:74

RTL8721D[Driver]: auth alg = 2

RTL8721D[Driver]:

OnAuthClient:algthm = 0, seq = 2, status = 0, sae_msg_len = 11

RTL8721D[Driver]: auth success, start assoc

RTL8721D[Driver]: association success(res=26)

RTL8721D[Driver]: ClientSendEAPOL[1650]: no use cache pmksa

RTL8721D[Driver]: set pairwise key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4)

RTL8721D[Driver]: set group key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4) keyid:2

Interface 0 IP address : 192.168.50.50Connected to wifi
SSID: ASUS_5G-1
IP Address: 192.168.50.50
signal strength (RSSI):-60 dBm

[INFO] Create socket successfully

[ERROR] Connect to server failed

[INFO] [ard_socket.c][send_data] err = 1043507392

[INFO] [ard_socket.c][send_data] err = 1043507392

[INFO] [ard_socket.c][send_data] err = 1043507392

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 234885265

[INFO] [ard_socket.c][send_data] err = 234885265

[INFO] [ard_socket.c][send_data] err = 234885265

[INFO] [ard_socket.c][send_data] err = 255

[INFO] [ard_socket.c][send_data] err = 56

[INFO] [ard_socket.c][send_data] err = 268679524

[INFO] [ard_socket.c][send_data] err = 268679524

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 268679524

[INFO] [ard_socket.c][send_data] err = 268679524

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 2

startedRequest ok
Getting response failed: -3

Test 3:

WiFiClient c;
c.setBlockingMode();
HttpClient http(c);

String httpServer = "192.168.50.62";
String http_request = "e";
uint16_t httpPort = 8080;

err = http.get(ipAddr, NULL, 8080, "/e", NULL);
if (err == 0) {
    Serial.println("startedRequest ok");

Responce:

Attempting to connect to SSID: ASUS_5G-1
interface 0 is initialized

interface 1 is initialized

Initializing WIFI …

WIFI initialized

RTL8721D[Driver]: set ssid [ASUS_5G-1]

RTL8721D[Driver]: rtw_set_wpa_ie[1160]: AuthKeyMgmt = 0x2

RTL8721D[Driver]: rtw_restruct_sec_ie[4279]: no pmksa cached

RTL8721D[Driver]: start auth to 08:bf:b8:25:fa:74

RTL8721D[Driver]: auth alg = 2

RTL8721D[Driver]:

OnAuthClient:algthm = 0, seq = 2, status = 0, sae_msg_len = 11

RTL8721D[Driver]: auth success, start assoc

RTL8721D[Driver]: association success(res=31)

RTL8721D[Driver]: ClientSendEAPOL[1650]: no use cache pmksa

RTL8721D[Driver]: set pairwise key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4)

RTL8721D[Driver]: set group key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4) keyid:2

Interface 0 IP address : 192.168.50.50Connected to wifi
SSID: ASUS_5G-1
IP Address: 192.168.50.50
signal strength (RSSI):-60 dBm

[INFO] Create socket successfully

[ERROR] Connect to server failed

[INFO] [ard_socket.c][send_data] err = 0

[INFO] [ard_socket.c][send_data] err = 0

[INFO] [ard_socket.c][send_data] err = 0

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 268679380

[INFO] [ard_socket.c][send_data] err = 268679380

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 268679380

[INFO] [ard_socket.c][send_data] err = 268679380

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 9

[INFO] [ard_socket.c][send_data] err = 2

startedRequest ok
Getting response failed: -3

Hi @wspronk ,

Thanks for trying out the different API variants. Based on the log you provided without using port 8080, the connection between BW16 and server was indeed successful, and you were able to receive the response message of 404. The reason of not getting the correct data could be due to firewall blocking issue over router or server. Please check if there is any firewall setup on your router or server, and try to disable them temporarily for testing.

Thank you.

Hi Kevin,

After another two day’s of trying various codes and changes in my wifi system I decided to stop with this project and went back to my old system with the ESP8266. Installed an extra wifi mesh router close to it and now all is working fine.
I will use the BW16 in another project because it proves itself by connecting to my wify system on places where the ESP8266 could not connect.
But reading my Youless energy monitor with the BW16 seems to be impossible.

Many thanks for you help and patience.
Best regards,

Willy Spronk.