how to change default ip address in ap mode?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
cyberlab
Posts: 56
Joined: Sat Apr 21, 2018 5:02 am

how to change default ip address in ap mode?

Post by cyberlab » Sun Nov 04, 2018 2:44 am

hello everyone I did a search in google to know how to change the default names of the network, ip address and password in ap mode, I only found the name of the network but not the ip and the password, someone knows how to do it? first of all, Thanks.

cyberlab
Posts: 56
Joined: Sat Apr 21, 2018 5:02 am

Re: how to change default ip address in ap mode?

Post by cyberlab » Sun Nov 04, 2018 4:50 am

hello again I found the password, I just need to change the ip by default 192.168.4.1, thanks in advance

macieju-1974
Posts: 3
Joined: Sun Apr 12, 2020 8:19 pm

Re: how to change default ip address in ap mode?

Post by macieju-1974 » Sun Apr 12, 2020 8:28 pm

hi, i have the same problem how to change the default ip address 192.168.4.1 to another one e.g. 192.168.82.66

Christian Walther
Posts: 169
Joined: Fri Aug 19, 2016 11:55 am

Re: how to change default ip address in ap mode?

Post by Christian Walther » Mon Apr 13, 2020 7:39 am

I believe this is done using ifconfig().

macieju-1974
Posts: 3
Joined: Sun Apr 12, 2020 8:19 pm

Re: how to change default ip address in ap mode?

Post by macieju-1974 » Thu Apr 16, 2020 6:52 pm

on my esp I have this configuration:

# Complete project details at https://RandomNerdTutorials.com

try:
import usocket as socket
except:
import socket

import network

import network
from machine import Pin
import dht

import esp
esp.osdebug(None)

import gc
gc.collect()

ssid = 'AP-esp8266_garaz'
password = '123456789'

ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid=ssid, password=password)

while ap.active() == False:
pass

print('Connection successful')
print(ap.ifconfig())

sensor = dht.DHT11(Pin(14))

# ESP8266 GPIO 5
relay = Pin(5, Pin.OUT)

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: how to change default ip address in ap mode?

Post by jimmo » Fri Apr 17, 2020 4:23 am

As Christian said, you need to add a call to ifconfig -- this works in both station and AP mode to set the device IP address.

macieju-1974
Posts: 3
Joined: Sun Apr 12, 2020 8:19 pm

Re: how to change default ip address in ap mode?

Post by macieju-1974 » Sun Apr 19, 2020 6:46 pm

thanks guys for the answer but could you make it clearer ... or some example, please

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: how to change default ip address in ap mode?

Post by jimmo » Sun Apr 19, 2020 11:24 pm

The documentation that Christian linked to had an example
http://docs.micropython.org/en/latest/l ... N.ifconfig

Put that before or after the line "ap.config(ssid=...)".

Post Reply