A simple way to check Internet connectivity?

If doesn't fit into any other category ....
Post Reply
Eloclegin
Posts: 33
Joined: Fri Dec 09, 2022 5:04 pm
Has thanked: 17 times
Been thanked: 7 times

A simple way to check Internet connectivity?

Post by Eloclegin »

Hello to all,

Does anyone know of a simple way in Annex32 to get the ESP32 to confirm internet connectivity. (An ESP32 that is connected to a home wifi network). In other words, confirming that the utilised home network is indeed still connected to Internet.

I am thinking … something equivalent to achieving a successful PING of a known reliable major worldwide website. I seek a solution and one that could if necessary be repeated as often as every minute, over a 24 hr period. I am sure that in my blind ignorance I am missing a very simple and obvious method!

Anyone faced this issue before and can offer a solution?

Thank you advance for sharing any thoughts
Best wishes to all
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: A simple way to check Internet connectivity?

Post by Fernando Perez »

I would use this:
image.png
You do not have the required permissions to view the files attached to this post.
BeanieBots
Posts: 351
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 187 times
Been thanked: 113 times

Re: A simple way to check Internet connectivity?

Post by BeanieBots »

The Annex command WIFI.STATUS will return 3 if it is connected.
Check the help documentation for the meaning of other returned values.

EDIT: Sorry, just re-read your post and you wanted to know if you had internet. Therefore, what Fernando Perez said.
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: A simple way to check Internet connectivity?

Post by Fernando Perez »

It seems to me that wifi.status only reports whether our module is connected to our network via Wi-Fi, but not whether there is a real connection to the Internet.

Code: [Local Link Removed for Guests]

r = ping("8.8.8.8")
if r=1 then
   wlog "Connected to the internet"
else
   wlog "Internet connection failure"
end if
Last edited by Fernando Perez on Wed Nov 01, 2023 2:03 pm, edited 1 time in total.
Eloclegin
Posts: 33
Joined: Fri Dec 09, 2022 5:04 pm
Has thanked: 17 times
Been thanked: 7 times

Re: A simple way to check Internet connectivity?

Post by Eloclegin »

Fernado
How did I miss that a PING function exists?!!!? :shock: I scanned through the Help and never saw that. I did SEARCH for PING at the Help and no results are found from the SEARCH. But now i see it. Thanks!

BeanieBots
I have used WIFI status before and had always assumed that result 3 just meant that device is connected to the network, not that network itself is also connected to Internet.
Eloclegin
Posts: 33
Joined: Fri Dec 09, 2022 5:04 pm
Has thanked: 17 times
Been thanked: 7 times

Re: A simple way to check Internet connectivity?

Post by Eloclegin »

Fernando
Thank you for the code suggestion.
All the best.
Post Reply