Hi all,
a question about wifi and networking. I will describe two ways by which I connect to the internet, that work fine, but I do not understand the differences. Ultimately I want to combine both in one single project.
As you see, it uses a hardware serial and no special wifi libraries are needed. Works fine, does what I want it to do, which is connecting to a website somewhere.
This project too work fine. It distributes a website of its own to clients.
// -------------------------
What I want is that the server also occasionally reads a website as a client, to get the time and other initialization data.
As you can see, both methods have a very different syntax. From the documentation I do not understand how to combine both - if at all possible in a single sketch.
As you can see, both methods have a very different syntax. From the documentation I do not understand how to combine both - if at all possible in a single sketch.
You started with the WiFiServer example from the WiFi library, to set up your server.
Why not take a look at the WiFi client example(s) to see how to be a client, using the library?
Thanks, Paul, for your answer. As far as I understand, my first project as described is a client and the second a server. I followed the examples closely. What I would like to know is if a sketch can contain code for both a client and a server.
Normally, I would just try it and see, but the hardware is already tied up in the project and I update OTA. Therefore I'd rather not hang the device.
Dear Paul, thank you for your elucidating remarks.
For other people that may have the same problem: it seems as if there are different ways to communicate with wifi. In my first example, I used Serial3 on a Mega (or declared a SoftwareSerial method on an Uno). On the Wemos, I obviously had to declare a WifiClient.
This is all rather confusing and wouldn't it be nice if somewhere was a page dedicated to such differences...