I want to assign static IP to the webserver. I am using my mobile phone's hotspot to connect internet. Can you please guide me a tutorial.
Welcome to AAC.I want to assign static IP to the webserver. I am using my mobile phone's hotspot to connect internet. Can you please guide me a tutorial.
Thanks for your response.Welcome to AAC.
When you say “static IP” are you expecting this to be reachable from the Internet?
You will need to pick an address within your tethering network. Unless they’ve secured it in such a way that it will not allow access unless your MAC received a DHCP assignment ( a common security feature) this code should work.Thanks for your response.
No. It is ok, if it is accessible within a range.
This is the tutorial i followed. https://srituhobby.com/nodemcu-esp8266-web-server-relay-control-tutorial-step-by-step-instructions/
It works fine. But, each time a new IP is generated. I want a static ip. So that I can access with the same IP whenever i want to show the demo.
// Outside setup()
// IP address
IPAddress local_IP(192, 168, 1, 100);
// gateway address
IPAddress gateway(192, 168, 1, 1);
// netmask
IPAddress subnet(255, 255, 0, 0);
IPAddress primaryDNS(8, 8, 8, 8); // optional
IPAddress secondaryDNS(8, 8, 4, 4); // optional
setup(
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = INADDR_ANY, IPAddress dns2 = INADDR_ANY);
...
)
Since he is tethering to his cell phone, effectively he is. It will be whatever the tethering DHCP server hands out, and it will not change.Is your demo always running on the same network? Or are you moving around and demoing it at different places using the local network?
Thank you for your reply.Is your demo always running on the same network? Or are you moving around and demoing it at different places using the local network?
Thanks once again.You will need to pick an address within your tethering network. Unless they’ve secured it in such a way that it will not allow access unless your MAC received a DHCP assignment ( a common security feature) this code should work.
There is a tutorial here.ESP32 Static IP in the Arduino Environment:// Outside setup() // IP address IPAddress local_IP(192, 168, 1, 100); // gateway address IPAddress gateway(192, 168, 1, 1); // netmask IPAddress subnet(255, 255, 0, 0); IPAddress primaryDNS(8, 8, 8, 8); // optional IPAddress secondaryDNS(8, 8, 4, 4); // optional setup( bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = INADDR_ANY, IPAddress dns2 = INADDR_ANY); ... )
You should allow the device to get a DHCP address and then record those parameters. Use those.Thanks once again.
From where do i get the local_Ip, gateway, subnet, primaryDNS and secondaryDNS numbers? Are they are in my mobile phone or some random addresses?
You will need to pick an address within your tethering network. Unless they’ve secured it in such a way that it will not allow access unless your MAC received a DHCP assignment ( a common security feature) this code should work.