Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client not connecting to server #1

Open
wjflier2 opened this issue Apr 15, 2023 · 13 comments
Open

Client not connecting to server #1

wjflier2 opened this issue Apr 15, 2023 · 13 comments

Comments

@wjflier2
Copy link

Great idea but having issues.

Error message 'HTTPClient::begin' declared with attribute error: obsolete API, use ::begin(WiFiClient, url)
Changed code to:
// Declare object of class HTTPClient
HTTPClient http;
WiFiClient client;

// Setup the destination and content type
http.begin(client, "http://"+server+"/reading");
http.addHeader("Content-Type", "application/x-www-form-urlencoded");

no error, server and client both run, but no connection.

@goldbattle
Copy link
Owner

I assume you are using the v1 version of this code?
I no longer use this so can't help debug anything.

Maybe the libraries have updated since I used them.
Here is what I have on my machine:

  • DHTesp - 1.0.11
  • ESPAsyncTCP - 1.2.0
  • ESP Async WebServer - 1.2.0

It looks like you might need to define a WiFiClient now, see this link:
https://stackoverflow.com/a/67702894/7718197

@goldbattle
Copy link
Owner

Oh, I didn't fully read what you said, sorry about that. I see you fixed the problem.

Maybe you can check Serial.println("http response: "+httpCode); to see if there is any connection there.
Are you able to view each devices' web interface?

@wjflier2
Copy link
Author

Yes both web interfaces show, but the server doesn't update. header displays "ERROR: have not got any sensor readings from device office.
ERROR: last reading was from 19 hrs, 11 min, 18 sec ago.
ERROR: the system will be turned off till we get a new reading.

@wjflier2
Copy link
Author

"thermostat.local.lan" doesn't bring up anythin, I use the server ip

@wjflier2
Copy link
Author

I don't get where these connect, all I've read use AP to connect. What am I missing?

@goldbattle
Copy link
Owner

goldbattle commented Apr 19, 2023 via email

@wjflier2
Copy link
Author

yes

@wjflier2
Copy link
Author

both client and server post on their respective web pages but don't seem to talk to each other

@goldbattle
Copy link
Owner

Are you able to ping each client yourself? Otherwise, I am not sure.

@wjflier2
Copy link
Author

Yes, they ping, but I don't see where the server request data from the client, or the client broadcast to the server

@wjflier2
Copy link
Author

wjflier2 commented Apr 20, 2023

Not sure if this is an issue, but I noticed this part of the code doesn't work:
// Connect to Wi-Fi with our static ip
WiFi.config(staticIP, subnet, gateway, dns);
WiFi.begin(ssid, password);
Serial.println("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println(".");

does by changing subnet to (255, 255, 0, 0) but then the server web page doesn't load

@wjflier2
Copy link
Author

wjflier2 commented Apr 20, 2023

looks like something with dns
here's what I'm getting now till I reset
current temp of 0.00 < 75
current humidity is 0.00 %
no need to turn on cooling
user has forced fan to be on.

@wjflier2
Copy link
Author

Just wanted to say thanks for your responses. I'll figure it out, good brain exercise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants