Re-enable DHCP client

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
masteronepg
Posts: 2
Joined: Fri Sep 22, 2017 7:38 am

Re-enable DHCP client

Post by masteronepg » Fri Sep 22, 2017 7:47 am

Hi everyone
First of all I just want to say hello - I'm newbie :-)

I feel terrible - each time I had bigger or smaller problem with my ESP8266 I was able to overcome it somehow - usually googling and finding the right solution but now really I'm stucked. I don't know how to enable again dhcp client on STA_IF when previously I set IP address, mask etc. I use 1.9.2 self compiled micropython onboard.

Can anyone help me with any hint? I believe it's trivial.

Piotr

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Re-enable DHCP client

Post by pythoncoder » Sat Sep 23, 2017 6:27 am

I use this script to establish a connection (adapt for your SSID and password):

Code: Select all

def do_connect():
    import network
    sta_if = network.WLAN(network.STA_IF)
    ap = network.WLAN(network.AP_IF) # create access-point interface
    ap.active(False)         # deactivate the interface
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect('MY_SSID', 'MY_PASSWORD')
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
    a = sta_if.config('mac')
    print('MAC {:02x}:{:02x}:{:02x}:{:02x}:{:02x}'.format(a[0],a[1],a[2],a[3],a[4]))
You can erase memory of all WiFi connections by issuing

Code: Select all

esptool.py --port /dev/ttyUSB0 erase_flash
You'll then need to re-flash the firmware. Note that erasing flash will delete everything from the device's filesystem so make sure you have a backup.
Peter Hinch
Index to my micropython libraries.

masteronepg
Posts: 2
Joined: Fri Sep 22, 2017 7:38 am

Re: Re-enable DHCP client

Post by masteronepg » Mon Oct 02, 2017 2:37 pm

Dear Peter,

Thank you - I flashed once again my esp and everything get back to normal with DHCP client :)

Best wishes,
Piotr

Post Reply