-->
Page 1 of 5

WifiClient connecting to webserver running on ESP8266

PostPosted: Wed Jan 13, 2016 10:39 am
by Dan Kiefer
Hello,

I created a simple webserver (AP mode) which allows me to switch an LED and to read temperature. It works fine when I connect to it from a browser.

Now I tried to connect to it from another ESP8266 using the WifiClient example. Here I am stuck. In the example, a sparkfun address is used as the host. If I replace the host address by the IP of my webserver (192.168.4.1), my WifiClient connects to the network, but the connection to the server fails (client.connect("192.168.4.1", 80) == false). My intention was to send the same string to the webserver that is also sent by the browser. Sorry if that sounds silly.

How can I 'customize the script to talk to other http servers' (as it is said in the WifiClient example)? Do I have to change the server part in order that it accepts such requests?

Thanks for any help!

Regards,
Dan

Re: WifiClient connecting to webserver running on ESP8266

PostPosted: Thu Jan 14, 2016 11:19 am
by Yahya Khaled
Hi Dan, I'm working on a small project which is to control my aircon via wifi.
So far I succeeded communicating with the indoor unit via Infra red and I happen to have ESP8266 in my draw.

Can you please share your code - it saves me time :)

If I get lucky I will be able to remove the Arduino completely.

Many thanks in advance.

Re: WifiClient connecting to webserver running on ESP8266

PostPosted: Thu Jan 14, 2016 4:37 pm
by Dan Kiefer
Hello Khaled,

as you can see from my original post, I am anything but an expert in ESP8266. All I did was adapting an existing project to my own needs. Please find the Arduino sketch file attached. It's most likely you may be able to remove the Arduino in your project.

The original code was found at: https://blog.thesen.eu/http-1-1-webserver-fuer-esp8266-als-accesspoint/

My thanks goes to Stefan Thesen for his excellent work. For all that is wrong in my modified code, the fault is mine alone.

Regards,
Dan

Re: WifiClient connecting to webserver running on ESP8266

PostPosted: Thu Jan 14, 2016 5:54 pm
by martinayotte
Beware that the Server can be set in mode AP or AP+STA, but the client needs to be in STA-only, otherwise the client will try to connect to itself, since both will have an IP set 192.168.4.1.