B4R Question [Solved] Assign a static IP to client

Mark Read

Well-Known Member
Licensed User
Using an ESP8266 in access point mode as server, not connected to a router or internet, is it possible to assign a static IP to a client?

Many thanks.
 

Mark Read

Well-Known Member
Licensed User
The ESP can stay with its default IP 192.168.4.1 but one of the clients which will be connecting needs to have a static IP. I can see no way to set this info on the ESP.

Where is the client network configuration - this is where I am stuck?
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
The ESP will create the Access Point for a small Intranet, no internet. The first client to connect will be a RPi running an OctoPi Server for a 3D printer. I think, the RPi will be very busy serving the printer which is why I wanted to use the ESP to handle the connections. I can then connect to the ESP with a windows laptop or PC and send the gcode file to be printed.

If I understand correctly, the ESP will assign an IP to each client but I would like a static IP for the RPi - if possible.
 
Upvote 0

agraham

Expert
Licensed User
If I understand correctly, the ESP will assign an IP to each client but I would like a static IP for the RPi - if possible.
Only if the client asks for it via DHCP. If you configure the RPi to have a static IP address then it won't ask and the ESP will route the packets anyway.
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Thank you Agraham. So I can set for example in the /etc/dhcpcd.conf file on the RPi:

B4X:
interface wlan0
static ip_address=192.168.4.99
static router=192.168.4.1

The programming of the ESP is then easy.
 
Last edited:
Upvote 0

Mark Read

Well-Known Member
Licensed User
Just to finish the thread. It works!

Using this code from Erel:

Link

and the change I posted in Post#7.
 
Upvote 0
Top