I'm starting to use the esp8266 wifi, do you know if it is possible to use it as well as from a wifi network using the data network maybe through an IP?
for esp8266, yes you can use B4R and it is the easier way to program something on it.
After installation of B4R, you can find a good documentation with several examples of code to connect it to network . Also this forum is a real bible of code for esp8266 with B4R
I try to make myself better.
Once I have made the connection with the home modem, if I am away from home and out of range of the modem can I access the ESP8266 anyway?
as soon as your esp is connected to your internal network it will have an internal ip address like 192.168.1.45 and your esp can access to external network, but for an access from external network to your esp, you have to create a NAT link in your adsl box from external IP address+ port => esp local IP address.
you can use also an indirect way : your mobile and esp can connect to same external server and both can communicate .(like cloudMQTT.com )
you can use firebase and in this case it is push process...
Thanks for the reply.
I followed a tutorial and was able to connect through my router,
The strange thing is that they burn gives me the IP 192.168.4.2 instead I have to use what I find in the Modem however it works.
On the other hand, if I try to access from my smartphone away from home, it gives me as ip 127.0.0.1,
I use this ip + port 2000 to connect, but nothing.
Remember that some mobile provider blocks some ports. Use a dynamic DNS to find your public IP and redirect the port to your device. 127.0.0.1 is equivalent to localhost, the device itself. This is impossible to work! If you have a static IP address you can check it once by https://www.myip.com/ or if it is dynamic you must check everytime you need.