How to delete a static IP?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

How to delete a static IP?

Post by ZKDMun » Sun Jun 24, 2018 10:35 am

Hi,

I want to connect my ESP8266 to two different APs... on the first AP, the ESP8266 should have a static IP, but on the other AP it should be non-static.

But after the connection to the first AP with a static IP, and doing

Code: Select all

sta.disconnect() #from the first AP
sta.connect(<ESSID second AP>,<password second AP>)
my ESP8266 didnt get a new IP from the second AP... sta.ifconfig() shows me always the static IP from the first connection.

How can I delete this static IP from the first connection to get a new non-static IP from the second connection?

ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

Re: How to delete a static IP?

Post by ZKDMun » Sun Jun 24, 2018 11:35 am

On the WiPy it is possible to use sta.ifconfig(config="dhcp")?
http://docs.micropython.org/en/latest/w ... n.ifconfig

But on the ESP8266?

Doing a reset will be a solution - it works for this but I guess but it is not the best solution.

Code: Select all

import machine
machine.reset()

yeyeto2788
Posts: 28
Joined: Wed Mar 30, 2016 4:09 pm

Re: How to delete a static IP?

Post by yeyeto2788 » Mon Aug 13, 2018 11:17 am

Hello!

You might want to retrieve the status before connecting to another AP.

See documentation for retrieving it (http://docs.micropython.org/en/latest/e ... lan.status)

Should be something like this:

Code: Select all

sta.disconnect() #from the first AP
if sta.status == "STAT_IDLE":
    sta.connect(<ESSID second AP>,<password second AP>)

Hope it helps.
Regards.

Post Reply