Trying to understand wifi client.println() http GET

Hello,

I have been playing with my new Uno R4 wifi and trying to use the WiFiClient class client.println() method to get info from web pages, I have been following this code, and its works as written, with minor mods, for me:

WiFi Web Client | Arduino Documentation

My problems start when I try to deviate from using google.com as the main URL and 'arduino' as the query search. As written, the code basically retrieves byte by byte what the google search page returns as the results of the search. Its kind of useless and its too much data, but at least it works.

What I want to do, for now, is simply go to other simple homepages and get some basic data, even if its not especially meaningful, and I believe I need to use the http GET function, but its knowing what pages to go to, what data to get, and then how to form the GET request in proper syntax that is the issue. For now I dont want complex JSON data and API data from weather websites (for which I have examples), I just want simple info.

Can anyone advise on any good tutorials, with actual examples, of how to use GET in client.println() to get basic data with my Uno R4 wif acting as a web client?

Thanks, Steven Lightfoot

use the ArduinoHttpClient library

Thanks, very helpful, I never new such a thing existed. I will examine, and maybe comeback with questions, if you wouldn't mind.

Generally, there are no simple homepages any more. They're a bunch of HTML, maybe with a bunch of JavaScript, CSS, and/or images embedded in them.

How about simple JSON from an API? That would have a higher proportion of useful info that you might use on an Arduino. Try https://mocktarget.apigee.net/help

That part's easy. Even with an HTTP client, you pass the URL-path part, starting with a slash (after the host:port), as you've done already when manually performing HTTP with println("GET /whatever?and_maybe=a_parameter&or=two"). You use the same URL in a browser. It's all the other details that are complicated, like authentication/authorization -- aka "authN"

Thanks, very helpful. Basically what has happened is I bought two R4 wifis and want them to talk to each other, and I realized I thus needed to learn all the Arduino wifi classes, and object methods (I didnt really even understand the differences between client and server!). So I have been going through them one by one. In looking at WiFiClient class and client.println() method I mostly understood the general code, but didnt recognize the stuff in the method arguments like GET etc, and then realized its an entirely different language (http), so for now I dont really want to get data I mostly want to practice the wifi class functions in Arduino, but I wanted something basic to work for the http. But given that the examples I am using are maybe ten years its possible websites are more complex and less easy to use with really simple examples.

Eventually I will come back and really learn how to get a client talking to web servers effectively , but I am not there yet.

Steve

don't use http for communication between two Arduino.

this applies for communication of two Uno R4 WiFi too:

Thanks, very helpful. I will check that out. I had the impression that I could communicate between the two Arduinos via my wifi network (i.e. going through the router) but I also have the impression (and I need to study this more) that I can also comm between the two ESP32 radios direct, and maybe even at longer distance!