ESP8266 successfully connects to computer wifi hotspot, but not home wifi

My ESP8266 sends a call to IFTTT when a switch completes. When I connect the ESP8266 to my computer's wifi hot spot (which is ethernet wired into the home router), the call is sent successfully. However, when I attempt to connect the ESP8266 to the home wifi connected to the same home router, the call is not successfully sent out. And, when I look at the router logs it does show the registered MAC address of the ESP8266 and shows the assigned IP address. Nothing is blocked. If helpful, the code remains unchanged in both instances (other than changing the wifi login credentials). Also 6+ months ago the ESP8266 successfully connected to the home wifi as well.

Here is code that makes the connection and sends out the IFTTT call.

-- start of relevant code
conn = nil


-- This code defines the variable "conn" as a command to create a client. 
-- Documentation for net.createConnection can be found here. https://nodemcu.readthedocs.io/en/dev/en/modules/net/#netcreateconnection
-- The format of the variable & parameters are: net.createConnection(type, secure); i.e. Type = TCP
conn=net.createConnection(net.TCP, 0) 


-- This code attempts to connect to the IFTTT Maker channel on port 80.
-- Documentation for the :dns function can be found here: https://nodemcu.readthedocs.io/en/dev/en/modules/net/#netsocketdns
-- If a connection can be made, then the connection function below will be executed, and the IP address printed.

conn:dns("maker.ifttt.com",function(conn,ip) 

-- When connected to computer wifi, "ip" returns true and executes block.  When connected to home wifi "ip" returns false and the block is not executed.

    if (ip) then
        print("We can connect to " .. ip)
        conn:connect(80,ip)
    else
		dofile("3_delay.lua")
    end
end)

-- end of relevant code

That doesn't look like Arduino code. Are you using the Arduino IDE to program your ESP8266?!? If not, you should probably ask in a forum for the IDE you are using.

Also bear in mind that if the home wifi is configured as 5GHz most ESP devices can't see it.
https://www.esp8266.com/viewtopic.php?t=4032

1 Like

Thank you. Yes, I'm connecting to 2.4 GHz networks in both cases.

Thank you. Sorry, I'm new. Yes, it's in Lua. Regardless of code, any thoughts as to why the ESP8266 would connect to my computer's wifi that's hard wired to my home router, but not to my home wifi that's connected to the same router? Again, the router "sees" the ESP8266 on my home wifi and is even pingable,which makes this all the more head scratching.

That url appears to redirect to https://ifttt.com/
I'm guessing that your PC security software runs a proxy server and takes responsibility for building the secure connection to the external site. Kaspersky Internet security, for example, does this.
If that is the reason your esp works only via the PC defined hotspot, then the esp has to be configured to directly support secure html.

That's a great call out! Thank you. Can you point me to any suggested resources on how I go about configuring the ESP to support secure HTML?

I can't help much because I have not done this. You can try this search phrase:
esp8266 https get request
because this raises most of the issues related to secure html, but I didn't notice any referenced to Lua only to the Arduino ESP8266 core.

Looking at the original code that I included, it's actually making a non-secure call (http://maker.ifttt.com). First, it's being sent on port 80 (not 443), and secure=0 is the non-secure flag designation (secure=1 is secure). Any other things that come to mind as to why this isn't working. I'm befuddled. Thank you to those who have already responded. Much appreciated.

If you enter that http:// url in a normal web browser you see that it redirects to a https:// address. Probably that is recent change by the site owner if you say that it worked 6 months ago.

Also, I found this: Service API requirements - IFTTT which implies in the first section that https is (now) mandatory.

Turns out the problem was due to the DNS server being used on the home wifi was not reachable by the ESP. Once I set the DNS server explicitly on the ESP, everything worked great while using the home wifi.

e.g. net.dns.setdnsserver("8.8.8.8", 0)

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