Research: Arduino and Wi-Fi connectivity
I was doing research on how to control my Arduino through a website.
Hardware-wise, there are several options for controlling your project over the air. You can buy an Arduino Ethernet shield, which you can literally put on your existing Uno or Mega. Or you can go for an Arduini Nano 33 IoT. The Arduino Uno Wifi R2 is also one of the options. There are also other types of boards that are not part of the 'Arduino family', such as the ESP-WROOM-32 or the ESP8266 NodeMCU. The cheapest option is the ESP 8266 01 WiFi module, you can add this module to a regular Arduino Uno.
I decided to go with the cheapest option. For 7 euros you can't really do much wrong. A first test of the ESP 8266 01 module can be found in a following blog post.
Hardware is one thing, but how the connection is made is another. Again, there are several options. The Arduino by itself can be a WebServer (with its own IP address) You can then put HTML code on the Arduino (but in a very clumsy way, see snippet below)
It works, but this way has many drawbacks. When you start adding a lot of CSS and JS, it becomes fairly messy. It also runs locally on the Arduino. So I can't reach this page on other network or on my mobile network (maybe this can be fixed with a workaround)
With a special shield (PHPoC WiFi schield) you do have the ability to upload full PHP files and host it look (see this project). This can partially solve the above problem because you don't have to write 'client.print()' every time. This type of shield also has an embedded WebSocket server. But again, this is all local.
The following demo also shows another way. Here you can more easily implement your own code and host it yourself. So you can run heavier code on your PC instead of on your Arduino I think it is also possible to use a framework like React here. It also uses the ESP 8266 module that I am going to buy. It seems most logical for me to work this way. When my wifi module arrives I will try this sketch first.
As a final option, you can also use a database. This is the most complicated option, but also the one with the most possibilities. With this one I am also sure you can control the Arduino from anywhere, including your 4G. A disadvantage is that you are working in a PHP environment (but maybe this is not necessary, I can test this later) and that an Arduino Uno is not powerful enough, for this you need a Mega.